StreamFinder
view release on metacpan or search on metacpan
lib/StreamFinder/Tunein.pm view on Meta::CPAN
print "--Stream count=$stream_count=\n";
my @streams = $station->get();
foreach my $s (@streams) {
print "------ stream URL=$s=\n";
}
=head1 DESCRIPTION
StreamFinder::Tunein accepts a valid radio station or podcast ID or URL on
Tunein.com and returns the actual stream URL(s), title, and cover art icon.
The purpose is that one needs one of these URLs in order to have the option to
stream the station in one's own choice of media player software rather than
using their web browser and accepting any / all flash, ads, javascript,
cookies, trackers, web-bugs, and other crapware that can come with that method
of play. The author uses his own custom all-purpose media player called
"fauxdacious" (his custom hacked version of the open-source "audacious"
audio player). "fauxdacious" can incorporate this module to decode and play
Tunein.com streams. One or more streams can be returned for each station.
Depends:
L<URI::Escape>, L<HTML::Entities>, L<LWP::UserAgent>
=head1 SUBROUTINES/METHODS
=over 4
=item B<new>(I<ID>|I<ID/ID>|I<url> [, I<-notrim> [ => 0|1 ]]
[, I<-formats> => "type1,type2?..." | [type1,type2?...] ]
[, I<-secure> [ => 0|1 ]] [, I<-debug> [ => 0|1|2 ]])
Accepts a tunein.com station / podcast ID or URL and creates and returns a new
station object, or I<undef> if the URL is not a valid Tunein station or podcast,
or no streams are found. The URL can be the full URL,
ie. https://tunein.com/radio/B<station-id>,
https://tunein.com/podcasts/B<podcast-id>/?topicId=B<episode-id>,
or just I<station-id> or I<podcast-id>/I<episode-id>. NOTE: For podcasts,
you must also include the I<episode-id>, otherwise, the I<podcast-id> will be
interpreted as a I<station-id> and you'll likely get no streams!
The optional I<-notrim> argument can be either 0 or 1 (I<false> or I<true>).
If 0 (I<false>) then stream URLs are trimmed of excess "ad" parameters
(everything after the first "?" character, ie. "?ads.cust_params=premium" is
removed, including the "?". Otherwise, the stream URLs are returned as-is.
DEFAULT I<-notrim> (if not given) is 0 (I<false>) and URLs are trimmed. If
I<-notrim> is specified without argument, the default is 1 (I<true>). Try
using I<-notrim> if stream will not play without the extra arguments.
The optional I<-formats> argument can be either a comma-separated string or an
array reference ([...]) of stream types to keep (include) and returned in
order specified (type1, type2...). Each "type" can be an extension
(ie. mp3, acc, pls, etc.), or ("any" or "all" to keep all formats).
DEFAULT I<-formats> list is: 'all', meaning that all streams are accepted.
NOTE: I<-formats> only applies to streaming stations and is ignored for podcasts.
The optional I<-secure> argument can be either 0 or 1 (I<false> or I<true>).
If 1 then only secure ("https://") streams will be returned.
DEFAULT I<-secure> is 0 (false) - return all streams (http and https).
WARNING!: As of the latest StreamFinder release, almost ALL Tunein radio
station streams are "insecure" (http)!
Additional options:
I<-log> => "I<logfile>"
Specify path to a log file. If a valid and writable file is specified, A line
will be appended to this file every time one or more streams is successfully
fetched for a url.
DEFAULT I<-none-> (no logging).
I<-logfmt> specifies a format string for lines written to the log file.
DEFAULT "I<[time] [url] - [site]: [title] ([total])>".
The valid field I<[variables]> are: [stream]: The url of the first/best
stream found. [site]: The site name (Tunein). [url]: The url searched
for streams. [time]: Perl timestamp when the line was logged. [title],
[artist], [album], [description], [year], [genre], [total], [albumartist]:
The corresponding field data returned (or "I<-na->", if no value).
=item $station->B<get>()
Returns an array of strings representing all stream URLs found.
=item $station->B<getURL>([I<options>])
Similar to B<get>() except it only returns a single stream representing
the first valid stream found.
Current options are: I<"random">, I<"nopls">, and I<"noplaylists">.
By default, the first ("best"?) stream is returned. If I<"random"> is
specified, then a random one is selected from the list of streams found.
If I<"nopls"> is specified, and the stream to be returned is a ".pls" playlist,
it is first fetched and the first entry (or a random entry if I<"random"> is
specified) is returned. This is needed by Fauxdacious Mediaplayer.
If I<"noplaylists"> is specified, and the stream to be returned is a
"playlist" (either .pls or .m3u? extension), it is first fetched and the first
entry (or a random entry if I<"random"> is specified) in the playlist
is returned.
=item $station->B<count>()
Returns the number of streams found for the station.
=item $station->B<getID>(['fccid'])
Returns the station's Tunein ID (default) or
station's FCC call-letters ("fccid").
=item $station->B<getTitle>(['desc'])
( run in 0.822 second using v1.01-cache-2.11-cpan-39bf76dae61 )