Created
July 27, 2020 04:26
-
-
Save NyaMisty/2935f8b2501d58f7653a9f7da9750416 to your computer and use it in GitHub Desktop.
NIJISANJI to vdb~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding("UTF8") | |
import requests, re, json | |
sess = requests.Session() | |
r = sess.get("https://nijisanji.ichikara.co.jp/member/") | |
urls = re.findall(r"href=(https://nijisanji\.ichikara\.co\.jp/member/.*?)>", r.text) | |
ret = [] | |
for u in urls: | |
r = sess.get(u) | |
name = re.findall(r'class="elementor-heading-title elementor-size-default">(.*?)</h2>', r.text)[0] | |
u2b = re.findall(r"https://www\.youtube\.com/channel/(.*?)\?sub_confirmation=1", r.text)[0] | |
twi = re.findall(r'href="https://twitter\.com/(.*?)"', r.text)[0] | |
ret.append((name, u2b, twi)) | |
json.dump(ret, open("nijisanji.json", 'w'), ensure_ascii=False, indent=2) | |
r = requests.get("https://vdb.vtbs.moe/json/list.json") | |
missing = [c for c in ret if c[1] not in r.text and c[2] not in r.text] | |
json.dump(missing, open("nijisanji-missing.json", 'w'), ensure_ascii=False, indent=2) | |
template = """{ | |
"name": { | |
"jp": "{NAME}" | |
}, | |
"accounts": { | |
"youtube": "{U2B}", | |
"twitter": "{TWI}" | |
}, | |
"group": "NIJISANJI" | |
}""" | |
commands = [["name", "NyaMisty"]] | |
for c in missing: | |
content = template.replace("{NAME}", c[0]).replace("{U2B}", c[1]).replace("{TWI}", c[2]) | |
commands.append(["put", "%s.json" % c[0], content]) | |
print json.dumps(commands) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment