Permalink
Browse files

chunked everything up

  • Loading branch information...
1 parent 8f3c70a commit e4b6e607147a75070b5ddc4cc471d7df0041fe90 James Laver committed Mar 11, 2010
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,102 @@
+package Programme::bbclive;
+
+use Env qw[@PATH];
+use Fcntl;
+use File::Copy;
+use File::Path;
+use File::stat;
+use HTML::Entities;
+use HTTP::Cookies;
+use HTTP::Headers;
+use IO::Seekable;
+use IO::Socket;
+use LWP::ConnCache;
+use LWP::UserAgent;
+use POSIX qw(mkfifo);
+use strict;
+use Time::Local;
+use URI;
+
+# Inherit from Programme class
+use base 'Programme::bbciplayer';
+
+# Class vars
+sub file_prefix_format { '<name> <episode> <dldate> <dltime>' }
+
+# Class cmdline Options
+sub opt_format {
+ return {};
+}
+
+
+
+# Method to return optional list_entry format
+sub optional_list_entry_format {
+ return '';
+}
+
+
+sub clean_pid {
+ my $prog = shift;
+
+ # If this is a BBC *iPlayer* Live channel
+ #if ( $prog->{pid} =~ m{http.+bbc\.co\.uk/iplayer/console/}i ) {
+ # # Just leave the URL as the pid
+ # e.g. http://www.bbc.co.uk/iplayer/playlive/bbc_radio_fourfm/
+ if ( $prog->{pid} =~ m{http.+bbc\.co\.uk/iplayer}i ) {
+ # Remove extra URL path for URLs like 'http://www.bbc.co.uk/iplayer/playlive/bbc_radio_one/'
+ $prog->{pid} =~ s/^http.+\/(.+?)\/?$/$1/g;
+
+ # Else this is an embedded media player URL (live or otherwise)
+ } elsif ($prog->{pid} =~ m{^http}i ) {
+ # Just leave the URL as the pid
+ }
+}
+
+
+
+# Usage: Programme::liveradio->get_links( \%prog, 'liveradio' );
+# Uses: %{ channels() }, \%prog
+sub get_links {
+ shift; # ignore obj ref
+ my $prog = shift;
+ my $prog_type = shift;
+ # Hack to get correct 'channels' method because this methods is being shared with Programme::radio
+ my %channels = %{ main::progclass($prog_type)->channels_filtered( main::progclass($prog_type)->channels() ) };
+
+ for ( sort keys %channels ) {
+
+ # Extract channel
+ my $channel = $channels{$_};
+ my $pid = $_;
+ my $name = $channels{$_};
+ my $episode = 'live';
+ main::logger "DEBUG: '$pid, $name - $episode, $channel'\n" if $opt->{debug};
+
+ # build data structure
+ $prog->{$pid} = main::progclass($prog_type)->new(
+ 'pid' => $pid,
+ 'name' => $name,
+ 'versions' => 'default',
+ 'episode' => $episode,
+ 'desc' => "Live stream of $name",
+ 'guidance' => '',
+ #'thumbnail' => "http://static.bbc.co.uk/mobile/iplayer_widget/img/ident_${pid}.png",
+ 'thumbnail' => "http://www.bbc.co.uk/iplayer/img/station_logos/${pid}.png",
+ 'channel' => $channel,
+ #'categories' => join(',', @category),
+ 'type' => $prog_type,
+ 'web' => "http://www.bbc.co.uk/iplayer/playlive/${pid}/",
+ );
+ }
+ main::logger "\n";
+ return 0;
+}
+
+
+
+sub download {
+ # Delegate to Programme::tv (same function is used)
+ return Programme::tv::download(@_);
+}
+
@@ -0,0 +1,151 @@
+package Programme::liveradio;
+
+use Env qw[@PATH];
+use Fcntl;
+use File::Copy;
+use File::Path;
+use File::stat;
+use HTML::Entities;
+use HTTP::Cookies;
+use HTTP::Headers;
+use IO::Seekable;
+use IO::Socket;
+use LWP::ConnCache;
+use LWP::UserAgent;
+use POSIX qw(mkfifo);
+use strict;
+use Time::Local;
+use URI;
+
+# Inherit from Programme class
+use base 'Programme::bbclive';
+
+# Class vars
+sub index_min { return 80100 }
+sub index_max { return 80199 }
+sub channels {
+ return {
+ 'bbc_1xtra' => 'BBC 1Xtra',
+ 'bbc_radio_one' => 'BBC Radio 1',
+ 'bbc_radio_two' => 'BBC Radio 2',
+ 'bbc_radio_three' => 'BBC Radio 3',
+ 'bbc_radio_fourfm' => 'BBC Radio 4 FM',
+ 'bbc_radio_fourlw' => 'BBC Radio 4 LW',
+ 'bbc_radio_five_live' => 'BBC Radio 5 live',
+ 'bbc_radio_five_live_sports_extra' => 'BBC 5 live Sports Extra',
+ 'bbc_6music' => 'BBC 6 Music',
+ 'bbc_7' => 'BBC 7',
+ 'bbc_asian_network' => 'BBC Asian Network',
+ 'bbc_radio_foyle' => 'BBC Radio Foyle',
+ 'bbc_radio_scotland' => 'BBC Radio Scotland',
+ 'bbc_radio_nan_gaidheal' => 'BBC Radio Nan Gaidheal',
+ 'bbc_radio_ulster' => 'BBC Radio Ulster',
+ 'bbc_radio_wales' => 'BBC Radio Wales',
+ 'bbc_radio_cymru' => 'BBC Radio Cymru',
+ 'http://www.bbc.co.uk/worldservice/includes/1024/screen/audio_console.shtml?stream=live' => 'BBC World Service',
+ 'bbc_world_service' => 'BBC World Service Intl',
+ 'bbc_radio_cumbria' => 'BBC Cumbria',
+ 'bbc_radio_newcastle' => 'BBC Newcastle',
+ 'bbc_tees' => 'BBC Tees',
+ 'bbc_radio_lancashire' => 'BBC Lancashire',
+ 'bbc_radio_merseyside' => 'BBC Merseyside',
+ 'bbc_radio_manchester' => 'BBC Manchester',
+ 'bbc_radio_leeds' => 'BBC Leeds',
+ 'bbc_radio_sheffield' => 'BBC Sheffield',
+ 'bbc_radio_york' => 'BBC York',
+ 'bbc_radio_humberside' => 'BBC Humberside',
+ 'bbc_radio_lincolnshire' => 'BBC Lincolnshire',
+ 'bbc_radio_nottingham' => 'BBC Nottingham',
+ 'bbc_radio_leicester' => 'BBC Leicester',
+ 'bbc_radio_derby' => 'BBC Derby',
+ 'bbc_radio_stoke' => 'BBC Stoke',
+ 'bbc_radio_shropshire' => 'BBC Shropshire',
+ 'bbc_wm' => 'BBC WM',
+ 'bbc_radio_coventry_warwickshire' => 'BBC Coventry & Warwickshire',
+ 'bbc_radio_hereford_worcester' => 'BBC Hereford & Worcester',
+ 'bbc_radio_northampton' => 'BBC Northampton',
+ 'bbc_three_counties_radio' => 'BBC Three Counties',
+ 'bbc_radio_cambridge' => 'BBC Cambridgeshire',
+ 'bbc_radio_norfolk' => 'BBC Norfolk',
+ 'bbc_radio_suffolk' => 'BBC Suffolk',
+ 'bbc_radio_sussex' => 'BBC Sussex',
+ 'bbc_radio_essex' => 'BBC Essex',
+ 'bbc_london' => 'BBC London',
+ 'bbc_radio_kent' => 'BBC Kent',
+ 'bbc_southern_counties_radio' => 'BBC Southern Counties',
+ 'bbc_radio_oxford' => 'BBC Oxford',
+ 'bbc_radio_berkshire' => 'BBC Berkshire',
+ 'bbc_radio_solent' => 'BBC Solent',
+ 'bbc_radio_gloucestershire' => 'BBC Gloucestershire',
+ 'bbc_radio_swindon' => 'BBC Swindon',
+ 'bbc_radio_wiltshire' => 'BBC Wiltshire',
+ 'bbc_radio_bristol' => 'BBC Bristol',
+ 'bbc_radio_somerset_sound' => 'BBC Somerset',
+ 'bbc_radio_devon' => 'BBC Devon',
+ 'bbc_radio_cornwall' => 'BBC Cornwall',
+ 'bbc_radio_guernsey' => 'BBC Guernsey',
+ 'bbc_radio_jersey' => 'BBC Jersey',
+ };
+}
+
+
+# Class cmdline Options
+sub opt_format {
+ return {
+ liveradiomode => [ 1, "liveradiomode=s", 'Recording', '--liveradiomode <mode>,<mode>,..', "Live Radio Recording modes: flashaac,realaudio,wma"],
+ outputliveradio => [ 1, "outputliveradio=s", 'Output', '--outputliveradio <dir>', "Output directory for live radio recordings"],
+ rtmpliveradioopts => [ 1, "rtmp-liveradio-opts|rtmpliveradioopts=s", 'Recording', '--rtmp-liveradio-opts <options>', "Add custom options to flvstreamer/rtmpdump for liveradio"],
+ };
+}
+
+
+
+# This gets run before the download retry loop if this class type is selected
+sub init {
+ # Force certain options for Live
+ # Force --raw otherwise realaudio stdout streaming fails
+ # (this would normally be a bad thing but since its a live stream we
+ # won't be downloading other types of progs afterwards)
+ $opt->{raw} = 1 if $opt->{stdout} && $opt->{nowrite};
+ # Force only one try if live and recording to file
+ $opt->{attempts} = 1 if ( ! $opt->{attempts} ) && ( ! $opt->{nowrite} );
+ # Force to skip checking history if live
+ $opt->{force} = 1;
+}
+
+
+
+# Returns the modes to try for this prog type
+sub modelist {
+ my $prog = shift;
+ my $mlist = $opt->{liveradiomode} || $opt->{modes};
+
+ # Defaults
+ if ( ! $mlist ) {
+ if ( ! main::exists_in_path('flvstreamer') ) {
+ main::logger "WARNING: Not using flash modes since flvstreamer/rtmpdump is not found\n" if $opt->{verbose};
+ $mlist = 'realaudio,wma';
+ } else {
+ $mlist = 'flashaachigh,flashaacstd,realaudio,flashaaclow,wma';
+ }
+ }
+ # Deal with BBC Radio fallback modes and expansions
+ # Valid modes are rtmp,flashaac,realaudio,wmv
+ # 'rtmp' or 'flash' => 'flashaac'
+ # flashaac => flashaachigh,flashaacstd,flashaaclow
+ # flashaachigh => flashaachigh1,flashaachigh2
+ $mlist = main::expand_list($mlist, 'best', 'flashaachigh,flashaacstd,realaudio,flashaaclow,wma');
+ $mlist = main::expand_list($mlist, 'flash', 'flashaac');
+ $mlist = main::expand_list($mlist, 'rtmp', 'flashaac');
+ $mlist = main::expand_list($mlist, 'flashaac', 'flashaachigh,flashaacstd,flashaaclow');
+
+ return $mlist;
+}
+
+
+
+# Default minimum expected download size for a programme type
+sub min_download_size {
+ return 102400;
+}
+
@@ -0,0 +1,88 @@
+package Programme::livetv;
+
+use Env qw[@PATH];
+use Fcntl;
+use File::Copy;
+use File::Path;
+use File::stat;
+use HTML::Entities;
+use HTTP::Cookies;
+use HTTP::Headers;
+use IO::Seekable;
+use IO::Socket;
+use LWP::ConnCache;
+use LWP::UserAgent;
+use POSIX qw(mkfifo);
+use strict;
+use Time::Local;
+use URI;
+
+# Inherit from Programme class
+use base 'Programme::bbclive';
+
+# Class vars
+sub index_min { return 80000 }
+sub index_max { return 80099 }
+sub channels {
+ return {
+ 'bbc_one' => 'BBC One',
+ 'bbc_two' => 'BBC Two',
+ 'bbc_three' => 'BBC Three',
+ 'bbc_four' => 'BBC Four',
+ 'cbbc' => 'CBBC',
+ 'cbeebies' => 'CBeebies',
+ 'bbc_news24' => 'BBC News 24',
+ 'bbc_parliament' => 'BBC Parliament',
+ };
+}
+
+
+# Class cmdline Options
+sub opt_format {
+ return {
+ livetvmode => [ 1, "livetvmode=s", 'Recording', '--livetvmode <mode>,<mode>,...', "Live TV Recoding modes: flashhd,flashvhigh,flashhigh,flashstd,flashnormal (default: flashhd,flashvhigh,flashhigh,flashstd,flashnormal)"],
+ outputlivetv => [ 1, "outputlivetv=s", 'Output', '--outputlivetv <dir>', "Output directory for live tv recordings"],
+ rtmplivetvopts => [ 1, "rtmp-livetv-opts|rtmplivetvopts=s", 'Recording', '--rtmp-livetv-opts <options>', "Add custom options to flvstreamer/rtmpdump for livetv"],
+ };
+}
+
+
+
+# This gets run before the download retry loop if this class type is selected
+sub init {
+ # Force certain options for Live
+ # Force only one try if live and recording to file
+ $opt->{attempts} = 1 if ( ! $opt->{attempts} ) && ( ! $opt->{nowrite} );
+ # Force to skip checking history if live
+ $opt->{force} = 1;
+}
+
+
+
+# Returns the modes to try for this prog type
+sub modelist {
+ my $prog = shift;
+ my $mlist = $opt->{livetvmode} || $opt->{modes};
+
+ # Defaults
+ if ( ! $mlist ) {
+ $mlist = 'flashhd,flashvhigh,flashhigh,flashstd,flashnormal';
+ }
+ # Deal with BBC TV fallback modes and expansions
+ # Valid modes are rtmp,flashhigh,flashstd
+ # 'rtmp' or 'flash' => 'flashhigh,flashnormal'
+ $mlist = main::expand_list($mlist, 'best', 'flashhd,flashvhigh,flashhigh,flashstd,flashnormal,flashlow');
+ $mlist = main::expand_list($mlist, 'flash', 'flashhd,flashvhigh,flashhigh,flashstd,flashnormal,flashlow');
+ $mlist = main::expand_list($mlist, 'rtmp', 'flashhd,flashvhigh,flashhigh,flashstd,flashnormal,flashlow');
+
+ return $mlist;
+}
+
+
+
+# Default minimum expected download size for a programme type
+sub min_download_size {
+ return 102400;
+}
+
+
Oops, something went wrong.

0 comments on commit e4b6e60

Please sign in to comment.