leSALON PHOTOGRAPHY 首頁 leSALON PHOTOGRAPHY
QSHOT foto 歡迎攝影同好加入
 
  搜尋搜尋   會員列表會員列表   會員群組會員群組   李非客李非客   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入 
 目前沒有活動計畫 

gtkhirad Linux 下聽Hinet Radio 的小軟體 hinet change code again

 
 
發表新主題   回覆主題    leSALON PHOTOGRAPHY 首頁 -> OSP linux hint
上一篇主題 :: 下一篇主題  
發表人 內容
foo
白金會員
白金會員


註冊時間: 2007-06-29
文章: 866
來自: MID2 BU #11798

發表發表於: 星期六 十一月 10, 2007 10:24 am    文章主題: gtkhirad Linux 下聽Hinet Radio 的小軟體 hinet change code again 引言回覆

fix code work after NOV 2007 hinet radio
PCMan play.pl
代碼:

#!/usr/bin/perl

# Copyright (c) 2007 洪任諭 (PCMan) <pcman.tw@gmail.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time );
my $baseurl = 'http://hichannel.hinet.net/radio/';
my $url = $baseurl.@ARGV[0];
my $record = 0;
my $month = (localtime)[4]+1;      # month
my $day = (localtime)[3];          # day
my $hour = (localtime)[2];         # hour
my $Ilikeradio = "radio.jsp?chid=205";
my $rthkradio ="mms://202.177.192.108/ptc";
my $bbcradio ="mms://livewmstream-ws.bbc.co.uk.edgestreams.net/reflector:38968";


if (-e $of) {
  system( "rm $of" );
}
print "perl radio player v0.2\r\n";

# add for fave radio class 8
$myradio = "xxxx";
$argcnt = $#ARGV + 1;
$myargv = @ARGV[0];
if ($argcnt == 2 && $ARGV[1] eq "record") {
    $record = 1;
    print "Recording......\r\n";
}

if (@ARGV[0] eq "0") {
    $myargv = $Ilikeradio;
    $url = $baseurl.$myargv;   
    $record = 1;
    print "I Like Radio \r\n";
} elsif (@ARGV[0] eq "1") {
    $myargv = $rthkradio;
    $url = $baseurl.$myargv;   
    $record = 1;
    print "RTHK Radio \r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/rthk%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;   
    close (fps);   
    $cmd1 = sprintf("mimms -q -c -t 60 %s %s&",$myargv,$cmd);
    exec $cmd1;       
    die("881");
} elsif (@ARGV[0] eq "2") {
    $myargv = $bbcradio;
    $url = $baseurl.$myargv;   
    $record = 1;
    print "BBC World service Radio \r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/bbc%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;       
    close (fps);
    $cmd1 = sprintf("mimms -q -c -t 60 %s %s&",$myargv,$cmd);
    exec $cmd1;   
    die("881");
}


$myradio = substr($myargv, 0, 5);
if ($myradio eq "\tmms:") {
    print "my Radio\r\n";
    exec "mplayer -cache 128 $myargv";
    exit;
} elsif ($myradio eq "radio") {
    print "it's hiradio\r\n";
} else {
    die "exit:: Empty argv\r\n"; 
}

#----------------------------------------
print "Connecting in progress ....";
my $of='~/.gtkhirad/current.htm';
system("wget -q -O $of $url");
$url=`grep '<iframe .*src=".*player.*">' $of`;
system( "rm $of" );
#print $url."\r\n";
$url =~ m/^.*src="([^"]*)/;
$url = $baseurl.$1;

my $of='~/.gtkhirad/current.htm5';
system("wget -q -O $of $url");
$url=`grep 'window\.open' $of`;
system( "rm $of" );
#print $url."\r\n";
$url =~ m/\('([^']*)/;
$url = $baseurl."..".$1;
#print $url."\r\n";

my $of='~/.gtkhirad/current.htm1';
system("wget -q -O $of $url");
$url=`grep 'setMovieFile' $of`;
system( "rm $of" );
#print $url."\r\n";
$url =~ m/\("([^"]*)/;
$url = $baseurl.$1;
#print $url."\r\n";
$url =~ s/&r=//;
#print $url."\r\n";   

my $of='~/.gtkhirad/current.htm2';
system("wget --user-agent='Windows Media Player' -q -O $of $url");
$url=`grep -i 'href' $of`;
#print $url."\r\n";
system( "rm $of" );
$url =~ m/^.*href="([^"]*)/i;
$url = $1;
#print $url."\r\n";

my $of='~/.gtkhirad/current.htm3';
system("wget --user-agent='Windows Media Player' -q -O $of $url");
$url=`grep -i -m 1 'href' $of`;
#print $url."\r\n";
system( "rm $of" );
$url =~ m/^.*href="([^"]*)/i;
$url = $1;
#print $1."\r\n";

