From dac703aafaf393a1cfe25b0e0d5ed4b9bc2f0751 Mon Sep 17 00:00:00 2001 From: tech234a <46801700+tech234a@users.noreply.github.com> Date: Wed, 23 Sep 2020 23:29:07 -0400 Subject: [PATCH] Export retries on exception --- export.py | 86 ++++++++++++++++++++++++++++-------------------------- tracker.py | 2 +- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/export.py b/export.py index c8f2d03..d8bec63 100644 --- a/export.py +++ b/export.py @@ -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 diff --git a/tracker.py b/tracker.py index 480eee3..38aad30 100644 --- a/tracker.py +++ b/tracker.py @@ -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"