[mythtv-users] tv_grab_au: ninemsn obfuscating data
Michael Cowell
michael at mousewasher.dk
Tue Nov 8 21:12:16 EST 2005
Tj wrote:
>
> I think I just got past the look_down error.
>
> get_guide_page should look something like this.. i.e. the jz encoding
> and the "<SCRIPT>" things should be done in this sub instead. yay!
>
> sub get_guide_page {
> my $service = shift;
> my $date = shift;
> my $url = "$NMSN/guide/${date}_$service->{regionid}.asp?"
> . "channel=$service->{name}" . MSID();
> print "GET_GUIDE_PAGE($url)\n" if $debug;
> my $page = get_page($url) or
> print "Warning: Failed to get program listing for day $date\n";
> if ( $page ) {
> ++$count_guide;
> $page =~ s/jz\('([^']+)'\);/jz($1)/eg;
> $page =~ s/<SCRIPT src=\"dcr.js\"><\/SCRIPT><SCRIPT
> Language=\"Javascript\">/""/eg;
> $page =~ s/^<\/SCRIPT><NOSCRIPT>.*<\/NOSCRIPT>/""/eg;
> }
> return $page;
>
Here is a cleaner patch, with config that works. I think yours changes
should work too.
Michael
-------------- next part --------------
*** tv_grab_au Sat Aug 20 12:09:38 2005
--- tv_grab_au.new Wed Nov 9 12:08:01 2005
***************
*** 218,223 ****
--- 218,224 ----
for my $service (@{$conf->{services}}) {
my $guidedata = get_guide_page($service, dmY($date6am)) or next;
+
my $tree = HTML::TreeBuilder->new_from_content($guidedata);
for ($tree->look_down('_tag' => 'table', 'class' => 'tv')) {
***************
*** 257,262 ****
--- 258,266 ----
my @link = @{ $e->extract_links() };
die "too many links:\n" . $html if @link > 1;
my $url = $NMSN . $link[0]->[0];
+ # NMSN people have some javascript to generate new links, with cu
+ # in them instead of closeup. This should fix that
+ $url =~ s/closeup/cu/;
# --- check (pid, row, rowspan, title) against old cached data
my $cache_id = "$date:$pid:$row:$rowspan:$title";
***************
*** 410,415 ****
--- 414,443 ----
return $want;
}
+ # --- wrapper for the deobfuscator
+ sub deobfuscate {
+ my ($input) = @_;
+ my $guidedata = $input;
+ # De-obfuscate
+ $guidedata =~ s/jz\('([^']+)'\);/jz($1)/eg;
+ # Also need to remove useless script headers
+ $guidedata =~ s/<SCRIPT src=\"dcr.js\"><\/SCRIPT><SCRIPT Language=\"Javascript\">/""/eg;
+ $guidedata =~ s/^<\/SCRIPT><NOSCRIPT>.*<\/NOSCRIPT>/""/eg;
+ return $guidedata;
+ }
+
+ # --- deobfuscator from jollygoodshow at hotmail.com contributed to
+ # mythuser list
+ sub jz {
+ my ($z) = @_;
+ my ($y);
+
+ $z =~ s/%(..)/chr(hex($1))/eg;
+ ($y = $z) =~ s/(.)/chr(ord($1) - 1)/eg;
+ $y =~ s/%(..)/chr(hex($1))/eg;
+ return $y;
+ }
+
# --- get details from the closeup page for given show
sub get_closeup_details {
***************
*** 577,582 ****
--- 605,611 ----
($page, $base) = with_progress
( "getting regionid and channels for service $service->{name}",
sub { get_content_base("$TVTODAY?channel=$service->{name}") } );
+
$service->{region} = "Australia";
($service->{regionid})
= $base =~ /_(\d+).asp/ or die "cannot find regionid";
***************
*** 691,696 ****
--- 720,726 ----
my $url = shift;
my $page = (get_content_base($url))[0];
$page and $page =~ s/ / /g;
+ $page = deobfuscate($page);
return $page;
}
More information about the mythtv-users
mailing list