Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 6 123 ... LastLast
Results 1 to 10 of 59
  1. #1
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,962

    scanUrl not being called

    In a plugin, I am trying to replace the display of a stream URL with a local protocol handler version.
    I have seen that @expectingtofly VirginRadio plugin does this.

    e.g.
    myplugin:StationA
    translated by my explodePlaylist to
    h t t p: // radiostation.com/stream.mp3

    but I want LMS / players to show the URL as
    myplugin:StationA
    not
    h t t p: // radiostation.com/stream.mp3

    I think that scanUrl is the place to do this.

    My explodePlaylist is being called but my scanUrl is not.

    I have a
    use base qw(Slim::Player::Protocols::HTTPS);

    I also have:
    sub isAudio { 1 }
    sub isRemote { 1 }
    sub canDirectStream { 0 }


    Any ideas why my scanUrl is not being called then the stream is set to start?
    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. #2
    Senior Member
    Join Date
    Aug 2014
    Location
    UK
    Posts
    561
    Quote Originally Posted by Paul Webster View Post
    In a plugin, I am trying to replace the display of a stream URL with a local protocol handler version.
    I have seen that @expectingtofly VirginRadio plugin does this.

    e.g.
    myplugin:StationA
    translated by my explodePlaylist to
    h t t p: // radiostation.com/stream.mp3

    but I want LMS / players to show the URL as
    myplugin:StationA
    not
    h t t p: // radiostation.com/stream.mp3


    Any ideas why my scanUrl is not being called then the stream is set to start?
    I don't think my virgin radio plugin uses the explodeplaylist??
    In fact virginradio protocol handler is probably a good example as it uses scan url : https://github.com/expectingtofly/LM...andler.pm#L638

    I can't remember that exact order of doing things, I did make a note of it somewhere. But getNextTrack is where you work out the real stream url. So you can probably follow it through on the virgin radio or times radio plugins. (I think I had to do some jiggery pokery in the scanUrl override to make sure it used the real stream url.)

    Meanwhile, I'll try and find my notes.....

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,871
    I had problem with scanning with PlayHLS and I know I had to add an importer (either addImporter or in install.xml) for some reason.

    edit:
    Importer is not what you need - To replace the displayed URL - expectingtofly is on the right idea - similar what TRiode did in BBCiPlayer when it hid "iplayer://"
    Last edited by bpa; 2021-05-18 at 04:29.

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,629

    scanUrl not being called

    > I had problem with scanning with PlayHLS and I know I had to add an
    > importer (either addImporter or in install.xml) for some reason.

    I'm very much confused by this... And you mention this for the second
    time this week... scanUrl in the protocol handler has been around for
    years before the importer feature was implemented. I don't really know
    what they would have to do with each other. In particular would
    addImporter have nothing to do with a radio station? It's used to import
    tracks into your library.

    --

  5. #5
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,629

    scanUrl not being called

    > In a plugin, I am trying to replace the display of a stream URL with a
    > local protocol handler version.


    What do you mean by "the display of a stream URL"? A protocol handler
    (PH) would deal with a URL of a specific protocol. Eg. your protocol
    would be "myplugin". So myplugin:someStation would be handled by your
    PH. A PH is not there to customize behaviour of http://mystation/stream,
    but to "mask" it. Eg. radioparadise://1.flac would be the Mellow
    station. Only once the PH is called to getNextTrack() it would return
    the real http URL. But in LMS you'd almost always see
    radioparadise://1.flac, and not the http URL.

    I probably don't understand what you're trying to do.

  6. #6
    Senior Member
    Join Date
    Aug 2014
    Location
    UK
    Posts
    561
    Quote Originally Posted by mherger View Post
    > In a plugin, I am trying to replace the display of a stream URL with a
    > local protocol handler version.


    What do you mean by "the display of a stream URL"? A protocol handler
    (PH) would deal with a URL of a specific protocol. Eg. your protocol
    would be "myplugin". So myplugin:someStation would be handled by your
    PH. A PH is not there to customize behaviour of http://mystation/stream,
    but to "mask" it. Eg. radioparadise://1.flac would be the Mellow
    station. Only once the PH is called to getNextTrack() it would return
    the real http URL. But in LMS you'd almost always see
    radioparadise://1.flac, and not the http URL.

    I probably don't understand what you're trying to do.
    I think paul added an "explodeplaylist" to treate the customized url as a playlist, which would convert it to the real https:// playlist item. That means that the real https would then be used and his protocol handler would not be used from that point onwards.
    As you say, he needs to remove that explodeplaylist and use getNextTrack to resolve the real url (he should be able to follow my example in the virgin radio plugin).

  7. #7
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,871
    Quote Originally Posted by mherger View Post
    > I had problem with scanning with PlayHLS and I know I had to add an
    > importer (either addImporter or in install.xml) for some reason.

    I'm very much confused by this... And you mention this for the second
    time this week... scanUrl in the protocol handler has been around for
    years before the importer feature was implemented. I don't really know
    what they would have to do with each other. In particular would
    addImporter have nothing to do with a radio station? It's used to import
    tracks into your library.

    --
    Ignore me, I got into my head Paul was trying to hide multiple formats under one. I was too lazy to look at the code as why importer was needed.

    PlayHLS is an oddity - the suffix m3u8 playlist &MIME is ambiguous, the content needs ot be examined before determining whether the playlist can either be m3u playlist or HLS ones. So PlayHLS had to do a scan of m3u8 playlist and decide whether they are to be handled by LMS or PlayHLS. There may be a better solution but part of the problem was learning how the real world has implemented HLS and where the rules have not been followed.

  8. #8
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,962
    ok - will try with getNextTrack.

    I think I went with explodePlaylist initially because I saw it being used in BBCSounds plugin when converting sounds:// protocol for live streams.
    It worked (in that I provided the real URL back to LMS and it played) but I did not want the real URL to appear in UI or on devices so was then hunting for a way to hide it again.
    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

  9. #9
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,629

    scanUrl not being called

    > I think I went with explodePlaylist initially because I saw it being
    > used in BBCSounds plugin when converting sounds:// protocol for live
    > streams.
    > It worked (in that I provided the real URL back to LMS and it played)
    > but I did not want the real URL to appear in UI or on devices so was
    > then hunting for a way to hide it again.


    When you explode a list into its tracks, you can create your own URLs
    again, which then would be "translated" into real URLs in getNextTrack().

  10. #10
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,962
    Still having problems after removing explodePlaylist and having a getNextTrack
    My code that takes the given protocol:// string to find the real stream URL is working - and returning the right value.

    getNextTrack is called by LMS soon after scanUrl returns.
    The code looks (to me) to be essentially the same as in Slim::Plugin::RemoteLibrary::ProtocolHandler

    Code:
    sub getNextTrack {
    	my ( $class, $song, $successCb, $errorCb ) = @_;
    	my $masterUrl = $song->track()->url;
    	main::INFOLOG && $log->is_info && $log->info("getNextTrack " . $masterUrl);
    
    	if ( $masterUrl =~ /^$thisProtocol:/ ) {
    
    		my ($scheme, $auth, $path, $query, $frag) = uri_split($masterUrl);
    		
    		my $streamUrl;
    		
    		if ( $auth ){
    			$streamUrl = Plugins::myplugin::Plugin::_matchId( $auth );
    		}
    
    		main::DEBUGLOG && $log->is_debug && $log->debug("Setting Live Stream $streamUrl");
    		
    		$song->streamUrl($streamUrl);
    		#$song->track->bitrate(128_000);
    
    		$successCb->();
    	}
    
    }
    Edited log
    Code:
    [21-05-18 15:37:49.6711] Plugins::myplugin::ProtocolHandler::scanUrl (70) scanurl myplugin://test
    [21-05-18 15:37:49.6719] Plugins::myplugin::Plugin::_matchId (5586) _matchId: test exists
    [21-05-18 15:37:49.6725] Plugins::myplugin::ProtocolHandler::scanUrl (83) scanurl myplugin://test actual stream https://somewhere.com/stream.aac
    [21-05-18 15:37:52.4808] Plugins::myplugin::ProtocolHandler::getNextTrack (97) getNextTrack myplugin://test
    [21-05-18 15:37:52.4821] Plugins::myplugin::Plugin::_matchId (5586) _matchId: test exists
    [21-05-18 15:37:52.4832] Plugins::myplugin::ProtocolHandler::getNextTrack (109) Setting Live Stream https://somewhere.com/stream.aac
    [21-05-18 15:37:52.4874] Slim::Player::Song::open (415) Error: Couldn't create command line for unk playback for [myplugin://test]
    If I play the same final stream url in LMS then it works fine.
    It looks to me like the line
    Code:
    $song->streamUrl($streamUrl);
    did not change the song data so LMS tried to create a command line to handle myplugin: which failed.

    Sorry for the trouble.
    I don't want to share the exact stream URL in public for reasons that I am happy to explain via PM or email.
    I can share the current code if an expert is willing to take a look offline.
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •