Mercurial > codedump
changeset 102:eacdf8cc0335
Update uploadafterdl.py
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Mon, 29 Aug 2022 23:21:09 -0400 |
parents | a7d2fb3751a0 |
children | 1cc4f545a260 |
files | uploadafterdl.py |
diffstat | 1 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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)