SARS22

loader

Feb 21st, 2021
464
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import requests
  3.  
  4. video_url = input("Enter URL: ")
  5. video_id = video_url.split('/')[-1]
  6. final_file_name = video_url.split('/')[-2]
  7.  
  8.  
  9. def get_video(video_url):
  10.     num = 1
  11.     files = ''
  12.     while num:
  13.         piece_number = str(num).zfill(5)
  14.         url = 'https://d13z5uuzt1wkbz.cloudfront.net/' + video_id + '/HIDDEN4500-' + piece_number + '.ts'
  15.         req = requests.get(url)
  16.         file_size = (len(req.content) / 1024) /1024
  17.  
  18.         if req.status_code == 200:
  19.             file_name = url.split('/')[-1]
  20.             download_sc(url)
  21.             num = num + 1
  22.             files += file_name + ' '
  23.             print(f'Download file: {file_name} {file_size:.2f}Mb')
  24.         else:
  25.             print(f'Downloaded {num-1} files.')
  26.             os.system("cat " + files + " > " + final_file_name +".ts")
  27.             os.system("rm " + files)
  28.             print("Temporary files deleted...")
  29.             print(f"Video file {final_file_name} created.")
  30.             break
  31.  
  32. def download_sc(download_url):
  33.     file_name = download_url.split('/')[-1]
  34.  
  35.     with requests.get(download_url) as req:
  36.         with open(file_name, 'wb') as f:
  37.             for chunk in req.iter_content(chunk_size=8192):
  38.                 if chunk:
  39.                     f.write(chunk)
  40.         return file_name
  41.  
  42. get_video(video_url)
  43.  
RAW Paste Data