1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-03-07 13:01:37 +00:00

Improve ytInitialData extraction

This commit is contained in:
Cadence Ember 2020-12-03 17:00:06 +13:00
parent ba88c53857
commit 554cd8cc3a
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 9 additions and 6 deletions

View file

@ -28,6 +28,11 @@ def get_created_files(id):
id = "_" + id[1:] # youtube-dl changes - to _ at the start, presumably to not accidentally trigger switches with * in shell
return (f for f in os.listdir() if f.startswith("{}_".format(id)))
def clean_up_temp_files(id):
created_files = get_created_files(id)
for file in created_files:
os.unlink(file)
def format_order(format):
# most significant to least significant
# key, max, order, transform
@ -172,6 +177,8 @@ def extract_video(id):
return result
except youtube_dlc.DownloadError as e:
clean_up_temp_files(id)
if isinstance(e.exc_info[1], urllib.error.HTTPError):
if e.exc_info[1].code == 429:
result = {
@ -192,9 +199,7 @@ def extract_video(id):
print("messed up in original transform.")
finally:
created_files = get_created_files(id)
for file in created_files:
os.unlink(file)
clean_up_temp_files(id)
return result
def get_more_stuff_from_file(id, result):