Skip to content

Commit

Permalink
Remove traces of mp3tunes, SiriusXM, Orange, and others
Browse files Browse the repository at this point in the history
  • Loading branch information
mherger committed Apr 6, 2022
1 parent 1d0807e commit c06d6c2
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 138 deletions.
10 changes: 5 additions & 5 deletions HTML/EN/html/docs/cli-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -8838,7 +8838,7 @@ <h3 id="PG">
<strong><code><a href="#fulltextsearch">fulltextsearch</a></code></strong>
</li>
<li>
<strong><a href="#XMLBrowser">Live Music Archive, MP3tunes, Pandora, Podcasts, RadioTime, Napster, Shoutcast, Staff Picks, RSS</a></strong>
<strong><a href="#XMLBrowser">Live Music Archive, Pandora, Podcasts, RadioTime, Napster, Shoutcast, Staff Picks, RSS</a></strong>
</li>
<li>
<strong><a href="#Favorites">Favorites</a></strong>
Expand Down Expand Up @@ -8923,7 +8923,7 @@ <h3 id="PG">
&nbsp;&nbsp;<b>cmd</b>
</td>
<td>
Command, one of &quot;lma&quot;, &quot;mp3tunes&quot;,
Command, one of &quot;lma&quot;,
&quot;pandora&quot;, &quot;podcast&quot;,
&quot;radiotime&quot;, &quot;rhapsodydirect&quot;, &quot;shoutcast&quot;, &quot;
or &quot;picks&quot;, or any other, additionally installed radio or music service
Expand Down Expand Up @@ -9008,13 +9008,13 @@ <h3 id="PG">

<br>
<h3 id="XMLBrowser">
Live Music Archive, MP3tunes, Pandora, Podcasts, RadioTime, Napster, Shoutcast, Staff Picks, RSS
Live Music Archive, Pandora, Podcasts, RadioTime, Napster, Shoutcast, Staff Picks, RSS
</h3>
<p>
<strong>
<code>
&lt;playerid&gt;
&lt;lma|mp3tunes|pandora|podcast|radiotime|rhapsodydirect|shoutcast|picks|rss&gt;
&lt;lma|pandora|podcast|radiotime|rhapsodydirect|shoutcast|picks|rss&gt;
items
&lt;start&gt;
&lt;itemsPerResponse&gt;
Expand Down Expand Up @@ -9216,7 +9216,7 @@ <h3 id="XMLBrowser">
<strong>
<code>
&lt;playerid&gt;
&lt;lma|mp3tunes|pandora|podcast|radiotime|rhapsodydirect|shoutcast|picks|rss&gt;
&lt;lma|pandora|podcast|radiotime|rhapsodydirect|shoutcast|picks|rss&gt;
playlist
&lt;play|load|insert|add&gt;
&lt;taggedParameters&gt;
Expand Down
1 change: 0 additions & 1 deletion Slim/Control/XMLBrowser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,6 @@ sub _cliQuery_done {
# make a best effort to make a labeled title for the search
my $queryTypes = {
rhapsodydirect => 'PLUGIN_RHAPSODY_DIRECT_MODULE_NAME',
mp3tunes => 'PLUGIN_MP3TUNES_MODULE_NAME',
radiotime => 'PLUGIN_RADIOTIME_MODULE_NAME',
slacker => 'PLUGIN_SLACKER_MODULE_NAME',
lma => 'PLUGIN_LMA_MODULE_NAME',
Expand Down
72 changes: 30 additions & 42 deletions Slim/Player/Protocols/HTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sub new {

${*$self}{'client'} = $args->{'client'};
${*$self}{'url'} = $args->{'url'};
${*$self}{'_class'} = $class;
${*$self}{'_class'} = $class;

return $self;
}
Expand All @@ -79,14 +79,14 @@ sub close {
} elsif ($enhanced->{'status'} && $enhanced->{'status'} > IDLE) {
# disconnect persistent session (if any)
$enhanced->{'session'}->disconnect;
}
}
}

