Skip to content

Instantly share code, notes, and snippets.

@tkoz0
Last active April 15, 2021 22:11
Show Gist options
  • Save tkoz0/8176c216bd52fb1c36a7b8b7d9c9691a to your computer and use it in GitHub Desktop.
Save tkoz0/8176c216bd52fb1c36a7b8b7d9c9691a to your computer and use it in GitHub Desktop.
Small dumb things for AMQ related data
-- Getting the song list JSON from expand library --
1. Go to AMQ page
2. Open developer menu (F12 in firefox) network tab
3. Log in
4. Set anime list(s)
5. Open expand library and wait for it to load
6. Filter network tab to WS (websocket)
7. Click on the websocket connection
8. Open the response tab on the right
9. Find the data in the list with "expandLibrary questions"
10. Right click and copy message
11. Save it elsewhere but delete the "42" at the beginning
import json
import os
import re
import sys
# filename format
# the \[.*\] at the end matches notes I may add between []
file_re = re.compile(r'song_export_\d{4}(-\d\d){2}_(\d\d-){2}\d\d(\[.*\])?.json')
# use args for input or cwd if not provided
# use args for input of directories, otherwise use cwd only
if len(sys.argv) > 1:
dirs = sys.argv[1:]
else:
dirs = ['.']
# list (filename,path) for all files, sort by filename (which has date)
files = sum( ( [ (file,os.path.join(dir_,file))
for file in os.listdir(dir_) if file_re.fullmatch(file)]
for dir_ in dirs),[])
files = sorted(files)
# merge into 1 list and write json to stdout
merge = sum((json.loads(open(f[1],'r').read()) for f in files),[])
sys.stderr.write('read %d songs\n'%len(merge))
print(json.dumps(merge,separators=(',',':')),end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment