Skip to content

Instantly share code, notes, and snippets.

@Shiroizu Shiroizu/notifs.py
Created Aug 9, 2019

Embed
What would you like to do?
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
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
songlist["songLinks"].append({"order": order, "song": {"id": int(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
You can’t perform that action at this time.