#!/usr/bin/perl # Copyright (c) 2007 洪任諭 (PCMan) # # 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. sub get_subitems{ my $of="~/.gtkhirad/$_[0].htm"; my $cmd = "wget --post-data='cid=$_[0]' http://hichannel.hinet.net/radio/ajax/menu.jsp -O $of >/dev/null 2>&1"; system( $cmd ); @items = `grep 'radio.jsp' $of | iconv -f big5 -t utf-8`; system( "rm $of" ); foreach $item (@items) { $item =~ s/^.*href="//; $item =~ s/<\/a>.*$//; my @tmp = split(/">/, $item); my $url = $tmp[0]; my $name=$tmp[1]; chomp($name); print OF $name."\t".$url."\n"; } printf OF "\n"; } sub get_dir{ system("wget http://hichannel.hinet.net/radio/index.jsp -O ~/.gtkhirad/home >/dev/null 2>&1"); system("grep \"['ImageRadio[0-9]*',*]\" ~/.gtkhirad/home > ~/.gtkhirad/dir"); system( "rm ~/.gtkhirad/home" ); open(F, <~/.gtkhirad/dir>); while( my $l = ) { $l =~ m/[^0-9]*([0-9]*)/; my $id = $1; if( $id eq "" ) { next; } #print "ID: ".$id."\n"; $l =~ m/(images\/[^']*.gif)/g; $img = $1; #print "Image: ".$img."\n"; system("wget http://hichannel.hinet.net/radio/$img -O ~/.gtkhirad/$id.gif >/dev/null 2>&1"); print OF "$id\n"; &get_subitems( $id ); } close(F); system("rm ~/.gtkhirad/dir"); } system("mkdir ~/.gtkhirad >/dev/null 2>&1"); $fn=glob("~/.gtkhirad/menu"); open( OF, ">$fn" ) || die "failed"; &get_dir; close( OF );