Skip to content

Commit

Permalink
bismillah
Browse files Browse the repository at this point in the history
  • Loading branch information
ensargx committed Nov 26, 2023
1 parent bb49d88 commit 2b71f3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions upload_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def download_video(title, url):
# Return a video object
os.system(f"curl '{url}' -o '{title}.mp4'")

def check_if_auth_code_valid(auth_code):
r = requests.get(f'https://youtube.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=Ks-_Mh1QhMc&key={auth_code}')
print(f"Checking if auth code is valid: {r.status_code}")
print(r.content)
assert r.status_code == 200

def create_resumable_upload(auth_token, video_len, title):
r = requests.post("https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status,contentDetails", headers={
'Authorization': f'Bearer {auth_token}',
Expand Down Expand Up @@ -50,6 +56,8 @@ def upload_video(location, title, auth_token, video_len):


auth_token = os.getenv('AUTH_TOKEN')
assert auth_token != None
check_if_auth_code_valid(auth_token)
videos = load_videos('videos.json')

for video in videos:
Expand Down
2 changes: 1 addition & 1 deletion videos.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"title": "Re Zero Part 11",
"url": "https://dv8-2.sibnet.ru/44/50/43/4450436.mp4?st=z4fUI6tJUAG-q6U0uy55Mg&e=1700980000&stor=8&noip=1"
"url": "https://dv8-2.sibnet.ru/44/50/43/4450436.mp4?st=aigsKKNCwNbeFo_M6avH5Q&e=1701010000&stor=8&noip=1"
}
]

0 comments on commit 2b71f3e

Please sign in to comment.