Open AdrianEdelen opened 1 year ago
apple music api docs: https://developer.apple.com/documentation/applemusicapi
I am not sure, but I think apple may require a developer account.
YT Music:
I found a 3rd party API that seems to work: here is the python snippet
from ytmusicapi import YTMusic
ytmusic = YTMusic("headers_auth.json")
history = ytmusic.get_history()
print(history[0])
You need to get post headers manually the first time, but once you have them you can use a json file to authenticate.
this request gets the history, which can be periodically checked. the first item on the history update pretty much as soon as you start playing a song.
I tested this playing a song on my phone and then making the request ~5-10 seconds after the song started.
Response (minus tokens)
{'videoId': 'oXqBnl-qL_o', 'title': 'Apotheosis', 'artists': [{'name': 'Lorna Shore', 'id': 'UCyqgKuAOtkK4BM61QADpsRQ'}], 'album': {'name': 'Pain Remains', 'id': 'MPREb_vfcxHvRZ4d9'}, 'likeStatus': 'INDIFFERENT', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/GopyhBGIUSqTdLP064FSiks2wBCAUZD3IURp1LXCP2zfakVQaqsM6V2xv2ZOwiRiNvC58sMXFJQwMH3W=w60-h60-l90-rj', 'width': 60, 'height': 60}, {'url': 'https://lh3.googleusercontent.com/GopyhBGIUSqTdLP064FSiks2wBCAUZD3IURp1LXCP2zfakVQaqsM6V2xv2ZOwiRiNvC58sMXFJQwMH3W=w120-h120-l90-rj', 'width': 120, 'height': 120}], 'isAvailable': True, 'isExplicit': False, 'videoType': 'MUSIC_VIDEO_TYPE_ATV', 'duration': '4:55', 'duration_seconds': 295, 'feedbackTokens': {'add': '
Benefits: will work with any device playing music on that authenticated account. gives the album art url right there.
cons: requires first time (and possibly repeat) manual authentication. can be confusing if you don't know how it works.
apple music api docs: https://developer.apple.com/documentation/applemusicapi
I am not sure, but I think apple may require a developer account.
We can piggyback off of the Discord rich presence code. Apple developer accounts aren't too hard to get iirc.
https://github.com/kkevinm/iTunes-Discord-RP
Edit: Apparently this dev gave up on the project and the application does not really work anymore but the basics of the code should still be useful.
Clients to consider: iTunes Spotify YT Music Plexamp Tidal. more to come, I'm sure.
Issue: As it stands we have no way to actually determine which song is playing. There are several approaches to this, though it currently is unclear which if any will work.
Approach 1: native API. for some clients out there there is definitely a native API that will make this very easy. Approach 2: 3rd party API. Approach 3: OCR, CV tools to monitor the client (this can either be to scan determine the album art, or literally just screencap it and send it to the screen. Approach 4: Audio recognition. likely to be the hardest approach, but in theory could be client agnostic. listening to the audio stream on the pc however means OS dependency.
Any other ideas are welcome.