Tải bản đầy đủ - 0 (trang)
Hack 44. Plan Your TV Viewing

Hack 44. Plan Your TV Viewing

Tải bản đầy đủ - 0trang

Yahoo!TVeditorsoffertheirtakeonthebestbetsfor

viewing,aswellasbriefsynopsesoftheshowsat

http://tv.yahoo.com/picks.Youcantakealookateditors'

choicesforthatdayormovebackorforwardafewdays.



TVNewsandGossip

Findoutwhat'shappeninginthetelevisionindustryand

whatTVcelebritiesareupto.Youcanevenreadabout

celebritiesattheirworstfromseveraldifferentsupermarket

tabloidsathttp://tv.yahoo.com/entgossip.



NielsenRatings

Findoutwhichshowshadthehighestnumbersofviewers

fortheweek,ascalculatedbyNielsen.You'llfindtheTop20

athttp://tv.yahoo.com/nielsen.



TVShowDatabase

Youcanlookuptelevisionshowstoreadabriefsynopsis,

seephotographsoftheactors,andreviewdescriptionsof

upcomingepisodes.Browsetohttp://tv.yahoo.com/dband

searchalphabeticallyorbygenre.Thedatabasecontains

listingsforshowsfromthelate1980sthroughtoday.



SoapOperaSynopses

Missanepisodeofyourfavoritesoap?Browseto

http://tv.yahoo.com/soapsandyou'llbecaughtuponwho

wassleepingwithwhomandwhethertheiramnesiahas



wornoff.



MessageBoards

DiscussshowswithotherYahoo!usersattheYahoo!

MessageBoardsbybrowsingtohttp://messages.yahoo.com

andclickingtheTVlinkunderHotTopicsontheleftsideof

thepage.YoucanalsofindmanyYahoo!Groupsdevotedto

specificprogramsorgeneralTVdiscussionat

http://tv.dir.groups.yahoo.com.



2.23.1.PersonalizeYourListings

OneofthemostusefulfeaturesispersonalizedTVlistings.To

personalizeyourlistings,bringuptheYahoo!TVsite

