Suppenbiatch

clipscraper

Jun 8th, 2020
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import requests
  2. import json
  3. import os
  4.  
  5. path = os.getcwd() + '\\Shlorox\\'
  6. os.makedirs(path, exist_ok=True)
  7.  
  8. start_at = 0
  9.  
  10. with open('clips.json', encoding='utf-8') as f:
  11.     data = json.load(f)
  12.  
  13. data = data[start_at:]
  14.  
  15. for i, val in enumerate(data):
  16.     print('Getting: {} - Views: {} - Clips remaining: {}'. format(val['name'], val['views'], len(data) - i))
  17.     try:
  18.         r = requests.get(val['data_url'], allow_redirects=False)
  19.         with open(path + str(i + start_at) + '_' + val['name'] + ' - (' + val['views'] + ').mp4', 'wb') as mp4_file:
  20.             mp4_file.write(r.content)
  21.     except KeyError:
  22.         print('         no clip url found :(')
Add Comment
Please, Sign In to add comment