Mercurial > codedump
diff 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 |
line wrap: on
line diff
--- a/getlist.py Mon May 31 15:37:50 2021 -0400 +++ b/getlist.py Sat Jun 05 16:32:38 2021 -0400 @@ -1,6 +1,8 @@ import urllib.request, json, re, sys -id = input("What is the MyAnimeList ID for your anime?: ") +id = sys.argv[1] +if not 'id' in locals() or not 'id' in globals(): + id = input("What is the MyAnimeList ID for your anime?: ") try: temp = int(id) except: @@ -10,11 +12,11 @@ with urllib.request.urlopen(f"https://api.jikan.moe/v3/anime/{str(id)}/episodes") as url: data = json.loads(url.read().decode()) count = 0 + f = open("list.txt", "w", encoding="utf-8") + f.write("") + f.close() 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") + 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