(http://tv.yahoo.com)andsigninwithyourYahoo!ID[Hack

#3]byclickingtheSignInlinkontherightsideofthepage.If

youdon'thaveaYahoo!ID,youcanstilltemporarily

personalizetheTVlistingsbyclickingtheMyListingslink,but

keepinmindthatyourlistingswon'tbeavailableacross

differentbrowsersandcomputersyouusewithoutsigningin,

andyouwon'tbeabletosaveyourfavoritechannels.

You'llneedtoenteryourZipCode,whichwillnarrowyour

choicesdowntocable,broadcast,andsatellitelistingsforyour

area.ChooseyourproviderfromthoselistedandclickGo!.You

shouldseelistingsforallofthechannelsyoureceive.Clickthe

CreatePersonalizedListingslinkatthetopofthepagetocreate

alistofyourfavoritechannels.Highlightachannelontheleft

andclicktheAddbutton;thechannelwillappearintheYour

Choicesboxontheright.

Youcanalsosetyourdisplaypreferencesandapreferredstart

time.Youcaneitherdisplaythefirst15,30,or45channels,or



justdisplayyourfavoritechannels.Youcanalsosetthestart

timeas7:00or8:00p.m.todisplayprime-timeshowsasyour

defaultdisplay.SettingthesepreferencesletsYahoo!know

whichlistingstoshowinMyYahoo!.

ClickFinishedandyoushouldseealistofwhat'scurrently

playingonyourfavoritechannels,asshowninFigure2-67.



Figure2-67.AscheduleofFavoriteChannelsat

Yahoo!TV



Onceyourfavoritesareset,youcanalsokeeptabsonthe

scheduleatMyYahoo!(http://my.yahoo.com).Figure2-68

showslistingsonMyYahoo!,withfavoritechannelssettobegin



at8:00p.m.

Ifyou'drathernotvisitaYahoo!websitetoviewyour

schedule,Yahoo!doesn'tofferanyoptionsforyouyet.Butwith

somePerlscripting,youcancreateyourownoptions.



2.23.2.EmailYourListings

Ifyou'remoreofanemailpersonthanawebpersonandprefer

toreadinformationinyourinboxinsteadofabrowser,some

quickscriptingcantakecareofthatforyou.Thishackrelieson

screenscrapingtogatherdata,andtheusualcaveatsapply,

becauseanychangetotheHTMLthatYahoo!usestodisplayTV

listingscouldbreakthisscript.Beawarethatyoumightneedto

tweakthiscodefromtimetotime.



Figure2-68.TheTVListingsmoduleatMyYahoo!



Torunthishack,you'llneedyourYahoo!TVpersonalized

listingsURLandacomputerthatcanrunPerlscripts.Ifyou



haven'talreadypersonalizedyourlistings,you'llneedtoback

upandsetyourlocationandTVprovider.Onceit'ssetup,

browsetotheYahoo!TVfrontpage(http://tv.yahoo.com)and

clickontheMyPersonalizedListingslinkatthetopofthepage.

NotetheURLinyourbrowser'saddressbar.Itshouldlook

somethinglikethis:





http://tv.yahoo.com/grid?lineup=us_OR36403&zip=97333



You'llneedtoaddthisURLtothecodesothescriptknows

wheretogetyourlistings.



2.23.2.1.Thecode.

Thiscodeusesthreemodulesthatyoumightneedtoinstall.

LWP::SimplehandlesfetchingtheTVlistingsandNet::SMTPsends

theemailthescriptbuilds.Asyou'dexpect,Date::Formathandles

somesimpledateformatting.



Thisscriptdoesn'tactuallylogintoyourYahoo!account,soyouwon't

seeyourfavoritechannelsintheemail.Instead,you'llseeallofthe

channelsfromyourcable,satellite,orbroadcastlistings.



Savethefollowingcodetoafilecalledwhats_on.plandinclude

yourpersonalizedlistingsURL,yourmailserver,andyouremail

address.Youcanalsochangethevalueof$starthourtoget

listingsforanothertimeofday.It'ssetto20,whichis8:00

p.m.ona24-hourclock,andthiswillgiveyoulistingsfor

prime-timeshows.















#!/usr/bin/perl

#whats_on.pl

#AscripttodownloadaYahoo!TVschedule

#andsenditviaemail

#Usage:whats_on.pl













usestrict;

useLWP::Simple;

useNet::SMTP;

useDate::Format;









#Setyourstarttimein24-hourhhformat

my$starthour=20;











#SettheYahoo!TVURL

my$url="insertyourpersonalizedlistingsURL";

$url.="&starthour=$starthour&prt=1";















#Setemailinfo

my$subject="OnTVTonight";

my$smtp_server="insertyourmailserver";

my$from_email='insertyouremailaddress';

my$to_email='insertyouremailaddress';











#GrabtheYahoo!TVlistingspageand

my$body=get($url);

my($lastchannel,$out);























#BuildtheemailbyloopingthroughtheHTML

#andpickingouttheimportantstuff

my$regex='.*?
$regex.='.*?">(.*?).*?';

my$out="OnTVtonight--";

while($body=~m!$regex!gis){



my$channel=$1;



my$channel_f=$1;



my$time=$2;







































}



my$title=$3;

if($lastchannelne$channel){



$channel_f=~s!\+(\d{1,2})!\($1\)!;



$out.="\n\n$channel_f\n\n";

}

my$airtime=time2str("%l:%M",$time);

$out.="$airtime$title\n";

$lastchannel=$channel;





















#Sendthescheduleviaemail

my$dtm=time2str("%m%d%Y%T",time);

my$smtp=Net::SMTP->new($smtp_server);

$smtp->hello($smtp_server);

$smtp->mail($from_email);

$smtp->to($to_email);

$smtp->data();

$smtp->datasend("From:$from_email\n");





















$smtp->datasend("To:$to_email\n");

$smtp->datasend("Subject:$subject\n");

$smtp->datasend("Message-Id:tv.yahoo.com-sched-$dtm\@$

$smtp->datasend('Content-Type:text/plain;');

$smtp->datasend("\n\n");

$smtp->datasend($out);

$smtp->dataend();

$smtp->quit;









#Closeoutputfile

close(FILE);



Noticethat$urlholdsyourpersonalizedlistingsURLandaddsa

coupleofquerystringvariablesandvalues,includingstarthour

andprt=1,whichsetsthepagetothePrintableViewonYahoo!,

whichiseasiertoscrape.



The$regexvariableholdsthepatternsthescriptusestofindthe

relevantbitsofinformationintheHTML,andyoumightneedto

adjustthisregularexpressionifYahoo!modifiestheirHTML.



2.23.2.2.Runningthehack.

Torunthisscriptonce,youcanjustcallitfromthecommand

line,likethis:





perlwhats_on.pl



Toreallytakeadvantageofthescript,setittorundailywith

theWindowsSchedulerorbyaddingacronjobonUnix-based

machines.Onceset,you'llreceivedailyemailsliketheone

showninFigure2-69,withtheprime-timeTVschedulelistedby

channel.



Figure2-69.TVlistingsemail



Thetextlistingintheemailissimpleandincludesonlythe

channel,time,andprogramname.Ifyouliketoread

informationinyourinbox,though,it'sano-frillswaytofindout

what'sgoingtobeonTV.



Hack45.CreateaTVWatchList



CombineYahoo!TVwithYahoo!Calendartobuilda

customTVschedule.

Youcanfindlotsofinformationaboutupcomingtelevision

showsatYahoo!TV[Hack#44].Byclickingonaprogramtitle

inyourpersonalizedlistings,youcanfindabriefsynopsisofthe

show,membersofthecast,andevendirectorsandproducers.

And,ofcourse,Yahoo!letsyousearchthisinformation.Browse

toYahoo!TV(http://tv.yahoo.com)andyou'llseethesearch

formlabeled"SearchlistingsbyKeyword."

Imagineyou'reaTomHanksfanandyou'dliketofindoutwhen

ashowormoviehe'sbeeninwillbeon.Type"TomHanks"intothe

form,andclickGo!.Notethatthequotesareimportantwhen

you'relookingforafullphrase.You'llseealistofshowsthat

TomHanksappearsinwithinthenext14days,asshownin

Figure2-70.



Figure2-70.Yahoo!TVlistingssearchresultsfor

"TomHanks"



WhoknewhewasinoldepisodesofHappyDays?Clickatitlein

theresultsandyou'llfindthedetailpagefortheprogram.

Alongsidethechannelandairtime,you'llseean"AddtoMy

Calendar"link.Thislinkletsyouaddtheshowasaneventon

yourYahoo!Calendarsothatyoucantracktheshowsyou'dlike

towatch.Andonceashowisaneventonyourcalendar,you'll

receiveremindersabouttheeventinyouremail,whichcanhelp

youremembertocatchtheshowwhenitairs.

YoucouldrunthesearchforTomHanksyourselfeverycoupleof

weeksatYahoo!TVandaddanyprogramsthatlookinteresting.

Butthishackshowsyouhowtobelazy,lettingascriptdothe

workforyou.Infact,thishackwillrunaYahoo!TVsearchfor

anykeywordandaddeveryresulttoyourYahoo!Calendar.

ThenyoucanvisityourYahoo!Calendarperiodicallytosee

whatYahoo!hassuggestedthatyouviewbasedonyour



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 44. Plan Your TV Viewing

Tải bản đầy đủ ngay(0 tr)

×