derat / yambs

Moved to codeberg.org/derat/yambs
https://codeberg.org/derat/yambs
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Add Tidal support #17

Closed derat closed 1 year ago

derat commented 1 year ago

Per this thread, it sounds like there's no easy way to seed releases from Tidal right now. Tidal provides a JSON API with endpoints for looking up albums and tracklists, so I'm adding support.

derat commented 1 year ago

Hmm. I thought this was pretty much ready to go, but I'm running into what seems to be annoying geographic restrictions in the API for some albums.

https://tidal.com/browse/album/132439428 shows 10 tracks.

https://api.tidal.com/v1/albums/132439428?countryCode=US (with X-Tidal-Token) also says there are 10 tracks:

{
  "id": 132439428,
  "title": "Outland",
  "duration": 2609,
  "streamReady": true,
  "streamStartDate": "2020-03-05T00:00:00.000+0000",
  "allowStreaming": true,
  "premiumStreamingOnly": false,
  "numberOfTracks": 10,
  "numberOfVideos": 0,
  "numberOfVolumes": 1,
  "releaseDate": "2020-05-01",
  "copyright": "Planet Mu Records Ltd.",
  "type": "ALBUM",
  "version": null,
  "url": "http://www.tidal.com/album/132439428",
  "cover": "b6741a3d-183c-469c-847b-3cfefd9823d4",
  "vibrantColor": "#FFFFFF",
  "videoCover": null,
  "explicit": false,
  "upc": "5055300399700",
  "popularity": 4,
  "audioQuality": "LOSSLESS",
  "audioModes": ["STEREO"],
  "artist": {
    "id": 4134860,
    "name": "Ital Tek",
    "type": "MAIN",
    "picture": "efe4665c-fc83-4b9c-875e-39f66a91a02d"
  },
  "artists": [
    {
      "id": 4134860,
      "name": "Ital Tek",
      "type": "MAIN",
      "picture": "efe4665c-fc83-4b9c-875e-39f66a91a02d"
    }
  ]
}

https://api.tidal.com/v1/albums/132439428/tracks?countryCode=US returns zero tracks, though:

{ "limit": 0, "offset": 0, "totalNumberOfItems": 0, "items": [] }

I do get the track information when I request https://api.tidal.com/v1/albums/132439428/tracks?countryCode=DE, though.

It's frustrating that the /tracks endpoint returns different information depending on the country code, and I'm not sure how to tell which countries an album is available in. I guess I can let the user specify the country code. :-/

derat commented 1 year ago

Basic support is in now. I'm sure there's still a lot of room for improvement.

Compilation albums can be pretty slow since I'm querying MusicBrainz to try to find MBIDs for artist credits, and I'm currently looking for both https://tidal.com/artist/<id> and https://stream.tidal.com/artist/<id> since both seem to be used (MB should probably normalize these URLs...).

It'd be nice to automatically choose a suitable country code, but I haven't found a way to do this yet. Other people seem to have this problem too; see e.g. https://www.reddit.com/r/TIdaL/comments/zm3gf5/in_which_country_is_this_album_available/.

cherryblossom000 commented 1 year ago

Wow, that was fast! I think a-tisket finds the countries Apple Music releases are available in by trying every country and seeing if that works (but obviously this takes time so this can be disabled). Maybe something similar could be done for Tidal. There doesn’t seem to be an official list of what countries Tidal is available in but I did find this:

Andorra Argentina Australia Austria Belgium Brazil Canada Chile Colombia Cyprus Czech Republic Denmark Dominican Republic Estland Finland France Germany Greece Hong Kong Hungary Iceland Ireland Israel Italy Jamaica Latvia Liechtenstein Lithuania Luxemburg Malaysia Malta Mexico Monaco Netherlands New Zealand Norway Peru Poland Portugal Puerto Rico Romania Singapore Slovakia Slovenia South Africa Spain Sweden Switzerland Thailand Turkey Uganda UK USA

derat commented 1 year ago

Thanks for the suggestion! I've opened #18 to track multi-country lookups.