sub response {
my $self = shift;
my ($args, $request, @headers) = @_;

# HTTP headers have now been acquired in a blocking way
# HTTP headers have now been acquired in a blocking way
my $enhance = $self->canEnhanceHTTP($args->{'client'}, $args->{'url'});
return unless $enhance;

Expand All @@ -99,11 +99,11 @@ sub response {
if ($uri !~ /^https?/) {
my ($proto, $host, $port) = $args->{'url'} =~ m|(.+)://(?:[^\@]*\@)?([^:/]+):*(\d*)|;
$request_object->uri("$proto://$host" . ($port ? ":$port" : '') . $uri);
}
}

my ($first) = $self->contentRange =~ /(\d+)-/;
my $length = $self->contentLength;

${*$self}{'_enhanced'} = {
'session' => Slim::Networking::Async::HTTP->new,
'request' => $request_object,
Expand All @@ -116,7 +116,7 @@ sub response {
};

main::INFOLOG && $log->is_info && $log->info("Using Persistent service for $args->{'url'}");
} else {
} else {
# enable fast download of body to a file from which we'll read further data
# but the switch of socket handler can only be done within _sysread otherwise
# we will timeout when there is a pipeline with a callback
Expand Down Expand Up @@ -159,7 +159,7 @@ sub request {
if ($formatClass->can('getInitialAudioBlock')) {
$song->initialAudioBlock($formatClass->getInitialAudioBlock($fh, $track, $seekdata->{timeOffset} || 0));
}

$song->initialAudioBlock('') unless defined $song->initialAudioBlock;

$fh->close if $fh;
Expand All @@ -178,7 +178,7 @@ sub request {
${*$self}{'initialAudioBlockRef'} = $blockRef;
${*$self}{'initialAudioBlockRemaining'} = length $$blockRef;

# dynamic headers need to be re-calculated every time
# dynamic headers need to be re-calculated every time
$song->initialAudioBlock(undef) if $processor->{'initial_block_type'};

main::DEBUGLOG && $log->debug("streaming $args->{url} with header of ", length $$blockRef, " from ",
Expand All @@ -197,14 +197,14 @@ sub readMetaData {
my $metadataSize = 0;
my $byteRead = 0;

# some streaming servers might align their chunks on metadata which means that
# some streaming servers might align their chunks on metadata which means that
# we might wait a long while for the 1st byte. We don't want about busy loop, so
# exit if we don't have one. But once we have it, rest shall follow shortly

if (!readChunk($self, $metadataSize, 1)) {
$log->debug("Metadata byte not read, trying again: $!");
return undef;
}
}

$metadataSize = ord($metadataSize) * 16;

Expand Down Expand Up @@ -391,11 +391,11 @@ sub parseMetadata {

sub canEnhanceHTTP {
return $prefs->get('useEnhancedHTTP');
}
}

sub canDirectStream {
my ($class, $client, $url, $inType) = @_;

# when persistent is used, we won't direct stream to enable retries
return 0 if $class->canEnhanceHTTP($client, $url);

Expand Down Expand Up @@ -455,28 +455,28 @@ sub readChunk {
}

sub readPersistentChunk {
my $enhanced = shift;
my $enhanced = shift;
my $self = $_[0];

# read directly from socket if primary connection is still active
if ($enhanced->{'status'} == IDLE) {
my $readLength = $self->_sysread($_[1], $_[2], $_[3]);
$enhanced->{'first'} += $readLength;

# return sysread's result UNLESS we reach eof before expected length
return $readLength unless defined($readLength) && !$readLength && $enhanced->{'first'} != $self->contentLength;
}
}

# all received using persistent connection
return 0 if $enhanced->{'status'} == DISCONNECTED;

# if we are not streaming, need to (re)start a session
if ( $enhanced->{'status'} <= READY ) {
my $request = $enhanced->{'request'};
my $request = $enhanced->{'request'};
my $last = $enhanced->{'length'} - 1 if $enhanced->{'length'};

$request->header( 'Range', "bytes=$enhanced->{'first'}-$last");
$enhanced->{'status'} = CONNECTING;
$enhanced->{'status'} = CONNECTING;
$enhanced->{'lastSeen'} = undef;

$log->warn("Persistent streaming from $enhanced->{'first'} for ${*$self}{'url'}");
Expand All @@ -502,15 +502,15 @@ sub readPersistentChunk {
# the child socket is non-blocking so we can safely call read_entity_body which calls sysread
# if buffer is empty. This is normally a callback used when select() indicates pending bytes
my $bytes = $enhanced->{'session'}->socket->read_entity_body($_[1], $_[2]) if $enhanced->{'status'} == CONNECTED;

# note that we use EINTR with empty buffer because EWOULDBLOCK allows Source::_readNextChunk
# to do an addRead on $self and would not work as primary socket is closed
if ( $bytes && $bytes != -1 ) {
$enhanced->{'first'} += $bytes;
$enhanced->{'lastSeen'} = time();
return $bytes;
} elsif ( $bytes == -1 || (!defined $bytes && $enhanced->{'errors'} < $enhanced->{'max'} &&
($enhanced->{'status'} != CONNECTED || $! == EINTR || $! == EWOULDBLOCK) &&
} elsif ( $bytes == -1 || (!defined $bytes && $enhanced->{'errors'} < $enhanced->{'max'} &&
($enhanced->{'status'} != CONNECTED || $! == EINTR || $! == EWOULDBLOCK) &&
(!defined $enhanced->{'lastSeen'} || time() - $enhanced->{'lastSeen'} < 5)) ) {
$! = EINTR;
main::DEBUGLOG && $log->is_debug && $log->debug("need to wait for ${*$self}{'url'}");
Expand All @@ -521,7 +521,7 @@ sub readPersistentChunk {
main::INFOLOG && $log->is_info && $log->info("end of ${*$self}{'url'} s:", time() - $enhanced->{'lastSeen'}, " e:$enhanced->{'errors'}");
return 0;
} else {
$log->warn("unexpected connection close at $enhanced->{'first'}/$enhanced->{'length'} for ${*$self}{'url'}\n\tsince:",
$log->warn("unexpected connection close at $enhanced->{'first'}/$enhanced->{'length'} for ${*$self}{'url'}\n\tsince:",
time() - $enhanced->{'lastSeen'}, "\n\terror:", ($! != EINTR && $! != EWOULDBLOCK) ? $! : "N/A");
$enhanced->{'session'}->disconnect;
$enhanced->{'status'} = READY;
Expand All @@ -532,7 +532,7 @@ sub readPersistentChunk {
}

sub readBufferedChunk {
my $enhanced = shift;
my $enhanced = shift;
my $self = $_[0];

# first, try to read from buffer file
Expand Down Expand Up @@ -615,23 +615,23 @@ sub sysread {
my $metaInterval = ${*$self}{'metaInterval'};
my $metaPointer = ${*$self}{'metaPointer'};

# handle instream metadata for shoutcast/icecast
# handle instream metadata for shoutcast/icecast
if ($metaInterval) {

if ($metaPointer == $metaInterval) {
# don't do anything if we can't read yet
$self->readMetaData() || return undef;
$metaPointer = ${*$self}{'metaPointer'} = 0;

$metaPointer = ${*$self}{'metaPointer'} = 0;
}
elsif ($metaPointer > $metaInterval) {
main::DEBUGLOG && $log->debug("The shoutcast metadata overshot the interval.");
}

if ($metaPointer + $chunkSize > $metaInterval) {
$chunkSize = $metaInterval - $metaPointer;
$chunkSize = $metaInterval - $metaPointer;
#$log->debug("Reduced chunksize to $chunkSize for metadata");
}
}
}

my $readLength;
Expand Down Expand Up @@ -723,12 +723,6 @@ sub parseDirectHeaders {
$startOffset = $1;
$rangeLength = $2;
}

# mp3tunes metadata, this is a bit of hack but creating
# an mp3tunes protocol handler is overkill
elsif ( $url =~ /mp3tunes\.com/ && $header =~ /^X-Locker-Info:\s*(.+)/i ) {
Slim::Plugin::MP3tunes::Plugin->setLockerInfo( $client, $url, $1 );
}
}

# Content-Range: has predecence over Content-Length:
Expand Down Expand Up @@ -799,7 +793,7 @@ sub parseHeaders {

# we should not parse anything before we have reached target
return if ${*$self}{'redirect'} = $redir;

if ($contentType) {
if (($contentType =~ /text/i) && !($contentType =~ /text\/xml/i)) {
# webservers often lie about playlists. This will
Expand Down Expand Up @@ -992,15 +986,9 @@ sub scanUrl {
Slim::Utils::Scanner::Remote->scanURL($url, $args);
}

# Allow mp3tunes tracks to be scrobbled
sub audioScrobblerSource {
my ( $class, $client, $url ) = @_;

if ( $url =~ /mp3tunes\.com/ ) {
# Scrobble mp3tunes as 'chosen by user' content
return 'P';
}

# R (radio source)
return 'R';
}
Expand Down
Loading

0 comments on commit c06d6c2

Please sign in to comment.