print "\r\n";
#print 'URL: '.$url."\n";
if ($record == 1) {
    #    print "Record ....";
    #    print "$url\r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/radio%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;
    close (fps);
    #    $cmd1 = sprintf("mplayer -really-quiet -nortc -nolirc -cache 128 -dumpstream %s  -dumpfile %s",$url, $cmd);
    $cmd1 = sprintf("mimms -q -c -t 60 %s %s&",$url,$cmd);
    exec $cmd1;
} else {
    #    exec "mplayer -really-quiet -nojoystick -nolirc -cache 128 $url";
    exec "mplayer -ao alsa:device=hw=1,0 -nolirc -nojoystick -really-quiet -quiet -cache 128 $url";
}

很好:0
普通:0
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站 雅虎訊息通 MSN Messenger  No rating
foo
白金會員
白金會員


註冊時間: 2007-06-29
文章: 866
來自: MID2 BU #11798

發表發表於: 星期四 一月 03, 2008 4:12 pm    文章主題: 引言回覆

update 2008 JAN 03
代碼:
#!/usr/bin/perl

# Copyright (c) 2007 洪任諭 (PCMan) <pcman.tw@gmail.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#  patch from lecheel


use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time );
my $baseurl = 'http://hichannel.hinet.net/radio/';
my $url = $baseurl.@ARGV[0];
my $record = 0;
my $month = (localtime)[4]+1;      # month
my $day = (localtime)[3];          # day
my $hour = (localtime)[2];         # hour
my $Ilikeradio = "radio.jsp?chid=205";
my $NEWS98 = "radio.jsp?chid=187";
my $UFO = "radio.jsp?chid=232";
my $rthkradio ="mms://202.177.192.108/ptc";
my $bbcradio ="mms://livewmstream-ws.bbc.co.uk.edgestreams.net/reflector:38968";

my $baseIP ="mms://203.69.144.196/203.69.144.138/";


if (-e $of) {
  system( "rm $of" );
}
print "perl radio player v0.3\r\n";

# add for fave radio class 8
$myradio = "xxxx";
$argcnt = $#ARGV + 1;
$myargv = @ARGV[0];
if ($argcnt == 2 && $ARGV[1] eq "record") {
    $record = 1;
    print "Recording......\r\n";
}

if (@ARGV[0] eq "0") {
    $myargv = $UFO;
    $url = $baseurl.$myargv;   
    $record = 0;
    $uid="?id=232";
    print "UFO Network \r\n";
} elsif (@ARGV[0] eq "1") {
    $myargv = $Ilikeradio;
    $url = $baseurl.$myargv;   
    $record = 0;
    $uid="?id=205";
    print "I Like Radio \r\n";   
} elsif (@ARGV[0] eq "2") {
    $myargv = $NEWS98;
    $url = $baseurl.$myargv;   
    $record = 0;
    $uid="?id=187";
    print "NEWs98 \r\n";       
} elsif (@ARGV[0] eq "10") {
    $myargv = $rthkradio;
    $url = $baseurl.$myargv;   
    $record = 1;
    print "RTHK Radio \r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/rthk%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;   
    close (fps);   
    exec "mimms -q -c -t 60 $myargv /share/radio/rthk$month$day-$hour.asf &";   
    die("881");
} elsif (@ARGV[0] eq "20") {
    $myargv = $bbcradio;
    $url = $baseurl.$myargv;   
    $record = 1;
    print "BBC World service Radio \r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/bbc%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;       
    close (fps);
    $cmd1 = sprintf("mimms -q -c -t 60 %s %s&",$myargv,$cmd);
    exec $cmd1;   
    die("881");
}


$myradio = substr($myargv, 0, 5);
if ($myradio eq "\tmms:") {
    print "my Radio\r\n";
    exec "mplayer -cache 128 $myargv";
    exit;
} elsif ($myradio eq "radio") {
    print "it's hiradio\r\n";
} else {
    die "exit:: Empty argv (0,1,2,3,10,20)\r\n"; 
}

#----------------------------------------
print "Connecting in progress ....\r\n";
my $of='~/.gtkhirad/current.htm';
system("wget -q -O $of $url");
$url=`grep '<iframe .*src=".*player.*">' $of`;
system( "rm $of" );
#print $url."\r\n";
$url =~ m/^.*src="([^"]*)/;
$url = $baseurl.$1;

my $of='~/.gtkhirad/current.htm5';
system("wget -q -O $of $url");
$url=`grep 'window\.open' $of`;
system( "rm $of" );
#print $url."\r\n";
$url =~ m/\('([^']*)/;
$url = $baseurl."..".$1;
print $url."\r\n";

