Skip to content
Snippets Groups Projects
Commit c7c771e3 authored by MARCHAL Julien's avatar MARCHAL Julien
Browse files

add getVideosMp4.py and requirements.txt for pip install

parent d16ac203
Branches
No related tags found
No related merge requests found
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
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
requests
requests_toolbelt
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment