diff --git a/README b/README index 8b369eda2d0985e198f8841897b739807c2c877f..f875ad57ee21fe54051ad511ea444b3e08b1b555 100644 --- a/README +++ b/README @@ -1,12 +1,17 @@ python3 -m venv .venv source .venv/bin/activate -pip install requests -pip install requests_toolbelt +pip install -r requirements.txt rename and adapt config.sample.py to config.py rename and adapt usersList.sample.csv to usersList.csv rename and adapt videosList.sample.csv to videosList.csv +# Create list of user from csv python3 createUsers.py usersList.csv -python3 putVideos.py videosList.csv \ No newline at end of file + +# Upload videos from csv +python3 putVideos.py videosList.csv + +# get best definition of mp4 video for all videos +python3 getVideosMp4.py \ No newline at end of file diff --git a/getVideosMp4.py b/getVideosMp4.py new file mode 100644 index 0000000000000000000000000000000000000000..7501134d72f2b589d7cd833d68e47c2f05fcd628 --- /dev/null +++ b/getVideosMp4.py @@ -0,0 +1,54 @@ +import requests +import sys +import json +import os + +import config + +headers_json={ + 'Content-Type':'application/json', + 'Authorization': 'Token {}'.format(config.POD_TOKEN) +} + +payload_search_videos={ + +} + +hasNext = True +url_to_fetch=config.POD_API_UPLOAD_VIDEO +while(hasNext): + response = requests.get(url_to_fetch, headers=headers_json, params=payload_search_videos) + if(response.status_code != 200): + print("ERROR get [%s] : [CODE:%s]" % (url_to_fetch,response.status_code)) + else: + result = json.loads(response.content.decode("utf-8")) + if(result['count'] == 0): + print("Videos not found") + else: + for video in result['results']: + id=video['id'] + slug=video['slug'] + mp4_orig_url=video['video'] + mp4_orig_url_start='/'.join(mp4_orig_url.split('/')[:-1]) + + found_mp4 = False + for definition in ('1080p', '720p', '360p'): + mp4_url='/'.join((mp4_orig_url_start,f'{id:04}',('%s.mp4' % definition))) + r = requests.head(mp4_url) + if(r.status_code == 200): + found_mp4 = True + print("[ID:%s] [SLUG:%s] [URL:%s]" % (id, slug, mp4_url)) + break + if(not found_mp4): + print("[ID:%s] [SLUG:%s] [URL:no mp4 found]" % (id,slug)) + + if(result['next']): + hasNext=True + url_to_fetch=result['next'] + print("next page : %s" % url_to_fetch) + else: + print("no next page") + hasNext=False + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8550bb5c6a27c06d8c9f799821637a9d87e141dd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +requests_toolbelt \ No newline at end of file