Browse Source

Export retries on exception

microtasks
tech234a 3 years ago
parent
commit
dac703aafa
2 changed files with 46 additions and 42 deletions
  1. +45
    -41
      export.py
  2. +1
    -1
      tracker.py

+ 45
- 41
export.py View File

@@ -90,47 +90,51 @@ def subprrun(jobs, mysession, langcode, vid, mode):
print(langcode, vid)

while True:
if mode == "default":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
("bl", "vmp"),
("ui", "hd"),
("tab", "captions"),
("o", "U")
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)
elif mode == "forceedit-metadata":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
('forceedit', 'metadata'),
('tab', 'metadata')
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)
elif mode == "forceedit-captions":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
("bl", "vmp"),
("ui", "hd"),
('forceedit', 'captions'),
("tab", "captions"),
("o", "U")
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)

if not "accounts.google.com" in page.url:
break
else:
print("[Retrying in 30 seconds] Please supply authentication cookie information in config.json or environment variables. See README.md for more information.")
sleep(30)
try:
if mode == "default":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
("bl", "vmp"),
("ui", "hd"),
("tab", "captions"),
("o", "U")
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)
elif mode == "forceedit-metadata":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
('forceedit', 'metadata'),
('tab', 'metadata')
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)
elif mode == "forceedit-captions":
pparams = (
("v", vid),
("lang", langcode),
("action_mde_edit_form", 1),
("bl", "vmp"),
("ui", "hd"),
('forceedit', 'captions'),
("tab", "captions"),
("o", "U")
)

page = mysession.get("https://www.youtube.com/timedtext_editor", params=pparams)

if not "accounts.google.com" in page.url:
break
else:
print("[Retrying in 30 seconds] Please supply authentication cookie information in config.json or environment variables. See README.md for more information.")
sleep(30)
except:
print("Error in request, retrying in 5 seconds...")
sleep(5)

inttext = page.text



+ 1
- 1
tracker.py View File

@@ -9,7 +9,7 @@ from os.path import isfile
from json import loads

# https://github.com/ArchiveTeam/tencent-weibo-grab/blob/9bae5f9747e014db9227821a9c11557267967023/pipeline.py
VERSION = "20200923.06"
VERSION = "20200923.07"

TRACKER_ID = "ext-yt-communitycontribs"
TRACKER_HOST = "trackerproxy.meo.ws"


Loading…
Cancel
Save