tre revised this gist 3 hours ago. Go to revision
No changes
tre revised this gist 4 hours ago. Go to revision
1 file changed, 29 insertions
yuletide-vn.py(file created)
| @@ -0,0 +1,29 @@ | |||
| 1 | + | import re,requests | |
| 2 | + | from bs4 import BeautifulSoup | |
| 3 | + | ||
| 4 | + | maxhours = 45 | |
| 5 | + | ||
| 6 | + | with open("tagset.html","r") as tagset: | |
| 7 | + | tagsoup = BeautifulSoup(tagset,"html.parser") | |
| 8 | + | fandoms = tagsoup.find_all("li",class_="fandom") | |
| 9 | + | vns = [] | |
| 10 | + | for fandom in fandoms: | |
| 11 | + | title = fandom.find("h4") | |
| 12 | + | if "Visual Novel" in title.text: | |
| 13 | + | thetitle = re.sub(" \(.*Visual Novel.*\)\n.*\n.*","",re.sub(".* \| ","",title.text.strip())) | |
| 14 | + | vns.append(thetitle) | |
| 15 | + | ||
| 16 | + | final = [] | |
| 17 | + | ||
| 18 | + | for vn in vns: | |
| 19 | + | x = requests.post("https://api.vndb.org/kana/vn",json={"filters":["and",["lang","=","en"],["search","=",vn],["olang","=","ja"],["or",["platform","=","ps4"],["platform","=","ps5"],["platform","=","swi"]]],"fields":"title, length_minutes, id"}) | |
| 20 | + | try: | |
| 21 | + | for result in x.json()["results"]: | |
| 22 | + | if result["length_minutes"] < (maxhours * 60): | |
| 23 | + | final.append(result["title"] + ": https://vndb.org/" + result["id"] + " (" + vn + ")") | |
| 24 | + | except requests.exceptions.JSONDecodeError: | |
| 25 | + | pass | |
| 26 | + | ||
| 27 | + | final = sorted(list(dict.fromkeys(final))) | |
| 28 | + | for vn in final: | |
| 29 | + | print(vn) | |
Newer
Older