python-tidal icon indicating copy to clipboard operation
python-tidal copied to clipboard

Ability to retrieve created attribute from favorite tracks list

Open clrxbl opened this issue 4 years ago • 2 comments

It appears that the API is retrieving the "item" object inside of the "items" array. The problem with this is that I'm trying to retrieve the "date added" attribute of a favorite track and I'm seemingly unable to do so with the 0.7.x library. I did take a look at the code and see if I could add this feature myself but I'm not exactly sure how to do this.

Example JSON data of the users//favorites/tracks output, showing the "created" key:

{
   "limit":10,
   "offset":0,
   "totalNumberOfItems":331,
   "items":[
      {
         "created":"2019-12-27T14:30:29.824+0000",
         "item":{
            "id":102655820,
            "title":"100 Bad Days",
            "duration":213,
            "replayGain":-9.34,
            "peak":0.994263,
            "allowStreaming":true,
            "streamReady":true,
            "streamStartDate":"2019-01-30T00:00:00.000+0000",
            "premiumStreamingOnly":false,
            "trackNumber":1,
            "volumeNumber":1,
            "version":null,
            "popularity":11,
            "copyright":"(P) 2019 AJR Productions under exclusive license to Black Butter Limited",
            "url":"http://www.tidal.com/track/102655820",
            "isrc":"QMRSZ1900001",
            "editable":false,
            "explicit":false,
            "audioQuality":"LOSSLESS",
            "audioModes":[
               "STEREO"
            ],
            "artist":{
               "id":5073699,
               "name":"AJR",
               "type":"MAIN"
            },
            "artists":[
               {
                  "id":5073699,
                  "name":"AJR",
                  "type":"MAIN"
               }
            ],
            "album":{
               "id":102655819,
               "title":"100 Bad Days",
               "cover":"dec5bf9c-5573-4db5-9944-aa72051af368",
               "videoCover":null
            },
            "mixes":{
               "MASTER_TRACK_MIX":"014830637ccb8da5ffab01af5d3ce5",
               "TRACK_MIX":"001995746cb8ee26395ebd5bb3b78e"
            }
         }
      },

clrxbl avatar Dec 15 '20 00:12 clrxbl

Tracks in a playlist have a 'dateAdded' key inside the 'item' dict, i think i will do it that way for favorites too, by moving the created key into the 'item' dict. This makes the functions continue to return a list containing the favorited items.

Does this sound good? It would look roughly like this, with the date being a datetime object as usual

favorite_tracks = session.user.favorites.tracks()
print(favorite_tracks[0].user_date_added)

morguldir avatar Jan 03 '21 23:01 morguldir

Seems fine to me

clrxbl avatar Jan 03 '21 23:01 clrxbl