StreamFinder
view release on metacpan or search on metacpan
lib/StreamFinder.pm view on Meta::CPAN
my $genre = $station->{'genre'};
print "Genre=$genre\n" if ($genre);
my $icon_url = $station->getIconURL();
if ($icon_url) { #SAVE THE ICON TO A TEMP. FILE:
print "Icon URL=$icon_url=\n";
my ($image_ext, $icon_image) = $station->getIconData();
if ($icon_image && open IMGOUT, ">/tmp/${stationID}.$image_ext") {
binmode IMGOUT;
print IMGOUT $icon_image;
close IMGOUT;
print "...Icon image downloaded to (/tmp/${stationID}.$image_ext)\n";
}
}
my $stream_count = $station->count();
print "--Stream count=$stream_count=\n";
my @streams = $station->get();
foreach my $s (@streams) {
print "------ stream URL=$s=\n";
}
=head1 DESCRIPTION
StreamFinder accepts a webpage URL for a valid radio station, video, or podcast
/ episode URL on supported websites and returns the actual stream URL(s),
title, and cover art icon for that station / podcast / video. The purpose is
that one needs one of these URLs in order to have the option to stream the
station / podcast / video in one's own choice of media player software rather
than using their web browser and accepting flash, ads, javascript, cookies,
trackers, web-bugs, and other crapware associated with that method of play.
The author created and uses his own custom all-purpose media player called
"Fauxdacious Media Player" (his custom forked version of the open-source
"Audacious Audio Player). "Fauxdacious"
(L<https://wildstar84.wordpress.com/fauxdacious/>) incorporates this module via
a Perl helper-script to decode and play streams, along with their titles /
station names, and station / podcast / video icons, artists / channel names,
genres, and descriptions!
Please NOTE: StreamFinder is a module, NOT a standalone application. It is
designed to be used by other Perl applications. To create your own very simple
application just to fetch stream data manually, simply grab the code in the
B<SYNOPSIS> section above, save it to an executable text file, ie.
I<StreamFinder.pl>, and run it from the command line with a supported streaming
site URL as the argument. You can then edit it to tailor it to your needs.
The currently-supported websites are:
podcasts.apple.com podcasts (L<StreamFinder::Apple>),
bitchute.com videos (L<StreamFinder::Bitchute>),
blogger.com videos (L<StreamFinder::Blogger>),
brandnewtube.com (now onevsp.com) videos (L<StreamFinder::BrandNewTube>),
brighteon.com videos (L<StreamFinder::Brighteon>),
castbox.fm podcasts (L<StreamFinder::Castbox>),
theepochtimes.com/epochtv videos (L<StreamFinder::EpochTV>),
iheart.com (aka iheartradio.com) radio stations and podcasts
(L<StreamFinder::IHeartRadio>),
www.internet-radio.com radio stations (L<StreamFinder::InternetRadio>),
onlineradiobox.com radio stations (L<StreamFinder::OnlineRadiobox>),
odysee.com videos (L<StreamFinder::Odysee>),
podbean.com podcasts (L<StreamFinder::Podbean>),
podcastaddict.com podcasts (L<StreamFinder::PodcastAddict>),
podchaser.com podcasts (L<StreamFinder::Podchaser>),
prageru.com videos (L<StreamFinder::PragerU>),
radio.net radio stations (L<StreamFinder::RadioNet>),
rcast.net radio stations (L<StreamFinder::Rcast>),
rumble.com videos (L<StreamFinder::Rumble>),
sermonaudio.com sermons: audio and video (L<StreamFinder::SermonAudio>),
soundcloud.com (non-paywalled) songs (L<StreamFinder::SoundCloud>)
(DEPRECIATED), spreaker.com podcasts (L<StreamFinder::Spreaker>),
subsplash.com podcasts (L<StreamFinder::Subsplash>) (EXPERIMENTAL),
tunein.com (non-paywalled) radio stations and podcasts
(L<StreamFinder::Tunein>), vimeo.com videos (L<StreamFinder::Vimeo>),
youtube.com, et. al and other sites that yt-dlp support
(L<StreamFinder::Youtube>),
zeno.fm radio stations and podcasts (L<StreamFinder::Zeno>),
and L<StreamFinder::Anystream> - search any (other) webpage URL (not supported
by any of the other submodules) for streams.
NOTE: StreamFinder::Podcastaddict is now fully-functional again including
being able to return playlists from podcast pages!
NOTE: StreamFinder::Google has been removed as Google Podcasts has shut down.
NOTE: Users should also consider StreamFinder::SoundCloud to now be
depreciated, as they've added cookie and tracker requirements making it
impossible to search for songs on their site without enabling, but song URLs
(when known) seem to still work for now, but without channel/artist icons.
(Privacy-minded individuals should now be cautious while using this site).
NOTE: For many sites, ie. Youtube, Vimeo, Apple, Spreaker, Castbox, PragerU,
etc. the "station" object actually refers to a specific video or podcast
episode, but functions the same way.
Each site is supported by a separate subpackage (StreamFinder::I<Package>),
which is determined and selected based on the URL argument passed to it when
the StreamFinder object is created. The methods are overloaded by the selected
subpackage's methods. An example would be B<StreamFinder::Youtube>.
Please see the POD. documentation for each subpackage for important additional
information on options and features specific to each site / subpackage!
One or more playable streams can be returned for each station / video /
podcast, along with at least a "title" (station name / video or podcast episode
title) and an icon image URL ("iconurl" - if found). Additional information
that MAY be fetched is a (larger?) banner image ("imageurl"), a (longer?)
"description", an "artist" / author, a "genre", and / or a "year" (podcasts,
videos, etc.), an AlbumArtist / channel URL, and possibly a second
icon image for the channel (podcasts and videos). Some sites also provide
radio stations' FCC call letters ("fccid"). For icon and image URLs,
functions exist (getIconData() and getImageData()) to fetch the actual binary
data and mime type for downloading to local storage for use by your
application or preferred media player. NOTE: StreamFinder::Anystream is not
able to return much beyond the stream URLs it finds, but please see it's POD
documentation for details on what it is able to return.
If you have another streaming site that is not supported, first, make sure
you have B<yt-dlp> installed and see if B<StreamFinder::Youtube> can
successfully fetch any streams for it. If not, then please file a feature
request via email or the CPAN bug system, or (for faster service), provide a
Perl patch module / program source that can extract some or all of the
necessary information for streams on that site and I'll consider it! The
easiest way to do this is to take one of the existing submodules, copy it to
"StreamFinder::I<YOURSITE>.pm", modify it (and the POD docs) to your
specific site's needs, test it on several of their pages (see the "SYNOPSIS"
code above), and send it to me (That's what I do when I want to add a
new site)!
=head1 SUBROUTINES/METHODS
=over 4
=item B<new>(I<url> [, I<options> ])
Accepts a URL and creates and returns a new station, video, or
podcast object, or I<undef> if the URL is not a valid station or
no streams are found.
NOTE: Depending on the type of site being queried, the "station
object" can be either a streaming station, a video, or a podcast,
but works the same way (method calls, arguments, etc.).
NOTE: A full URL must be specified here, but if using any of the
subpackage modules directly instead, then either a full URL OR just
the station / video / podcast's site ID may be used! Reason being
that this function parses the full URL to determine which subpackage
(site) module to use.
I<options> can vary depending on the type of site that is
being queried. One option common to all sites is I<-debug>, which
turns on debugging output. A numeric option can follow specifying
the level (0, 1, or 2). 0 is none, 1 is basic, 2 is detailed.
Default: B<1> (if I<-debug> is specified). Warning: 2 will dump a ton
of output (mostly the HTML of the web page being parsed!
One specific option (I<-omit>, added as of v1.45) permits omitting
specific submodules which are currently installed from being considered.
For example, to NOT handle Youtube videos nor use the fallback
"Anystream" module, specify: I<-omit> => I<"Youtube,Anystream">, which
will cause StreamFinder::Anystream and StreamFinder::Youtube to not be used
for the stream search. Default is for all installed submodules to be
considered. NOTE: Omitting a module from being considered when seeking
to match the correct module by site URL does NOT prevent that
module from being invoked by a selected module for an embedded link, OR
in the case of StreamFinder::Youtube being omitted, will still be invoked,
if required or needed by a non-omitted module initially selected!
Another global option (applicable to all submodules) is the I<-secure>
option who's argument can be either 0 or 1 (I<false> or I<true>). If 1,
then only secure ("https://") streams will be returned. NOTE, it's
possible that some sites may only contain insecure ("http://") streams,
which won't return any streams if this option is specified. Therefore,
it may be necessary, if setting this option globally, to set it to
zero in the config. files for those specific modules, if you determine
that to be the case (I have not tested all sites for that). Default:
I<-secure> is 0 (false) - return all streams (http and https).
Any other options (including I<-debug>) will be passed to the submodule
(if any) that handles the URL you pass in, but note, submodules accept
different options and ignore ones they do not recognize. Valid values
for some options can also vary across different submodules. A better
way to change default options for one or more submodules is to set up
submodule configuration files for the ones you wish to change.
Additional options:
I<-hls_bandwidth> => "I<number>"
Limit HLS (m3u8) streams that contain a list of other HLS streams of varying
BANDWIDTH values (in BITS per second) by selecting the highest bitrate stream
at or below the specified limit when I<$stream>->I<getURL()> is called.
DEFAULT I<-none-> (no limiting by bitrate).
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.
( run in 0.684 second using v1.01-cache-2.11-cpan-39bf76dae61 )