Announcement

Collapse
No announcement yet.

Accessing data in songStreamController

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Accessing data in songStreamController

    > [22-12-11 14:54:10.0337] Slim::Player::Protocols::HTTP::getMetadataFor (1005) Metadata provider Plugins::RadioNowPlaying::Plugin:rovider failed: Can't locate object method "redir" via package "Slim::Schema::Track"

    Would you have some more context about what you're trying to do, and how
    you're getting here?

    > I see that "redir" is still defined (I think I am looking in the right
    > place)
    > https://github.com/Logitech/slimserv...teTrack.pm#L36


    "redir" is available for RemoteTrack. But the above error is for a local
    "Track". Local files obviously shouldn't redirect. Maybe you should
    check whether a file isRemote or not before checking the redir
    attribute? But lack of context this is just a wild guess.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

    #2
    Accessing data in songStreamController

    I am trying to resolve an issue that I have had for ages ... where a stream URL changes because of a redirect and then the new stream URL no longer matches a regex that I have in place.
    I have been getting around this by working out a set of regex matches that work for the original and for the one redirected to but have now hit one that this is not feasible to do.

    So - time has come to do it properly and use the original URL.

    I do this because I have to set up a timer to call me back to go out and find metadata for the currently playing song (since it is not in the stream metadata).

    My recollection of the history of this is that if my timer expires but the listener has changed to play something else then I must not overwrite the now playing information with the track info from what is now the previous station being listened to ... so I get the current stream via

    Code:
    my $song = $client->playingSong();
    if ( $song && $song->streamUrl ) { $playingURL = $song->streamUrl}
    However, I dumped out a bunch of stuff and saw ... (edited) ...

    Code:
    'songStreamController' => bless( [
                                                                 bless( [
                                                                          'Slim::Player::Protocols::HTTPS',
                                                                          0,
                                                                          bless( [
                                                                                   -157146472,
                                                                                   1,
                                                                                   undef,
                                                                                   undef,
                                                                                   'h t t p s ://currentlyplaying.stream/mp3',
                                                                                   'h t t p://originally.launched.stream/mp3',
                                                                                   'mp3',
                                                                                   192000,
                                                                                   0,
                                                                                   undef,
                                                                                   undef,
                                                                                   undef,
                                                                                   undef,
                                                                                   undef,
                                                                                   'station name',
    So my question ... what is the correct way to get those 2 URLs from songStreamController ?
    Is the first one the same as
    $song->streamUrl

    I tried to find where the blessed object is defined but without luck so far.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

    Comment


      #3
      Originally posted by Paul Webster View Post
      I am trying to resolve an issue that I have had for ages ... where a stream URL changes because of a redirect and then the new stream URL no longer matches a regex that I have in place.
      I have been getting around this by working out a set of regex matches that work for the original and for the one redirected to but have now hit one that this is not feasible to do.

      So - time has come to do it properly and use the original URL.

      I do this because I have to set up a timer to call me back to go out and find metadata for the currently playing song (since it is not in the stream metadata).

      My recollection of the history of this is that if my timer expires but the listener has changed to play something else then I must not overwrite the now playing information with the track info from what is now the previous station being listened to ... so I get the current stream via

      Code:
      my $song = $client->playingSong();
      if ( $song && $song->streamUrl ) { $playingURL = $song->streamUrl}
      However, I dumped out a bunch of stuff and saw ... (edited) ...

      Code:
      'songStreamController' => bless( [
                                                                   bless( [
                                                                            'Slim::Player::Protocols::HTTPS',
                                                                            0,
                                                                            bless( [
                                                                                     -157146472,
                                                                                     1,
                                                                                     undef,
                                                                                     undef,
                                                                                     'h t t p s ://currentlyplaying.stream/mp3',
                                                                                     'h t t p://originally.launched.stream/mp3',
                                                                                     'mp3',
                                                                                     192000,
                                                                                     0,
                                                                                     undef,
                                                                                     undef,
                                                                                     undef,
                                                                                     undef,
                                                                                     undef,
                                                                                     'station name',
      So my question ... what is the correct way to get those 2 URLs from songStreamController ?
      Is the first one the same as
      $song->streamUrl

      I tried to find where the blessed object is defined but without luck so far.
      This might be correct, it certainly is with protocol handlers when I handle the redirect myself :

      original URL is : $song->track()->url
      actual URL is : $song->streamUrl
      Last edited by expectingtofly; 2022-05-17, 14:01. Reason: Got them the wrong way around!
      Stuart McLean

      ExpectingToFly Plugins :
      BBC Sounds, Global Player (UK), Times Radio, UK Radio Player, Virgin Radio (UK) and the Radio Favourites Plugin

      For BBC Sounds help see the BBC Sounds Wiki.

      Comment


        #4
        Just tried examining $song->track()->url ... and it is the redirected to URL in my case.

        Perhaps because I do not have my own protocol handler in this case (and don't really want one in this plugin - at least while I can avoid it) ... so maybe http/https protocol handler has already handled it and updated $song->track()->url to point to the accepted redirection.

        I /think/ that Slim/Schema/RemoteTrack.pm is where the blessed structure is defined ... and if it is then attribute "redir" might be the one I need ... which would be somewhat unintuitive if correct (it comes after _url and before content_type and bitrate ... which seems to match the array dump).

        I see that there is a "get" routine in there so maybe I need to call it with "redir" ... next step is to work out how to do that.

        Edit:
        Aha ... from developers.txt
        That $song contains a $track object that is created from the original $url set when OPML item is
        added in the playlist. When scanning $url, the Slim::Utils::Scanner::Remote::scanURL creates a new
        $track object everytime the uri returned by the GET is different from the $url argument. This
        happens on HTTP redirection and if the $url argument differs from $args->{'song'}->track->url. The
        original url is stored as $track->redir (note that it might be empty).
        Last edited by Paul Webster; 2022-05-17, 15:12.
        Paul Webster
        Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
        and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

        Comment


          #5
          Looking promising ...
          $song->track()->redir does seem to hold the original URL.
          Paul Webster
          Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
          and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

          Comment


            #6
            Originally posted by Paul Webster View Post
            Looking promising ...
            $song->track()->redir does seem to hold the original URL.

            This was working well since I started using it 6 months ago ... however, I am now seeing in the log (LMS 8.4)
            Code:
            [22-12-11 14:54:10.0337] Slim::Player::Protocols::HTTP::getMetadataFor (1005) Metadata provider Plugins::RadioNowPlaying::Plugin::provider failed: Can't locate object method "redir" via package "Slim::Schema::Track"
            when my plugin code does a test on it.

            I see that "redir" is still defined (I think I am looking in the right place)
            Paul Webster
            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

            Comment


              #7
              This was in RNP so playing an internet radio stream.

              I'll try again on next LMS restart (later today) to see if still happening.
              Paul Webster
              Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
              and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

              Comment


                #8
                Just realised what caused it.
                It happens on the transition from playing something with RNP to playing local music.
                My timer expires and checks to see if the radio is still playing by trying to match the stream URL, including the redir URL ... which, of course, will fail when local music is being played.

                I'll modify it to first check that it is a stream that is playing.
                Paul Webster
                Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                Comment

                Working...
                X