-
-
Save UnrelatedString/5b4c660c833bebc1118e66de56f9899b to your computer and use it in GitHub Desktop.
SE Nitro Cubari gist generator
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
#! /usr/bin/python3 | |
import requests | |
import json | |
import re | |
from sys import stdout | |
def main(): | |
request = requests.get('https://se-nitro.surge.sh/data.js') | |
js = request.text | |
deassigned = re.sub(r'const parts = ', '', js) | |
decommented = re.sub(r'//.*$', '', deassigned, flags = re.MULTILINE) | |
desinglequoted = re.sub(r"'.*'(,?)$", r'0\1', decommented, flags = re.MULTILINE) # this is fucked up but whatever | |
detrailingcommad = re.sub(r',\s*]', ']', desinglequoted) | |
data = json.loads(detrailingcommad) | |
chapters = {} | |
# https://github.com/subject-f/cubarimoe/blob/243414186c8e88c219c9ea0e2c69b41164cf53a6/proxy/sources/gist.py | |
absolute_chapter = 0 | |
for a, part in enumerate(data, start=1): | |
for b, chapter in enumerate(part, start=1): | |
absolute_chapter += 1 | |
page_urls = [f'https://se-nitro.surge.sh/comics/p{a}/c{b}/{c}.png' | |
for c in range(1, len(chapter)+1)] | |
chapters[f'{absolute_chapter}'] = { | |
'title': f'Part {a}, Chapter {b}', | |
'volume': f'{a}', | |
'groups': { | |
'Par for the Course Comics': page_urls | |
} | |
} | |
gist_dict = dict( | |
title = "SE Nitro", | |
description = "good question", | |
chapters = chapters | |
) | |
json.dump(gist_dict, stdout) | |
print() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment