annotate getlist.py @ 133:0d8eabdd12ab default tip

create: write H:MM:SS timestamps, add option to fill with gaussian-blur instead of black many albums are longer than one hour so writing H:MM:SS is a necessity. if anything there will just be verbose info that isn't important for my use-case. however the gaussian-blur is simply broken. It works, and it plays locally just fine, but YouTube in particular elongates the video to fit the full width. I'm not entirely sure why it does this, but it makes it useless and ugly.
author Paper <paper@tflc.us>
date Sat, 03 Jan 2026 20:25:38 -0500
parents eac6dae753ca
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
1 import urllib.request
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
2 import json
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
3 import sys
118
eac6dae753ca *: major cleanup
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 41
diff changeset
4 from yt_dlp.utils import sanitize_filename
30
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
6 # Initialize variables
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
7 # https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
8 key = "f090bb54758cabf231fb605d3e3e0468"
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
9
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
10 # Ask for source
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
11 if not 2 >= len(sys.argv):
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
12 source = sys.argv[1]
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
13 if 'source' not in locals() or 'source' not in globals():
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
14 source = input(
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
15 "Which website would you like to pull titles from? [tmdb, mal]: ")
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
16 while source not in ["tmdb", "mal"]:
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
17 print("Not a valid source! Exiting.")
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
18 sys.exit()
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
19
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
20 # Ask for ID
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
21 if not 3 >= len(sys.argv):
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
22 source = sys.argv[2]
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
23 if 'id' not in locals() or 'id' not in globals():
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
24 id = input("What is the ID for your show?: ")
30
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 try:
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 temp = int(id)
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
27 except Exception:
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
28 print("Not a valid ID! Exiting.")
30
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 sys.exit()
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
31 # Scrapers
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
32 if source == 'tmdb':
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
33 # required because api is... odd
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
34 season = input("Which season do you want?: ")
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
35 try:
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
36 temp = int(season)
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
37 except Exception:
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
38 print("Not a valid season! Exiting.")
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
39 sys.exit()
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
40 data = json.loads(urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}?api_key={key}').read().decode())
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
41 amount = data["number_of_episodes"]
31
b5cf08125fd5 add deleteautosave.py
Paper <mrpapersonic@gmail.com>
parents: 30
diff changeset
42 f = open("list.txt", "w", encoding="utf-8")
b5cf08125fd5 add deleteautosave.py
Paper <mrpapersonic@gmail.com>
parents: 30
diff changeset
43 f.write("")
b5cf08125fd5 add deleteautosave.py
Paper <mrpapersonic@gmail.com>
parents: 30
diff changeset
44 f.close()
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
45 count = 1
40
Paper <mrpapersonic@gmail.com>
parents: 32
diff changeset
46 for i in range(amount): # this may count as spamming the api but i don't care lol
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 40
diff changeset
47 with urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url:
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
48 data = json.loads(url.read().decode())
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
49 f = open("list.txt", "a", encoding="utf-8")
118
eac6dae753ca *: major cleanup
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 41
diff changeset
50 f.write(sanitize_filename(data["name"], restricted=True) + "\n")
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
51 count += 1
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
52 f.close()
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
53 if source == 'mal':
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
54 with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url:
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
55 data = json.loads(url.read().decode())
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
56 count = 0
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
57 f = open("list.txt", "w", encoding="utf-8")
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
58 f.write("")
30
6f784c5d13ce add getlist.py
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 f.close()
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
60 for i in range(len(data["episodes"])):
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
61 f = open("list.txt", "a", encoding="utf-8")
118
eac6dae753ca *: major cleanup
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 41
diff changeset
62 f.write(sanitize_filename(data["episodes"][count]["title"], restricted=True) + "\n")
32
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
63 count += 1
fdbafd3e86d9 add tmdb to getlist.py
Paper <mrpapersonic@gmail.com>
parents: 31
diff changeset
64 f.close()