AutoNotification Get album art from Spotify

Discussion in 'AutoApps' started by Rich Wallace, Jun 18, 2016.

  1. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    I have a task that is queuing a spotify notification to get track name and album.
    This works great.
    As does the grabbing of the actions.
    But I'm finding that getting the album cover is very unreliable.
    Very often i get nothing returned.
    And if I do get the cover art. If the track is paused and restarted it can't be retrieved a second time
    Has anyone else experienced this?
    Has anyone successfully and reliably managed to get the album cover?

    FYI it's to use in a scene
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    How exactly are you retrieving the art? thanks
     
  3. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    This is the task description (the scene Jjj is just a test scene with an image element to prove off what I am trying to do.
    Had the same problem again over weekend this morning.
    For some tracks it works, others it returns nothing or file:///null
    And when I do get it to work, if I pause the track and set the image to nothing, it doesn't work when I restart.
    My eventual final task is to have a profile triggered by Spotify intent receive for playback state changed and / or meta data changed.
    Code (Text):
    Music (97) A1: AutoNotification Query [ Configuration:persistency Type: Persistent Only
    Notification Apps: Spotify
    Has Reply Action: false
    Get All Fields : true
    Image Names : image
    Big Image Names : big
    Internal Actions Big: -1 Timeout (Seconds):20 ]
    A2: Flash [ Text:%antitle1
    %image
    %big Long:Off ]
    A3: Destroy Scene [ Name:Jjj ]
    A4: Create Scene [ Name:Jjj ]
    A5: Element Image [ Scene Name:Jjj Element:Image1 Image:%image ]
    A6: Show Scene [ Name:Jjj Display As:Activity, Full Window Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Continue Task Immediately:On ]
     
    mtneerndixie likes this.
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Maybe when the first notification is posted by Spotify it doesn't have an album art cause it retrieves it after the notification has been posted?
    Can you try to do an AutoNotification query after 1 second inside the task and check if you correctly get the icon then? thanks!
     
  5. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    So I tried this and did some experimenting and here is what I come up with:
    There seem to be 2 intents being used with Spotify
    Code (Text):
    com.spotify.music.playbackstatechanged
    and
    Code (Text):
    com.spotify.music.metadatachanged
    Obviously the metadatachanged intent is fired each time there is new meta data...this includes the first time play is pressed per 'listening session' and each time a track is changed.
    If track is paused only playbackstatechanged is sent.
    If track is restarted only playbackstatechanged is sent.
    When the track is skipped during playback, both intents are sent...1st playbackstated changed and then metadatachanged.
    So from this its clear that when a track is skipped, it is actually paused and then skipped.
    BUT....
    This doesn't seem to be the reason that my task to get the album art is failing.
    Having added a wait action in before the query action I still see the same behaviour / results. I started with a 0.5sec wait and increased to 3 seconds and still couldn't get reliable results.
    Skip track and album art is retrieved and will display in a scene.
    Pause the track and art is cleared.
    Restart the same track and album art cannot be retrieved and query returns file:///null.
    Skip a track and next track album art is found OK and displayed in scene.

    I am now thinking this is not truly a problem with my task or AutoNotification, but the way in which Spotify is creating notifications.
    If anyone can spot anything that might help or where I should be looking thatd be great
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Hmm, maybe sometimes there's more than 1 image in the spotify notification? :) Maybe try to look in %animages() and see if by any chance 2 or more images come up when the task fails...
     
  7. Rich Wallace

    Rich Wallace Member

    Joined:
    Apr 10, 2015
    Messages:
    42
    Likes Received:
    1
    Yeah, I also tried this and there is nothing.
    It seems to me that when the meta data changes a new image is created. But when playback state stops, image is cleare, then when playback is restarted the image is not re-created.
    Its a strange one.
    And im now pretty sure its down to how Spotify is handling the notification and playback states.

    Ill do some more tests and see if I can figure it out.
     

Share This Page