#print "------------------grep setMovieFile\r\n";
my $of='~/.gtkhirad/current.htm1';
system("wget -q -O $of $url");
$url=`grep 'setMovieFile' $of`;
system( "rm $of" );
#print $url."\r\n--setMovieFile--\r\n";
$url =~ m/\("([^?]*)/;
$url = $baseurl.$1.$uid;
#print $url."\r\n";
#$url =~ s/&r=//;
print $url."\r\n";   
#print "should like this http://hichannel.hinet.net/radio/../api/streamFreeRadio.jsp?id=205\r\n";

print "WMP....................HREF http://\r\n";
my $of='~/.gtkhirad/current.htm2';
system("wget --user-agent='Windows Media Player' -q -O $of $url");
$url=`grep -i 'href' $of`;
#print $url."\r\n";
system( "rm $of" );
$url =~ m/^.*href="([^"]*)/i;
$url = $1;
print $url."\r\n";

print "WMP2.................... href mms://\r\n";
$i = 0;
while ($i<10) {
    my $of='~/.gtkhirad/current.htm3';
    system("wget --user-agent='Windows Media Player' -q -O $of $url");
    $url=`grep -i -m 1 'href' $of`;
    #print $url."\r\n";
    system( "rm $of" );
    $url =~ m/^.*href="([^"]*)/i;
    $url = $1;
    $var = substr($url, 0, 3);
    if ($var eq "mms")
    {
        $i = 20;
        #        print "mms://...... founded\r\n";
        print $1."\r\n";
    }
    else
    {
        $i = $i + 1;
        sleep(2);
        print "retry ....".$i."\r\n";
    }
}
if ($i <20)
{
    print "Need.... mms://nnn.mmm.nnn.mmm/.."."$i"."...asf\r\n";   
    exit;
}

print 'URL: '.$url."\n";
if ($record == 1) {
    #    print "Record ....";
    #    print "$url\r\n";
    open (fps, '>/share/radio/lastfm');
    $cmd = sprintf("/share/radio/radio%02d%02d-%02d.asf", $month, $day, $hour);
    print fps $cmd;
    close (fps);
    #    $cmd1 = sprintf("mplayer -really-quiet -nortc -nolirc -cache 128 -dumpstream %s  -dumpfile %s",$url, $cmd);
    $cmd1 = sprintf("mimms -q -c -t 60 %s %s&",$url,$cmd);
    exec $cmd1;
} else {
    #exec "mplayer -cache 128 $url";
    exec "mplayer -really-quiet -nortc -nolirc -cache 128 $url";
}

很好:0
普通:0

_________________
EOS 5D/50D 580EX
EOS 630/3
EF 16-35L/24-105L/50/85L/100/100-400L
Epson F-3200
Ubuntu 9.04 GiMP 2.6
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站 雅虎訊息通 MSN Messenger  No rating
foo
白金會員
白金會員


註冊時間: 2007-06-29
文章: 866
來自: MID2 BU #11798

發表發表於: 星期五 九月 05, 2008 8:38 am    文章主題: 引言回覆

2oo8 SEP 5 change again

----
following patch should fix setMovieFile problem +asx+
----
代碼:

#print "------------------grep setMovieFile\r\n";
my $of='~/.gtkhirad/current.htm1';
system("wget -q -O $of $url");
###############################################
#                                             #
#   before 2008 SEP 5                         #
###############################################
###$url=`grep 'setMovieFile' $of`;            #
####system( "rm $of" );                       #
####print $url."\r\n--setMovieFile--\r\n";    #
###$url =~ m/\("([^?]*)/;                     #
###$url = $baseurl.$1.$uid;                   #
###############################################

$url=`grep "asx = '" $of`;
system( "rm $of" );
$url =~ m/^.*asx = '([^&]*)/;
#$url = $baseurl.$1.$uid;
$url = $baseurl.$1;
##print $url."\r\n";

## should like this "http://hichannel.hinet.net/radio/../api/streamFreeRadio.jsp?id=232"

很好:0
普通:0

_________________
EOS 5D/50D 580EX
EOS 630/3
EF 16-35L/24-105L/50/85L/100/100-400L
Epson F-3200
Ubuntu 9.04 GiMP 2.6
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站 雅虎訊息通 MSN Messenger  No rating
從之前的文章開始顯示:   
發表新主題   回覆主題    leSALON PHOTOGRAPHY 首頁 -> OSP linux hint 所有的時間均為 台灣時間 (GMT + 8 小時)
1頁(共1頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票


Powered by phpBB © 2001, 2005 phpBB Group..
正體中文語系由 phpbb-tw 維護製作