[mythtv] Hack to retrieving digital channel listings

Kirk Lapray kirk at backfence.net
Wed Jan 21 12:37:32 EST 2004


I do not yet have a tuner card, but I am looking at getting the HDTV one from pcHDTV. It has kind of bothered me that there were not any listings for digital channels available. When I found out that XMLTV used zap2it.com I visited their website and noticed that digital channel listings were available, but to view more than one channel at a time you had to sign up and create a personal channel list.  Once my channel list was correct I was able to perform a crude hack on ZapListings.pm to have it load my personal cookie.  After this I was able to have XMLTV retrieve all channel information, including the digital ones.

To get it to work you have to patch ZapListings.pm and place the cookie.txt file in /usr/local/etc. You will also have to edit the cookie.txt file with the appropriate values for your location and your user id. These values can be obtained from the tvlistings2.zap2it cookie in your cookie directory after you have gone and customized your zap2it listings. With all of this done you should now be able to have XMLTV retrieve all the channels that are listed on your personalized zap2it listings.

In the future it would be nice if there was a simple option to pass the user id into tv_grag_na and have it pull the channels without the need for a customized cookie.

I am hoping with this that MythTV can now have the channel listings it needs to better work with the pcHDTV card.

This is my first post, so please let me know what I can do in the future to make them better.

Kirk

-------------- next part --------------
--- ZapListings.pm.bak	2003-12-31 11:59:36.000000000 -0700
+++ ZapListings.pm	2004-01-21 09:17:33.849292800 -0700
@@ -678,9 +678,9 @@
     }
 }
 
-sub doRequest($$$)
+sub doRequest($$$$)
 {
-    my ($ua, $req, $debug)=@_;
+    my ($ua, $req, $cookie, $debug)=@_;
     die if not $req;
     my $cookie_jar=$ua->cookie_jar();
 
@@ -697,6 +697,9 @@
     }
 
     $cookie_jar=$ua->cookie_jar();
+    if ($cookie) {
+      $cookie_jar->load("/usr/local/etc/cookie.txt");
+    }
     if ( defined($cookie_jar) && $debug ) {
       main::statusMessage("==== response cookies ====\n".$cookie_jar->as_string()."\n");
     }
@@ -733,7 +736,7 @@
 
     my $req = GET($url);
     die "cannot make request object for $url" if not $req;
-    my $res=doRequest($ua, $req, $debug);
+    my $res=doRequest($ua, $req, 0, $debug);
     if ( !defined($res) ) {
 	return(undef);
     }
@@ -784,7 +787,7 @@
 
     my $req = GET("http://www.zap2it.com/index");
     die "cannot make request object for http://www.zap2it.com/index" if not $req;
-    my $res=&doRequest($self->{ua}, $req, $self->{Debug});
+    my $res=&doRequest($self->{ua}, $req, 0, $self->{Debug});
 
     if ( !$res->is_success ) {
         warn("request failed with code: ".$res->code().":".HTTP::Status::status_message($res->code())."\n");
@@ -821,13 +824,13 @@
 	return(-1);
     }
 
-    $res=&doRequest($self->{ua}, $req, $self->{Debug});
+    $res=&doRequest($self->{ua}, $req, 0, $self->{Debug});
 
     # looks like some requests require two identical calls since
     # the zap2it server gives us a cookie that works with the second
     if ( !$res->is_success || $res->content()=~m/your session has timed out/i ) {
 	# again.
-	$res=&doRequest($self->{ua}, $req, $self->{Debug});
+	$res=&doRequest($self->{ua}, $req, 0, $self->{Debug});
     }
 
     if ( !$res->is_success ) {
@@ -934,12 +937,12 @@
 	return(undef);
     }
 
-    my $res=&doRequest($self->{ua}, $req, $self->{Debug});
+    my $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
     warn "zap2it gave us a server error, but let's go for it anyway\n" if $res->code eq '500' and !$got500error++;
     if ( !(   $res->is_success || $res->code eq '500') || $res->content()=~m/your session has timed out/i ) {
 	# again, but manditory sleep(5) between retries
 	sleep(5);
-	$res=&doRequest($self->{ua}, $req, $self->{Debug});
+	$res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 
 	# looks like some requests require two identical calls since
 	# the zap2it server gives us a cookie that works with the second
@@ -947,7 +950,7 @@
 	if ( !$res->is_success || $res->content()=~m/your session has timed out/i ) {
 	    # again, but manditory sleep(5) between retries
 	    sleep(5);
-	    $res=&doRequest($self->{ua}, $req, $self->{Debug});
+	    $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 	}
     }
 
@@ -980,13 +983,13 @@
     $self->{formSettings}->{rowdisplay} = 0;  # All Channels
     $req = $self->Form2Request($self->{GridForm});
     die "failed to get grid form\n" if not $req;
-    $res=&doRequest($self->{ua}, $req, $self->{Debug});
+    $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 
     warn "zap2it gave us a server error, but let's go for it anyway\n" if $res->code eq '500' and !$got500error++;
     if ( !($res->is_success || $res->code eq '500') || $res->content()=~m/your session has timed out/i ) {
 	# again, but manditory sleep(5) between retries
 	sleep(5);
-	$res=&doRequest($self->{ua}, $req, $self->{Debug});
+	$res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 
 	# looks like some requests require two identical calls since
 	# the zap2it server gives us a cookie that works with the second
@@ -994,7 +997,7 @@
 	if ( !$res->is_success || $res->content()=~m/your session has timed out/i ) {
 	    # again, but manditory sleep(5) between retries
 	    sleep(5);
-	    $res=&doRequest($self->{ua}, $req, $self->{Debug});
+	    $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 	}
     }
 
@@ -2118,7 +2121,7 @@
 	    return(-1);
 	}
 	
-	my $res=&doRequest($self->{ua}, $req, $self->{Debug});
+	my $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 
 	# looks like some requests require two identical calls since
 	# the zap2it server gives us a cookie that works with the second
@@ -2127,7 +2130,7 @@
 	if ( !($res->is_success || $res->code eq '500') || $res->content()=~m/your session has timed out/i ) {
 	    # again, but manditory sleep(5) between retries
 	    sleep(5);
-	    $res=&doRequest($self->{ua}, $req, $self->{Debug});
+	    $res=&doRequest($self->{ua}, $req, 1, $self->{Debug});
 	}
 
 	warn "zap2it gave us a server error, but let's go for it anyway\n" if $res->code eq '500' and !$got500error++;
-------------- next part --------------
#LWP-Cookies-1.0
#Set ZZZZZ to ZipCode
#Set SSSSSS to System ID
#Set XXXXXXXXX to User ID
Set-Cookie3: spp=0; path="/"; domain=tvlistings2.zap2it.com; path_spec; expires="2006-01-07 06:00:00Z"; version=0
Set-Cookie3: tvqpremium="zipcode=ZZZZZ&ProvGUID=PC%3AZZZZZ&system=SSSSSS&vstrid=XXXXXXXXX"; path="/"; domain=tvlistings2.zap2it.com; path_spec; expires="2006-01-07 06:00:00Z"; version=0



More information about the mythtv-dev mailing list