(WIP) Added update script

This commit is contained in:
tom5079
2020-10-05 18:06:49 +09:00
parent e9cbb64c89
commit 97e060fa0c
8 changed files with 51 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.vscode/

View File

@@ -1,3 +0,0 @@
{
"test": "test"
}

0
ko.json Normal file
View File

2
scripts/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
requests
beautifulsoup4

48
scripts/tags.py Normal file
View File

@@ -0,0 +1,48 @@
# Returns a list of all tags sorted by the number of tags
import re
import json
import requests
from bs4 import BeautifulSoup
indices = ['123'] + [chr(ord('a')+i) for i in range(26)]
tags = dict()
count_regex = re.compile(r".+\((\d+)\)$")
for index in indices:
url = f'https://hitomi.la/alltags-{index}.html'
soup = BeautifulSoup(requests.get(url).text, 'html.parser')
for item in soup.select('.content li'):
tag = item.a.text
count = int(count_regex.match(item.text).group(1))
tags[tag] = count
break
tag_regex = re.compile(r".+:(.+)$")
def clean(tag):
match = tag_regex.match(tag)
if match:
return match.group(1)
else:
return tag
temp = dict()
for k, v in tags.items():
tag = clean(k)
if tag in temp:
if v > temp[tag]:
temp[tag] = v
else:
temp[tag] = v
tags = sorted(temp, key=temp.get, reverse=True)
print(json.dumps(tags, indent=4))

0
scripts/update.py Normal file
View File

0
scripts/update.sh Normal file
View File

0
template.json Normal file
View File