Kometa-Team / Kometa

Python script to update metadata information for items in plex as well as automatically build collections and playlists. The Wiki Documentation is linked below.
https://kometa.wiki
MIT License
2.44k stars 304 forks source link

[Feature]: TuneFind.com as a metadata source for Music libraries #938

Closed DeftNerd closed 2 years ago

DeftNerd commented 2 years ago

Is your feature request related to a problem? Please elaborate.

I love that PMM now supports music libraries, but there is a lack of metadata sources for music information to build playlists. There are some obvious starting choices (spotify, apple music, last.fm, etc) but I would like to suggest tunefind.com

Describe the solution you'd like

TuneFind.com would be a great metadata source for PMM! It's a collaborative site where people identify and list songs they hear in movies or TV shows. This could conceivably allow a PMM user to make music playlists for TV series they have in their library. Binge watching a new TV show? When you're driving around, you can listen to the PMM generated soundtrack based on what already exists within your music collection.

General Info

As a fallback, it is possible to scrape pages. They store all the useful data in a HTML script tag called "__NEXT_DATA__" in a slightly different structure... but the easiest way is through the public API that I discovered by just watching the network activity tab in Firefox.

Useful API Endpoints for Discovery

category url description
tv https://www.tunefind.com/api/frontend/show Shows either airing now, newly added, or popular
tv https://www.tunefind.com/api/frontend/episode?sort=recently-aired Shows that have had episodes recently aired
tv https://www.tunefind.com/api/frontend/show/browse List of all shows (about 2700)
movies https://www.tunefind.com/api/frontend/movie Movies either featured, recently added, or recently updated
movies https://www.tunefind.com/api/frontend/movies?sort=recently-released Recently released movies
movies https://www.tunefind.com/api/frontend/movie/browse List of all movies (almost 7000)
games https://www.tunefind.com/api/frontend/game Games either featured, recently added, or recently updated
games https://www.tunefind.com/api/frontend/games?sort=recently-released Recently released games
games https://www.tunefind.com/api/frontend/game/browse List of all games (over 800)
songs https://www.tunefind.com/api/frontend/trending/now Songs trending right now across all media types
songs https://www.tunefind.com/api/frontend/trending/lastweek Songs trending last week across all media types

Searching

One method is to use their Algolia instance. An example search that returns JSON is: https://owe3eigao9-dsn.algolia.net/1/indexes/tunefind-prod?x-algolia-application-id=OWE3EIGAO9&x-algolia-api-key=e73d0fd588e6c0e221c6f8d79b833671&query=testing

You can also add some parameters to narrow down the search, like... facetFilters=[["type: show","type: movie"]] limits the results to the show and movie categories hitsPerPage=40 returns 40 results per page rather than the default 20

One example is: https://owe3eigao9-dsn.algolia.net/1/indexes/tunefind-prod?x-algolia-application-id=OWE3EIGAO9&x-algolia-api-key=e73d0fd588e6c0e221c6f8d79b833671&query=stranger+things&facetFilters=[[%22type:%20show%22,%22type:%20movie%22]]&hitsPerPage=40

The data that's returned is pretty simple to understand, but just a heads up that the cnt key lists the number of songs associated with the matching object... so for "stranger things" we can easily see that it's a show and the partial URL is /show/stranger-things and it has 384 songs.

More documentation can be found at: https://www.algolia.com/doc/rest-api/search/

TV Show - Show summary with a list of seasons

Example: https://www.tunefind.com/api/frontend/show/for-all-mankind?fields=seasons,similars,theme-song&metatags=1

TV Show - Season summary with a list of episodes

Example: https://www.tunefind.com/api/frontend/show/for-all-mankind/season/1?fields=episodes,theme-song,music-supervisors,hot-songs,composers,albums&metatags=1

TV Episode with a detailed list of songs

Example: https://www.tunefind.com/api/frontend/episode/92291?fields=song-events,nextPrev The episode ID in the URL is from the previous TV Season API call

Artist Info with a list of where their songs appear

Example: https://www.tunefind.com/api/frontend/artist/squirrel-nut-zippers?fields=appearances,meta,songs_count

Returns useful fields about the musical artist like name, image, HTML formatted biography, links to their various official sites and pages, links to their artist pages on music DL/streaming services, and the number of songs they have that have been featured in TV shows or movies that tunefind knows about. > appearances is a collection of data that includes all the TV shows and movies that the song has appeared in > popularity is an sorted array. The values represent the song_id in the appearances. The first item in the array is the most popular, the last item the least popular.

Public User Profile

Example: https://www.tunefind.com/api/frontend/profile/MaggiePhillips

Some artists are a member of the site. The results are similar in concept to the previous Artist Info endpoint

Game Details

https://www.tunefind.com/api/frontend/game/halo-infinite-2021?fields=song-events,theme-song,hot-songs,music-supervisors,similars,composers

Movie Details

Good example of a score: https://www.tunefind.com/api/frontend/movie/lightyear-2022?fields=song-events,hot-songs,music-supervisors,similars,composers Good example of a soundtrack: https://www.tunefind.com/api/frontend/movie/trainspotting-1996?fields=song-events,hot-songs,music-supervisors,similars,composers

Interesting observations

https://www.tunefind.com/api/frontend/user/current is called on most HTML pages and includes a response like

{"user":null,"csrf_token":"fE2GN8Kh189UjpMeP6tY1kP5dSC3YGtoLiju5fhW","notice":null,"nag_login":false,"nag_count":0}

The whole nag_login and nag_count makes me think that even the frontend public API may have some usage monitoring or rate limiting. I've never hit it, so I don't know what it looks like when that happens.

Additional Information

TuneFind does have an official API, but it looks like they're really trying to figure out how best to monetize it... The API endpoints I used above as examples are sourced from browsing the site itself. They might try to lock it down if it gets too popular. Also, tunefine is behind cloudflare so it would be important to make sure that CF isn't trying to do a CAPTCHA test during requests, and skipping the rest of the requests if it is.

meisnate12 commented 2 years ago

the site looks great but unfortunately, their api is not freely accessable so its not something i have an interest in adding to pmm