comparison getlist.py @ 118:eac6dae753ca

*: major cleanup committer: GitHub <noreply@github.com>
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Fri, 03 Mar 2023 22:51:28 +0000
parents 37f231f85a67
children
comparison
equal deleted inserted replaced
117:40a7b6d9bd3b 118:eac6dae753ca
1 import urllib.request 1 import urllib.request
2 import json 2 import json
3 import sys 3 import sys
4 from yt_dlp.utils import sanitize_filename
4 5
5 # Initialize variables 6 # Initialize variables
6 # https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36 7 # https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36
7 key = "f090bb54758cabf231fb605d3e3e0468" 8 key = "f090bb54758cabf231fb605d3e3e0468"
8 9
44 count = 1 45 count = 1
45 for i in range(amount): # this may count as spamming the api but i don't care lol 46 for i in range(amount): # this may count as spamming the api but i don't care lol
46 with urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url: 47 with urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url:
47 data = json.loads(url.read().decode()) 48 data = json.loads(url.read().decode())
48 f = open("list.txt", "a", encoding="utf-8") 49 f = open("list.txt", "a", encoding="utf-8")
49 f.write(data["name"].replace("?", "?").replace( 50 f.write(sanitize_filename(data["name"], restricted=True) + "\n")
50 ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
51 count += 1 51 count += 1
52 f.close() 52 f.close()
53 if source == 'mal': 53 if source == 'mal':
54 with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url: 54 with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url:
55 data = json.loads(url.read().decode()) 55 data = json.loads(url.read().decode())
57 f = open("list.txt", "w", encoding="utf-8") 57 f = open("list.txt", "w", encoding="utf-8")
58 f.write("") 58 f.write("")
59 f.close() 59 f.close()
60 for i in range(len(data["episodes"])): 60 for i in range(len(data["episodes"])):
61 f = open("list.txt", "a", encoding="utf-8") 61 f = open("list.txt", "a", encoding="utf-8")
62 f.write(data["episodes"][count]["title"].replace("?", "?").replace( 62 f.write(sanitize_filename(data["episodes"][count]["title"], restricted=True) + "\n")
63 ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
64 count += 1 63 count += 1
65 f.close() 64 f.close()