Mercurial > codedump
changeset 30:6f784c5d13ce
add getlist.py
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 31 May 2021 15:37:50 -0400 |
parents | 41bf22504479 |
children | b5cf08125fd5 |
files | README.md getlist.py |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/README.md Mon May 31 13:02:36 2021 -0400 +++ b/README.md Mon May 31 15:37:50 2021 -0400 @@ -6,6 +6,10 @@ ### garf.cpp this was a joke program i made when garf wanted to put ads on 1123.best +### getlist.py +gets episode names from MAL, thanks to the wonderful people who run the [Jikan](https://jikan.moe/) api<br> +meant to be used with rename.py + ### intro.py originally created to extract all of the yuru yuri intros
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getlist.py Mon May 31 15:37:50 2021 -0400 @@ -0,0 +1,26 @@ +import urllib.request, json, re, sys + +id = input("What is the MyAnimeList ID for your anime?: ") +try: + temp = int(id) +except: + print("Not a valid MyAnimeList ID! Exiting.") + sys.exit() + +with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url: + data = json.loads(url.read().decode()) + count = 0 + for i in range(len(data["episodes"])): + if count == 0: + f = open("list.txt", "w", encoding="utf-8") + else: + f = open("list.txt", "a", encoding="utf-8") + """ + this is really hard to read at first glance so i'll break it down + it replaces "?" and ":" with legal counterparts so windows stops screaming + then strips among a dash (which usually shows different parts in an episode) + it then removes the last part of the string cause most, if not of MAL's have spaces before slashes + """ + f.write(data["episodes"][count]["title"].replace("?", "?").replace(":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n") + count += 1 + f.close()