diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-05-15 11:14:29 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-05-15 11:16:48 +0300 |
commit | 1a39a06e542ce1691d1815d1dcf2847c99a0c7f0 (patch) | |
tree | 94173ce7cb34d69a9139f2a348fa05ac2285c40a | |
parent | f8f0ed2521db01b7180ab7be328884035edcc5f3 (diff) | |
download | vdradmin-am-1a39a06e542ce1691d1815d1dcf2847c99a0c7f0.tar.gz vdradmin-am-1a39a06e542ce1691d1815d1dcf2847c99a0c7f0.tar.bz2 |
Use default streamdev host from browser URL when VDR host is localhost.
http://projects.vdr-developer.org/issues/642
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | install.sh | 1 | ||||
-rwxr-xr-x | vdradmind.pl | 43 |
4 files changed, 24 insertions, 24 deletions
@@ -4,12 +4,13 @@ E-Mail: mail AT andreas DOT vdr-developer DOT org VDR-Portal: amair ----------------------------------------------------------- -2010-xx-xx: 3.6.x +2011-xx-xx: 3.6.x - Updated: Dutch translation (Submitted by Roel Koelewijn). - Updated: Finnish translation (Ville Skyttä). - Improved: Access logging (Ville Skyttä). - Improved: SVDRP connection error handling/logging/messages (Ville Skyttä). - Improved: Default SVDRP port is 6419 in initial config if locally installed VDR is >= 1.7.15 (Ville Skyttä). +- Improved: Use default streamdev host from browser URL when VDR host is localhost (Ville Skyttä). 2010-04-10: 3.6.7 - Updated: Italian translation (Submitted by Diego Pierotto). @@ -47,6 +47,7 @@ Requirements - Time::Local - MIME::Base64 - File::Temp + - URI - URI::Escape - Locale::gettext OR Locale::Messages - Optional: @@ -86,6 +86,7 @@ function perlModules() checkPerlModule Time::Local checkPerlModule MIME::Base64 checkPerlModule File::Temp + checkPerlModule URI checkPerlModule URI::Escape diff --git a/vdradmind.pl b/vdradmind.pl index 9f362b5..440b710 100755 --- a/vdradmind.pl +++ b/vdradmind.pl @@ -71,6 +71,7 @@ use POSIX qw(:sys_wait_h strftime mktime locale_h); use MIME::Base64 (); use File::Temp (); use Shell qw(locale); +use URI (); use URI::Escape qw(uri_escape); my $can_use_encode = 1; @@ -5156,26 +5157,24 @@ sub getReferer { sub live_stream { my $channel = $q->param("channel"); my $progname = $q->param("progname"); - my ($data, $ifconfig, $ip); + my $url; if ($CONFIG{ST_STREAMDEV_HOST}) { - $ip = $CONFIG{ST_STREAMDEV_HOST}; + $url = URI->new("http://$CONFIG{ST_STREAMDEV_HOST}"); } else { if ($CONFIG{VDR_HOST} =~ /^localhost(\.localdomain)?|127\.0\.0\.1$/i) { - $ifconfig = `/sbin/ifconfig eth0`; - if ($ifconfig =~ /inet.+:(\d+\.\d+\.\d+\.\d+)\s+Bcast/) { - $ip = $1; - } else { - $ip = `hostname`; - } + $url = URI->new($q->url(-base => 1)); + $url->scheme("http"); } else { - $ip = $CONFIG{VDR_HOST}; + $url = URI->new("http://$CONFIG{VDR_HOST}"); } } - chomp($ip); - $data = ""; + $url->port($CONFIG{ST_STREAMDEV_PORT}); + $url->path($channel); + + my $data = ""; $data .= "#EXTINF:0,$progname\n" if ($progname); - $data .= "http://$ip:$CONFIG{ST_STREAMDEV_PORT}/$channel\n"; + $data .= "$url\n"; return (header("200", $CONFIG{TV_MIMETYPE}, $data)); } @@ -6838,26 +6837,24 @@ sub run_svdrpcmd { sub export_channels_m3u { my $wanted = $q->param("wanted"); my @filenames = ( 'vdr_full_channels', 'vdr_selected_channels', 'vdr_tv_channels', 'vdr_radio_channels' ); - my ($ip, $ifconfig); + + my $url; if ($CONFIG{ST_STREAMDEV_HOST}) { - $ip = $CONFIG{ST_STREAMDEV_HOST}; + $url = URI->new("http://$CONFIG{ST_STREAMDEV_HOST}"); } else { if ($CONFIG{VDR_HOST} =~ /^localhost(\.localdomain)?|127\.0\.0\.1$/i) { - $ifconfig = `/sbin/ifconfig eth0`; - if ($ifconfig =~ /inet.+:(\d+\.\d+\.\d+\.\d+)\s+Bcast/) { - $ip = $1; - } else { - $ip = `hostname`; - } + $url = URI->new($q->url(-base => 1)); + $url->scheme("http"); } else { - $ip = $CONFIG{VDR_HOST}; + $url = URI->new("http://$CONFIG{VDR_HOST}"); } } - chomp($ip); + $url->port($CONFIG{ST_STREAMDEV_PORT}); my $data = ""; foreach (sort({ $a->{vdr_id} <=> $b->{vdr_id} } (@{$CHAN{$wanted}->{channels}}))) { - $data .= sprintf("#EXTINF:0,%s\nhttp://%s:%s/%s\n", $_->{name}, $ip, $CONFIG{ST_STREAMDEV_PORT}, $_->{uniq_id}); + $url->path($_->{uniq_id}); + $data .= sprintf("#EXTINF:0,%s\n%s\n", $_->{name}, $url); } return (header("200", $CONFIG{TV_MIMETYPE}, $data, sprintf("%s.%s", $filenames[$wanted], $CONFIG{TV_EXT}) )); } |