Mercurial > codedump
comparison uploadafterdl.py @ 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 | a9776ed0538b |
children |
comparison
equal
deleted
inserted
replaced
101:a7d2fb3751a0 | 102:eacdf8cc0335 |
---|---|
1 from tubeup.TubeUp import TubeUp | 1 from tubeup.TubeUp import TubeUp |
2 from yt_dlp.utils import sanitize_filename | 2 from yt_dlp.utils import sanitize_filename |
3 import glob | 3 import glob |
4 import json | 4 import json |
5 import os | 5 import os |
6 import internetarchive | |
7 | |
8 seen_ids = [] | |
6 | 9 |
7 tu = TubeUp() | 10 tu = TubeUp() |
8 | 11 |
9 for basename in glob.glob('*.info.json'): | 12 for basename in glob.glob('*.info.json'): |
10 print(basename + " " + str(os.path.getsize(basename))) | 13 print(basename + " " + str(os.path.getsize(basename))) |
14 sanitize_filename(basename[:-10] + ".webm", restricted=True)]): | 17 sanitize_filename(basename[:-10] + ".webm", restricted=True)]): |
15 print("no video downloaded") | 18 print("no video downloaded") |
16 continue | 19 continue |
17 with open(basename, "r", encoding="utf-8") as jf: | 20 with open(basename, "r", encoding="utf-8") as jf: |
18 jsons = json.load(jf) | 21 jsons = json.load(jf) |
19 try: | 22 jsons["extractor"] = "youtube" if "extractor" not in jsons else jsons["extractor"] |
20 jsons["extractor"] | 23 jsons["display_id"] = basename[:-10].split("-")[:-11] if "extractor" not in jsons else jsons["id"] |
21 except: | 24 jsons["title"] = jsons["fulltitle"] if "extractor" not in jsons else jsons["title"] |
22 jsons["extractor"] = "youtube" | 25 jsons["webpage_url"] = "https://youtube.com/watch?v=%s" % (jsons["display_id"]) |
23 try: | |
24 jsons["display_id"] = jsons["id"] | |
25 except: | |
26 jsons["display_id"] = basename[:-10].split("-")[:-11] | |
27 try: | |
28 jsons["title"] | |
29 except: | |
30 jsons["title"] = jsons["fulltitle"] | |
31 jsons["webpage_url"] = "https://youtube.com/watch?v=%s" % jsons["display_id"] | |
32 jsons["extractor_key"] = "Youtube" | 26 jsons["extractor_key"] = "Youtube" |
33 with open(basename, "w", encoding="utf-8") as jf: | 27 with open(basename, "w", encoding="utf-8") as jf: |
34 jf.write(json.dumps(jsons)) | 28 jf.write(json.dumps(jsons)) |
35 identifier, meta, item_exists = tu.upload_ia(sanitize_filename(basename[:-10])) | 29 if not internetarchive.get_item("%s-%s" % (jsons["extractor"], jsons["display_id"])).exists: |
36 print("%s, %s, %s" % (identifier, meta, item_exists)) | 30 identifier, meta = tu.upload_ia(sanitize_filename(basename[:-10])) |
37 print("uploaded %s" % basename) | 31 print("%s, %s" % (identifier, meta)) |
32 print("uploaded %s" % basename) | |
33 else: | |
34 print("skipped %s, item already exists" % basename) |