# HG changeset patch # User Paper <37962225+mrpapersonic@users.noreply.github.com> # Date 1661829669 14400 # Node ID eacdf8cc0335b260a8e5f4d9cf3c863d8cc30a91 # Parent a7d2fb3751a02d5f50df18d50894028e960c8857 Update uploadafterdl.py committer: GitHub diff -r a7d2fb3751a0 -r eacdf8cc0335 uploadafterdl.py --- a/uploadafterdl.py Sun Aug 28 19:48:44 2022 -0400 +++ b/uploadafterdl.py Mon Aug 29 23:21:09 2022 -0400 @@ -3,6 +3,9 @@ import glob import json import os +import internetarchive + +seen_ids = [] tu = TubeUp() @@ -16,22 +19,16 @@ continue with open(basename, "r", encoding="utf-8") as jf: jsons = json.load(jf) - try: - jsons["extractor"] - except: - jsons["extractor"] = "youtube" - try: - jsons["display_id"] = jsons["id"] - except: - jsons["display_id"] = basename[:-10].split("-")[:-11] - try: - jsons["title"] - except: - jsons["title"] = jsons["fulltitle"] - jsons["webpage_url"] = "https://youtube.com/watch?v=%s" % jsons["display_id"] + jsons["extractor"] = "youtube" if "extractor" not in jsons else jsons["extractor"] + jsons["display_id"] = basename[:-10].split("-")[:-11] if "extractor" not in jsons else jsons["id"] + jsons["title"] = jsons["fulltitle"] if "extractor" not in jsons else jsons["title"] + jsons["webpage_url"] = "https://youtube.com/watch?v=%s" % (jsons["display_id"]) jsons["extractor_key"] = "Youtube" with open(basename, "w", encoding="utf-8") as jf: jf.write(json.dumps(jsons)) - identifier, meta, item_exists = tu.upload_ia(sanitize_filename(basename[:-10])) - print("%s, %s, %s" % (identifier, meta, item_exists)) - print("uploaded %s" % basename) + if not internetarchive.get_item("%s-%s" % (jsons["extractor"], jsons["display_id"])).exists: + identifier, meta = tu.upload_ia(sanitize_filename(basename[:-10])) + print("%s, %s" % (identifier, meta)) + print("uploaded %s" % basename) + else: + print("skipped %s, item already exists" % basename)