The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tunein::Streams - Fetch actual raw streamable URLs from radio-station websites on Tunein.com

AUTHOR

This module is Copyright (C) 2017 by

Jim Turner, <turnerjw784 at yahoo.com>

Email: turnerjw784@yahoo.com

All rights reserved.

You may distribute this module under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

SYNOPSIS

        use strict;

        use Tunein::Streams;

        my $station = new Tunein::Streams(<url>);

        die "Invalid URL or no streams found!\n"  unless ($station);

        my @streams = $station->get();

        my $first = $station->get();

        my $best = $station->getBest();

        print "Best stream URL=".$best->{'Url'}."\n";

        my $besturl = $station->getBest('Url');

        my $stationTitle = $station->getStationTitle();
        
        print "Best stream URL=$besturl, Title=$stationTitle\n";

        my @allfields = $station->validFields();

        for (my $i=0; $i<$station->count(); $i++) {

                foreach my $field (@allfields) {

                        print "--$field: ".$streams[$i]->{$field}."\n";

                }

        }
        

DESCRIPTION

Tunein::Streams accepts a valid radio station URL on http://tunein.com and returns the urls and other information properties for the actual stream URLs available for that station. 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 audio 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 playing. The author uses his own custom all-purpose audio player called "fauxdacious" (his custom hacked version of the open-source "audacious" media player. "fauxdacious" incorporates this module to decode and play tunein.com streams.

One or more streams can be returned for each station. The available properties for each stream returned are normally: Bandwidth, HasPlaylist (1|0), MediaType (ie. MP3, AAC, etc.), Reliability (1-100), StreamId (numeric), Type (ie. Live) and Url.

EXAMPLES

use strict;

        use Tunein::Streams;

        my $kluv = new Tunein::Streams('http://tunein.com/radio/987-KLUV-s33892/');

        die "Invalid URL or no streams found!\n"  unless ($kluv);

        my $besturl = $kluv->getBest('Url');

        my $beststream = $kluv->getBest();

        my @allfields = $kluv->validFields();

        foreach my $field (@allfields) {

                print "--$field: ".$beststream->{$field}."\n";

        }

This would print:

--Bandwidth: 64

--HasPlaylist: 0

--MediaType: Windows

--Reliability: 100

--StreamId: 75549037

--Type: Live

--Url: http://19273.live.streamtheworld.com/KLUVFM_SC

SUBROUTINES/METHODS

new(url)

Accepts a tunein.com URL and creates and returns a new station object, or undef if the URL is not a valid tunein station or no streams are found.

$station->get([property])

Returns either a scalar or array of either values or hash references with an element for each stream url found. If property is specified, then the item(s) returned are scalars containing that property's value, otherwise, the item(s) returned are hash references, each to a hash who's elements represent the names and values for each property of the given stream. If a scalar target is used, the first stream is returned, if an array target is used, all streams are returned.

$station->getBest([property])

Similar to get() except it only returns a single stream representing the "best" stream found. "best" is determined as the one with the best Bandwidth with the best Reliability, if more than one with the same best Bandwidth value. If [property] is specified, only that property value is returned as a scalar. Otherwise, a hash reference to all the properties for that stream is returned.

$station->count()

Returns the number of streams found for the station.

$station->validFields()

Returns an array containing all the valid property names found. This list is normally: (Bandwidth, HasPlaylist, MediaType, Reliability, StreamId, Type, Url). These can be used in the get functions and as the keys in the hash references returned to fetch the corresponding property values.

$station->getStationID()

Returns the station's Tunein ID, for eample, the station: 'http://tunein.com/radio/987-KLUV-s33892/' would return "s33892".

$station->getStationTitle()

Returns the station's title (description). for eample, the station: 'http://tunein.com/radio/987-KLUV-s33892/' would return: "KLUV - Dallas, TX - Listen Online".

$station->getIconURL()

Returns the url for the station's "cover art" icon image.

$station->getImageURL()

Returns the url for the station's Tunein site's banner image.

KEYWORDS

tunein

DEPENDENCIES

LWP::Simple

BUGS

Please report any bugs or feature requests to bug-tunein-streams at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tunein-Streams. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Tunein::Streams

You can also look for information at:

ACKNOWLEDGEMENTS

The idea for this module came from a Python script that does this same task named "getstream", but I wanted a Perl module that could be called from within another program! I do not know the author of getstream.py.

LICENSE AND COPYRIGHT

Copyright 2017 Jim Turner.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.