Mercurial > codedump
comparison getlist.py @ 31:b5cf08125fd5
add deleteautosave.py
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 05 Jun 2021 16:32:38 -0400 |
parents | 6f784c5d13ce |
children | fdbafd3e86d9 |
comparison
equal
deleted
inserted
replaced
30:6f784c5d13ce | 31:b5cf08125fd5 |
---|---|
1 import urllib.request, json, re, sys | 1 import urllib.request, json, re, sys |
2 | 2 |
3 id = input("What is the MyAnimeList ID for your anime?: ") | 3 id = sys.argv[1] |
4 if not 'id' in locals() or not 'id' in globals(): | |
5 id = input("What is the MyAnimeList ID for your anime?: ") | |
4 try: | 6 try: |
5 temp = int(id) | 7 temp = int(id) |
6 except: | 8 except: |
7 print("Not a valid MyAnimeList ID! Exiting.") | 9 print("Not a valid MyAnimeList ID! Exiting.") |
8 sys.exit() | 10 sys.exit() |
9 | 11 |
10 with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url: | 12 with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url: |
11 data = json.loads(url.read().decode()) | 13 data = json.loads(url.read().decode()) |
12 count = 0 | 14 count = 0 |
15 f = open("list.txt", "w", encoding="utf-8") | |
16 f.write("") | |
17 f.close() | |
13 for i in range(len(data["episodes"])): | 18 for i in range(len(data["episodes"])): |
14 if count == 0: | 19 f = open("list.txt", "a", encoding="utf-8") |
15 f = open("list.txt", "w", encoding="utf-8") | |
16 else: | |
17 f = open("list.txt", "a", encoding="utf-8") | |
18 """ | 20 """ |
19 this is really hard to read at first glance so i'll break it down | 21 this is really hard to read at first glance so i'll break it down |
20 it replaces "?" and ":" with legal counterparts so windows stops screaming | 22 it replaces "?" and ":" with legal counterparts so windows stops screaming |
21 then strips among a dash (which usually shows different parts in an episode) | 23 then strips among a dash (which usually shows different parts in an episode) |
22 it then removes the last part of the string cause most, if not of MAL's have spaces before slashes | 24 it then removes the last part of the string cause most, if not of MAL's have spaces before slashes |