Mercurial > codedump
comparison uploadafterdl.py @ 71:a9776ed0538b
Create uploadafterdl.py
committer: GitHub <noreply@github.com>
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Sun, 19 Jun 2022 04:20:21 -0400 |
| parents | |
| children | eacdf8cc0335 |
comparison
equal
deleted
inserted
replaced
| 70:eafe13de3f76 | 71:a9776ed0538b |
|---|---|
| 1 from tubeup.TubeUp import TubeUp | |
| 2 from yt_dlp.utils import sanitize_filename | |
| 3 import glob | |
| 4 import json | |
| 5 import os | |
| 6 | |
| 7 tu = TubeUp() | |
| 8 | |
| 9 for basename in glob.glob('*.info.json'): | |
| 10 print(basename + " " + str(os.path.getsize(basename))) | |
| 11 if os.path.getsize(basename) != 0: | |
| 12 if not any(x in os.listdir(".") for x in [sanitize_filename(basename[:-10] + ".mp4", restricted=True), | |
| 13 sanitize_filename(basename[:-10] + ".mkv", restricted=True), | |
| 14 sanitize_filename(basename[:-10] + ".webm", restricted=True)]): | |
| 15 print("no video downloaded") | |
| 16 continue | |
| 17 with open(basename, "r", encoding="utf-8") as jf: | |
| 18 jsons = json.load(jf) | |
| 19 try: | |
| 20 jsons["extractor"] | |
| 21 except: | |
| 22 jsons["extractor"] = "youtube" | |
| 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" | |
| 33 with open(basename, "w", encoding="utf-8") as jf: | |
| 34 jf.write(json.dumps(jsons)) | |
| 35 identifier, meta, item_exists = tu.upload_ia(sanitize_filename(basename[:-10])) | |
| 36 print("%s, %s, %s" % (identifier, meta, item_exists)) | |
| 37 print("uploaded %s" % basename) |
