Skip to content

Commit

Permalink
Merge pull request #11 from mavit/rich-url-handler
Browse files Browse the repository at this point in the history
Handle MixCloud URLs passed to “Tune In URL”
  • Loading branch information
danielvijge authored Jul 31, 2020
2 parents c3602be + 581310b commit 2208da6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ProtocolHandler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ use Slim::Utils::Cache;
use Data::Dumper;
use Scalar::Util qw(blessed);

my $log = logger('plugin.mixcloud');
use constant PAGE_URL_REGEXP => qr{^https?://(?:www|m)\.mixcloud\.com/};

my $log = logger('plugin.mixcloud');

use strict;
Slim::Player::ProtocolHandlers->registerHandler('mixcloud', __PACKAGE__);
Slim::Player::ProtocolHandlers->registerHandler('mixcloudd' => 'Plugins::MixCloud::ProtocolHandlerDirect');
Slim::Player::ProtocolHandlers->registerURLHandler(PAGE_URL_REGEXP, __PACKAGE__)
if Slim::Player::ProtocolHandlers->can('registerURLHandler');
my $prefs = preferences('plugin.mixcloud');
$prefs->init({ apiKey => "", playformat => "mp4"});

Expand Down Expand Up @@ -416,4 +419,19 @@ sub getSeekDataByPosition {
return {%$seekdata, restartOffset => $bytesReceived};
}

sub explodePlaylist {
my ( $class, $client, $uri, $callback ) = @_;

if ( $uri =~ PAGE_URL_REGEXP ) {
Plugins::MixCloud::Plugin::urlHandler(
$client,
sub { $callback->([map {$_->{'play'}} @{$_[0]->{'items'}}]) },
{'search' => $uri},
);
}
else {
$callback->([]);
}
}

1;

0 comments on commit 2208da6

Please sign in to comment.