Skip to content

Instantly share code, notes, and snippets.

@Shiroizu
Last active December 14, 2019 10:43
Show Gist options
  • Save Shiroizu/1f270a3f61197dda556367660826da8f to your computer and use it in GitHub Desktop.
Save Shiroizu/1f270a3f61197dda556367660826da8f to your computer and use it in GitHub Desktop.
VocaDB song notification songlist -creator
import datetime
import requests
userID =
login = {
'UserName': 'user',
'password': 'pass'
}
# --- # --- # --- # --- #
date = str(datetime.datetime.now())[:10] # YYYY-MM-DD
songlist = {
"songLinks": [],
"author": {"id": userID},
"name": "Song Notifications " + date
}
order = 1 # For the songlist API
songIDS = [] # to avoid duplicates
with requests.Session() as s:
p = s.post("https://vocadb.net/User/Login", data=login)
r = s.get(f"https://vocadb.net/api/users/{userID}/messages?inbox=Notifications&unread=true&maxResults=50")
for item in r.json()["items"]:
if "song" in item["subject"]:
notif = s.get(f"https://vocadb.net/api/users/messages/{item['id']}")
songID = notif.json()["body"].split("/S/")[-1].split(")',")[0]
if s.get("https://vocadb.net/api/songs/" + songID).json()["pvServices"] == "Nothing":
continue # Skip entries without PVs
if songID not in songIDS:
songlist["songLinks"].append({"order": order, "song": {"id": int(songID)}})
songIDS.append(songID)
order += 1
r = s.post("https://vocadb.net/api/songLists", json=songlist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment