The feature introduced in version 1.8.0 where you could paste a Bandcamp URL into the "Tune in to URL" box was lost again in version 1.8.5. Here's a patch to restore it:
Code: -------------------- From 6714d94c0001a5128ce739e6e470aca6979ff343 Mon Sep 17 00:00:00 2001 From: Peter Oliver <g...@mavit.org.uk> Date: Mon, 21 Nov 2022 20:53:58 +0000 Subject: [PATCH] Restore "Tune In URL" handling. --- Plugin.pm | 7 +++++++ ProtocolHandler.pm | 23 +---------------------- URLHandler.pm | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 URLHandler.pm diff --git a/Plugin.pm b/Plugin.pm index 84ca0e1..7efe0c5 100644 --- a/Plugin.pm +++ b/Plugin.pm @@ -135,6 +135,13 @@ sub initPlugin { }, ) ); + if (Slim::Player::ProtocolHandlers->can('registerURLHandler')) { + Slim::Player::ProtocolHandlers->registerURLHandler( + Plugins::Bandcamp::URLHandler::PAGE_URL_REGEX, + 'Plugins::Bandcamp::URLHandler' + ); + } + # initialize recent plays: need to add them to the LRU cache ordered by timestamp my $recent_plays = $cache->get('recent_plays'); map { diff --git a/ProtocolHandler.pm b/ProtocolHandler.pm index 89cce95..385859a 100644 --- a/ProtocolHandler.pm +++ b/ProtocolHandler.pm @@ -1,7 +1,7 @@ package Plugins::Bandcamp::ProtocolHandler; use strict; -use base qw(Slim::Player::Protocols::HTTPS); +use base qw(Plugins::Bandcamp::URLHandler); # use Scalar::Util qw(blessed); @@ -9,10 +9,6 @@ package Plugins::Bandcamp::ProtocolHandler; use Plugins::Bandcamp::Plugin; -use constant PAGE_URL_REGEX => qr{^https?://(?:[a-z0-9-]+\.)?bandcamp\.com/}i; - -# Slim::Player::ProtocolHandlers->registerURLHandler(PAGE_URL_REGEX, __PACKAGE__) if Slim::Player::ProtocolHandlers->can('registerURLHandler'); - my $log = logger('plugin.bandcamp'); sub new { @@ -38,23 +34,6 @@ sub new { return $sock; } -sub explodePlaylist { - my ($class, $client, $url, $cb) = @_; - - if ($url =~ m{https?://bandcamp\.com/stream_redirect}) { - return $cb->([$url]); - } - - Plugins::Bandcamp::Plugin::get_item_info_by_url( $client, sub { - $cb->([ map { $_->{'play'} // () } @{$_[0]} ]); - }, {}, { 'url' => $url } ); -} - -sub getMetadataFor { - my ( $class, $client, $url ) = @_; - return Plugins::Bandcamp::Plugin::metadata_provider($client, $url); -} - sub scanUrl { my ($class, $url, $args) = @_; $args->{'cb'}->($args->{'song'}->currentTrack()); diff --git a/URLHandler.pm b/URLHandler.pm new file mode 100644 index 0000000..26ae1a1 --- /dev/null +++ b/URLHandler.pm @@ -0,0 +1,28 @@ +package Plugins::Bandcamp::URLHandler; + +use strict; +use base qw(Slim::Player::Protocols::HTTPS); +use Plugins::Bandcamp::Plugin; + +use constant PAGE_URL_REGEX => qr{^https?://(?:[a-z0-9-]+\.)?bandcamp\.com/}i; + + +sub explodePlaylist { + my ($class, $client, $url, $cb) = @_; + + if ($url =~ m{https?://bandcamp\.com/stream_redirect}) { + return $cb->([$url]); + } + + Plugins::Bandcamp::Plugin::get_item_info_by_url( $client, sub { + $cb->([ map { $_->{'play'} // () } @{$_[0]} ]); + }, {}, { 'url' => $url } ); +} + +sub getMetadataFor { + my ( $class, $client, $url ) = @_; + return Plugins::Bandcamp::Plugin::metadata_provider($client, $url); +} + + +1; -- 2.38.1 -------------------- ------------------------------------------------------------------------ mavit's Profile: http://forums.slimdevices.com/member.php?userid=10203 View this thread: http://forums.slimdevices.com/showthread.php?t=112519 _______________________________________________ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins