| 1 | ################################################################################# | ||
| 2 | #########This Perl module represents the CPAN name space Net::Hulu.############## | ||
| 3 | ####################Written by Gerald L. Hevener, M.S.########################### | ||
| 4 | ##############AKA: jackl0phty in the whitehat hacker community.################## | ||
| 5 | #########This module is licensed under the same terms as Perl itself.############ | ||
| 6 | #########Maintainer's Email: hevenerg {[AT]} marshall {[DOT]} edu.############## | ||
| 7 | #After years of using free (as in beer) software, thought I'd try to give back. # | ||
| 8 | ################################################################################# | ||
| 9 | |||
| 10 | # declare package name | ||
| 11 | package Net::Hulu; | ||
| 12 | |||
| 13 | 3 | ▶ | use 5.006000; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 3 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 0 | ▶ | use XML::Twig; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 18 | use LWP::Simple; | ||
| 19 | |||
| 20 | require Exporter; | ||
| 21 | |||
| 22 | our @ISA = qw(Exporter); | ||
| 23 | |||
| 24 | # Items to export into callers namespace by default. Note: do not export | ||
| 25 | # names by default without a very good reason. Use EXPORT_OK instead. | ||
| 26 | # Do not simply export all your public functions/methods/constants. | ||
| 27 | |||
| 28 | # This allows declaration use Net::Hulu ':all'; | ||
| 29 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||
| 30 | # will save memory. | ||
| 31 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
| 32 | |||
| 33 | ) ] ); | ||
| 34 | |||
| 35 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
| 36 | |||
| 37 | our @EXPORT = qw( | ||
| 38 | get_recent_videos get_recent_shows get_recent_movies get_highest_rated_videos | ||
| 39 | get_popular_videos_today get_popular_videos_this_week | ||
| 40 | get_popular_videos_this_month get_popular_videos_all_time | ||
| 41 | get_soon_to_expire_videos get_recent_blog_postings download_recent_videos_xml | ||
| 42 | download_recent_shows_xml download_recent_movies_xml download_highest_rated_videos_xml | ||
| 43 | download_popular_videos_today_xml download_popular_videos_this_week_xml | ||
| 44 | download_popular_videos_this_month_xml download_popular_videos_all_time_xml | ||
| 45 | download_soon_to_expire_videos_xml download_recent_blog_postings_xml | ||
| 46 | ); | ||
| 47 | |||
| 48 | our $VERSION = '0.03'; | ||
| 49 | |||
| 50 | # declare variables for recent videos | ||
| 51 | my $recent_videos_url = "http://rss.hulu.com/HuluRecentlyAddedVideos?format=xml"; | ||
| 52 | my $recent_videos_root; | ||
| 53 | my $recent_videos_xml; | ||
| 54 | my $recent_videos_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 55 | |||
| 56 | # declare variables for recent shows | ||
| 57 | my $recent_shows_url = "http://rss.hulu.com/HuluRecentlyAddedShows?format=xml"; | ||
| 58 | my $recent_shows_root; | ||
| 59 | my $recent_shows_xml; | ||
| 60 | my $recent_shows_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 61 | |||
| 62 | # declare variables for recent movies | ||
| 63 | my $recent_movies_url = "http://rss.hulu.com/HuluRecentlyAddedMovies?format=xml"; | ||
| 64 | my $recent_movies_root; | ||
| 65 | my $recent_movies_xml; | ||
| 66 | my $recent_movies_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 67 | |||
| 68 | # declare variables for highest rated videos | ||
| 69 | my $highest_rated_videos_url = "http://www.hulu.com/feed/highest_rated/videos"; | ||
| 70 | my $highest_rated_videos_root; | ||
| 71 | my $highest_rated_videos_xml; | ||
| 72 | my $highest_rated_videos_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 73 | |||
| 74 | # declare variables for popular videos today | ||
| 75 | my $popular_videos_today_url = "http://rss.hulu.com/HuluPopularVideosToday?format=xml"; | ||
| 76 | my $popular_videos_today_root; | ||
| 77 | my $popular_videos_today_xml; | ||
| 78 | my $popular_videos_today_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 79 | |||
| 80 | # declare variables for popular videos this week | ||
| 81 | my $popular_videos_this_week_url = "http://rss.hulu.com/HuluPopularVideosThisWeek?format=xml"; | ||
| 82 | my $popular_videos_this_week_root; | ||
| 83 | my $popular_videos_this_week_xml; | ||
| 84 | my $popular_videos_this_week_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 85 | |||
| 86 | # declare variables for popular videos this month | ||
| 87 | my $popular_videos_this_month_url = "http://rss.hulu.com/HuluPopularVideosThisMonth?format=xml"; | ||
| 88 | my $popular_videos_this_month_root; | ||
| 89 | my $popular_videos_this_month_xml; | ||
| 90 | my $popular_videos_this_month_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 91 | |||
| 92 | # declare variables for popular videos of all time | ||
| 93 | my $popular_videos_all_time_url = "http://rss.hulu.com/HuluPopularVideosAllTime?format=xml"; | ||
| 94 | my $popular_videos_all_time_root; | ||
| 95 | my $popular_videos_all_time_xml; | ||
| 96 | my $popular_videos_all_time_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 97 | |||
| 98 | # declare variables for soon to expire videos | ||
| 99 | my $soon_to_expire_videos_url = "http://www.hulu.com/feed/expiring/videos"; | ||
| 100 | my $soon_to_expire_videos_root; | ||
| 101 | my $soon_to_expire_videos_xml; | ||
| 102 | my $soon_to_expire_videos_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 103 | |||
| 104 | # declare variables for recent blog postings | ||
| 105 | my $recent_blog_postings_url = "http://rss.hulu.com/HuluBlog?format=xml"; | ||
| 106 | my $recent_blog_postings_root; | ||
| 107 | my $recent_blog_postings_xml; | ||
| 108 | my $recent_blog_postings_twig = new XML::Twig(TwigRoots => {'item' => 1, pretty_print => 'indented'}); | ||
| 109 | |||
| 110 | # preloaded methods go here. | ||
| 111 | ######################Begin Primary Subroutines########################## | ||
| 112 | |||
| 113 | sub get_recent_videos { | ||
| 114 | |||
| 115 | #Turn on strict and warnings. | ||
| 116 | use strict; | ||
| 117 | use warnings; | ||
| 118 | |||
| 119 | $recent_videos_twig->parsefile("HuluRecentlyAddedVideos?format=xml"); | ||
| 120 | |||
| 121 | #set root of the twig (channel). | ||
| 122 | $recent_videos_root = $recent_videos_twig->root; | ||
| 123 | |||
| 124 | #get recent videos titles. | ||
| 125 | foreach my $recent_videos_titles ($recent_videos_root->children('item')) { | ||
| 126 | |||
| 127 | print $recent_videos_titles->first_child_text('title'); | ||
| 128 | print "\n"; | ||
| 129 | } | ||
| 130 | |||
| 131 | # sub get_recent_videos() | ||
| 132 | } | ||
| 133 | |||
| 134 | sub get_recent_shows { | ||
| 135 | |||
| 136 | #Turn on strict and warnings. | ||
| 137 | use strict; | ||
| 138 | use warnings; | ||
| 139 | |||
| 140 | #parse xml file for recent shows. | ||
| 141 | $recent_shows_twig->parsefile("HuluRecentlyAddedShows?format=xml"); | ||
| 142 | |||
| 143 | #set root of the twig (channel). | ||
| 144 | $recent_shows_root = $recent_shows_twig->root; | ||
| 145 | |||
| 146 | #get recent videos titles. | ||
| 147 | foreach my $recent_shows_titles ($recent_shows_root->children('item')) { | ||
| 148 | |||
| 149 | print $recent_shows_titles->first_child_text('title'); | ||
| 150 | print "\n"; | ||
| 151 | } | ||
| 152 | |||
| 153 | # sub get_recent_shows() | ||
| 154 | } | ||
| 155 | |||
| 156 | sub get_recent_movies { | ||
| 157 | |||
| 158 | #Turn on strict and warnings. | ||
| 159 | use strict; | ||
| 160 | use warnings; | ||
| 161 | |||
| 162 | #parse xml file for recent movies. | ||
| 163 | $recent_movies_twig->parsefile("HuluRecentlyAddedMovies?format=xml"); | ||
| 164 | |||
| 165 | #set root of the twig (channel). | ||
| 166 | $recent_movies_root = $recent_movies_twig->root; | ||
| 167 | |||
| 168 | #get recent movies titles. | ||
| 169 | foreach my $recent_movies_titles ($recent_movies_root->children('item')) { | ||
| 170 | |||
| 171 | print $recent_movies_titles->first_child_text('title'); | ||
| 172 | print "\n"; | ||
| 173 | } | ||
| 174 | |||
| 175 | # sub get_recent_movies() | ||
| 176 | } | ||
| 177 | |||
| 178 | sub get_highest_rated_videos { | ||
| 179 | |||
| 180 | #Turn on strict and warnings. | ||
| 181 | use strict; | ||
| 182 | use warnings; | ||
| 183 | |||
| 184 | #parse xml file for highest rated videos. | ||
| 185 | $highest_rated_videos_twig->parsefile("videos"); | ||
| 186 | |||
| 187 | #set root of the twig (channel). | ||
| 188 | $highest_rated_videos_root = $highest_rated_videos_twig->root; | ||
| 189 | |||
| 190 | #get highest rated videos. | ||
| 191 | foreach my $highest_rated_videos_titles ($highest_rated_videos_root->children('item')) { | ||
| 192 | |||
| 193 | print $highest_rated_videos_titles->first_child_text('title'); | ||
| 194 | print "\n"; | ||
| 195 | } | ||
| 196 | |||
| 197 | # sub get_highest_rated_videos() | ||
| 198 | } | ||
| 199 | |||
| 200 | sub get_popular_videos_today { | ||
| 201 | |||
| 202 | #Turn on strict and warnings. | ||
| 203 | use strict; | ||
| 204 | use warnings; | ||
| 205 | |||
| 206 | #parse xml file for popular videos today. | ||
| 207 | $popular_videos_today_twig->parsefile("HuluPopularVideosToday?format=xml"); | ||
| 208 | |||
| 209 | #set root of the twig (channel). | ||
| 210 | $popular_videos_today_root = $popular_videos_today_twig->root; | ||
| 211 | |||
| 212 | #get popular videos today. | ||
| 213 | foreach my $popular_videos_today_titles ($popular_videos_today_root->children('item')) { | ||
| 214 | |||
| 215 | print $popular_videos_today_titles->first_child_text('title'); | ||
| 216 | print "\n"; | ||
| 217 | } | ||
| 218 | |||
| 219 | # sub get_popular_videos_today() | ||
| 220 | } | ||
| 221 | |||
| 222 | sub get_popular_videos_this_week { | ||
| 223 | |||
| 224 | #Turn on strict and warnings. | ||
| 225 | use strict; | ||
| 226 | use warnings; | ||
| 227 | |||
| 228 | #parse xml file for popular videos this week. | ||
| 229 | $popular_videos_this_week_twig->parsefile("HuluPopularVideosThisWeek?format=xml"); | ||
| 230 | |||
| 231 | #set root of the twig (channel). | ||
| 232 | $popular_videos_this_week_root = $popular_videos_this_week_twig->root; | ||
| 233 | |||
| 234 | #get popular videos this week. | ||
| 235 | foreach my $popular_videos_this_week_titles ($popular_videos_this_week_root->children('item')) { | ||
| 236 | |||
| 237 | print $popular_videos_this_week_titles->first_child_text('title'); | ||
| 238 | print "\n"; | ||
| 239 | } | ||
| 240 | |||
| 241 | # sub get_popular_videos_this_week() | ||
| 242 | } | ||
| 243 | |||
| 244 | sub get_popular_videos_this_month { | ||
| 245 | |||
| 246 | #Turn on strict and warnings. | ||
| 247 | use strict; | ||
| 248 | use warnings; | ||
| 249 | |||
| 250 | #parse xml file for popular videos this month. | ||
| 251 | $popular_videos_this_month_twig->parsefile("HuluPopularVideosThisMonth?format=xml"); | ||
| 252 | |||
| 253 | #set root of the twig (channel). | ||
| 254 | $popular_videos_this_month_root = $popular_videos_this_month_twig->root; | ||
| 255 | |||
| 256 | #get popular videos this month. | ||
| 257 | foreach my $popular_videos_this_month_titles ($popular_videos_this_month_root->children('item')) { | ||
| 258 | |||
| 259 | print $popular_videos_this_month_titles->first_child_text('title'); | ||
| 260 | print "\n"; | ||
| 261 | } | ||
| 262 | |||
| 263 | # sub get_popular_videos_this_month() | ||
| 264 | } | ||
| 265 | |||
| 266 | sub get_popular_videos_all_time { | ||
| 267 | |||
| 268 | #Turn on strict and warnings. | ||
| 269 | use strict; | ||
| 270 | use warnings; | ||
| 271 | |||
| 272 | #parse xml file for popular videos of all time. | ||
| 273 | $popular_videos_all_time_twig->parsefile("HuluPopularVideosAllTime?format=xml"); | ||
| 274 | |||
| 275 | #set root of the twig (channel) | ||
| 276 | $popular_videos_all_time_root = $popular_videos_all_time_twig->root; | ||
| 277 | |||
| 278 | #get popular videos all time | ||
| 279 | foreach my $popular_videos_all_time_titles ($popular_videos_all_time_root->children('item')) { | ||
| 280 | |||
| 281 | print $popular_videos_all_time_titles->first_child_text('title'); | ||
| 282 | print "\n"; | ||
| 283 | } | ||
| 284 | |||
| 285 | # sub get_popular_videos_all_time() | ||
| 286 | } | ||
| 287 | |||
| 288 | sub get_soon_to_expire_videos { | ||
| 289 | |||
| 290 | #Turn on strict and warnings. | ||
| 291 | use strict; | ||
| 292 | use warnings; | ||
| 293 | |||
| 294 | #parse xml file for soon to expire videos. | ||
| 295 | $soon_to_expire_videos_twig->parsefile("videos.1"); | ||
| 296 | |||
| 297 | #set root of the twig (channel). | ||
| 298 | $soon_to_expire_videos_root = $soon_to_expire_videos_twig->root; | ||
| 299 | |||
| 300 | #get soon to expire videos. | ||
| 301 | foreach my $soon_to_expire_videos_titles ($soon_to_expire_videos_root->children('item')) { | ||
| 302 | |||
| 303 | print $soon_to_expire_videos_titles->first_child_text('title'); | ||
| 304 | print "\n"; | ||
| 305 | } | ||
| 306 | |||
| 307 | # sub get_soon_to_expire_videos() | ||
| 308 | } | ||
| 309 | |||
| 310 | sub get_recent_blog_postings { | ||
| 311 | |||
| 312 | #Turn on strict and warnings. | ||
| 313 | use strict; | ||
| 314 | use warnings; | ||
| 315 | |||
| 316 | #parse xml file for hulu's recent blog postings. (Hulu's primary RSS feed). | ||
| 317 | $recent_blog_postings_twig->parsefile("HuluBlog?format=xml"); | ||
| 318 | |||
| 319 | #set root of the twig (channel). | ||
| 320 | $recent_blog_postings_root = $recent_blog_postings_twig->root; | ||
| 321 | |||
| 322 | #get hulu's recent blog postings | ||
| 323 | foreach my $recent_blog_postings_titles ($recent_blog_postings_root->children('item')) { | ||
| 324 | |||
| 325 | print $recent_blog_postings_titles->first_child_text('title'); | ||
| 326 | print "\n"; | ||
| 327 | } | ||
| 328 | |||
| 329 | # sub get_recent_blog_postings() | ||
| 330 | } | ||
| 331 | |||
| 332 | ######################End of primary subroutines########################## | ||
| 333 | |||
| 334 | ########Begin subroutines that download XML RSS feeds from Hulu########### | ||
| 335 | |||
| 336 | sub download_recent_videos_xml { | ||
| 337 | |||
| 338 | #Turn on strict and warnings. | ||
| 339 | use strict; | ||
| 340 | use warnings; | ||
| 341 | |||
| 342 | #get xml using LWP::Simple. | ||
| 343 | $recent_videos_xml = get $recent_videos_url; | ||
| 344 | |||
| 345 | #get rid of non-ascii chars. | ||
| 346 | $recent_videos_xml =~ s/[^[:ascii:]]+//g; | ||
| 347 | |||
| 348 | #save XML to file. | ||
| 349 | open( my $RECENT_VIDEOS_FH, ">", "HuluRecentlyAddedVideos?format=xml" ) or confess "Can't open file: $!"; | ||
| 350 | |||
| 351 | #print recent videos to file in PWD. | ||
| 352 | print $RECENT_VIDEOS_FH "$recent_videos_xml"; | ||
| 353 | |||
| 354 | close($RECENT_VIDEOS_FH); | ||
| 355 | |||
| 356 | # sub download_recent_videos_xml() | ||
| 357 | } | ||
| 358 | |||
| 359 | sub download_recent_shows_xml { | ||
| 360 | |||
| 361 | #Turn on strict and warnings. | ||
| 362 | use strict; | ||
| 363 | use warnings; | ||
| 364 | |||
| 365 | #get xml using LWP::Simple. | ||
| 366 | $recent_shows_xml = get $recent_shows_url; | ||
| 367 | |||
| 368 | #get rid of non-ascii chars. | ||
| 369 | $recent_shows_xml =~ s/[^[:ascii:]]+//g; | ||
| 370 | |||
| 371 | #save XML to file. | ||
| 372 | open( my $RECENT_SHOWS_FH, ">", "HuluRecentlyAddedShows?format=xml" ) or confess "Can't open file: $!"; | ||
| 373 | |||
| 374 | #print recent shows to file in PWD. | ||
| 375 | print $RECENT_SHOWS_FH "$recent_shows_xml"; | ||
| 376 | |||
| 377 | close($RECENT_SHOWS_FH); | ||
| 378 | |||
| 379 | # sub download_recent_shows_xml() | ||
| 380 | } | ||
| 381 | |||
| 382 | sub download_recent_movies_xml { | ||
| 383 | |||
| 384 | #Turn on strict and warnings. | ||
| 385 | use strict; | ||
| 386 | use warnings; | ||
| 387 | |||
| 388 | #get xml using LWP::Simple. | ||
| 389 | $recent_movies_xml = get $recent_movies_url; | ||
| 390 | |||
| 391 | #get rid of non-ascii chars. | ||
| 392 | $recent_movies_xml =~ s/[^[:ascii:]]+//g; | ||
| 393 | |||
| 394 | #save XML to file. | ||
| 395 | open( my $RECENT_MOVIES_FH, ">", "HuluRecentlyAddedMovies?format=xml" ) or confess "Can't open file: $!"; | ||
| 396 | |||
| 397 | #print recent movies to file in PWD. | ||
| 398 | print $RECENT_MOVIES_FH "$recent_movies_xml"; | ||
| 399 | |||
| 400 | close($RECENT_MOVIES_FH); | ||
| 401 | |||
| 402 | # sub download_recent_movies(). | ||
| 403 | } | ||
| 404 | |||
| 405 | sub download_highest_rated_videos_xml { | ||
| 406 | |||
| 407 | #Turn on strict and warnings. | ||
| 408 | use strict; | ||
| 409 | use warnings; | ||
| 410 | |||
| 411 | #get xml using LWP::Simple. | ||
| 412 | $highest_rated_videos_xml = get $highest_rated_videos_url; | ||
| 413 | |||
| 414 | #get rid of non-ascii chars. | ||
| 415 | $highest_rated_videos_xml =~ s/[^[:ascii:]]+//g; | ||
| 416 | |||
| 417 | #save XML to file. | ||
| 418 | open( my $HIGHEST_RATED_VIDEOS_FH, ">", "videos" ) or confess "Can't open file: $!"; | ||
| 419 | |||
| 420 | #print highest rated videos to file in PWD. | ||
| 421 | print $HIGHEST_RATED_VIDEOS_FH "$highest_rated_videos_xml"; | ||
| 422 | |||
| 423 | close($HIGHEST_RATED_VIDEOS_FH); | ||
| 424 | |||
| 425 | # sub download_highest_rated_videos_xml(). | ||
| 426 | } | ||
| 427 | |||
| 428 | sub download_popular_videos_today_xml { | ||
| 429 | |||
| 430 | #Turn on strict and warnings. | ||
| 431 | use strict; | ||
| 432 | use warnings; | ||
| 433 | |||
| 434 | #get xml using LWP::Simple. | ||
| 435 | $popular_videos_today_xml = get $popular_videos_today_url; | ||
| 436 | |||
| 437 | #get rid of non-ascii chars. | ||
| 438 | $popular_videos_today_xml =~ s/[^[:ascii:]]+//g; | ||
| 439 | |||
| 440 | #save XML to file. | ||
| 441 | open( my $POPULAR_VIDEOS_TODAY_FH, ">", "HuluPopularVideosToday?format=xml" ) or confess "Can't open file: $!"; | ||
| 442 | |||
| 443 | #print popular videos for today to file in PWD. | ||
| 444 | print $POPULAR_VIDEOS_TODAY_FH "$popular_videos_today_xml"; | ||
| 445 | |||
| 446 | close($POPULAR_VIDEOS_TODAY_FH); | ||
| 447 | |||
| 448 | # sub download_popular_videos_today_xml. | ||
| 449 | } | ||
| 450 | |||
| 451 | sub download_popular_videos_this_week_xml { | ||
| 452 | |||
| 453 | #Turn on strict and warnings. | ||
| 454 | use strict; | ||
| 455 | use warnings; | ||
| 456 | |||
| 457 | #get xml using LWP::Simple. | ||
| 458 | $popular_videos_this_week_xml = get $popular_videos_this_week_url; | ||
| 459 | |||
| 460 | #get rid of non-ascii chars. | ||
| 461 | $popular_videos_this_week_xml =~ s/[^[:ascii:]]+//g; | ||
| 462 | |||
| 463 | #save XML to file. | ||
| 464 | open( my $POPULAR_VIDEOS_THIS_WEEK_FH, ">", "HuluPopularVideosThisWeek?format=xml" ) or confess "Can't open file: $!"; | ||
| 465 | |||
| 466 | #print popular videos for this week to file in PWD. | ||
| 467 | print $POPULAR_VIDEOS_THIS_WEEK_FH "$popular_videos_this_week_xml"; | ||
| 468 | |||
| 469 | close($POPULAR_VIDEOS_THIS_WEEK_FH); | ||
| 470 | |||
| 471 | # sub download_popular_videos_this_week(). | ||
| 472 | } | ||
| 473 | |||
| 474 | sub download_popular_videos_this_month_xml { | ||
| 475 | |||
| 476 | #Turn on strict and warnings. | ||
| 477 | use strict; | ||
| 478 | use warnings; | ||
| 479 | |||
| 480 | #get xml using LWP::Simple. | ||
| 481 | $popular_videos_this_month_xml = get $popular_videos_this_month_url; | ||
| 482 | |||
| 483 | #get rid of non-ascii chars. | ||
| 484 | $popular_videos_this_month_xml =~ s/[^[:ascii:]]+//g; | ||
| 485 | |||
| 486 | #save XML to file. | ||
| 487 | open( my $POPULAR_VIDEOS_THIS_MONTH_FH, ">", "HuluPopularVideosThisMonth?format=xml" ) or confess "Can't open file: $!"; | ||
| 488 | |||
| 489 | #print popular videos for this month to file in PWD. | ||
| 490 | print $POPULAR_VIDEOS_THIS_MONTH_FH "$popular_videos_this_month_xml"; | ||
| 491 | |||
| 492 | close($POPULAR_VIDEOS_THIS_MONTH_FH); | ||
| 493 | |||
| 494 | # sub download_popular_videos_this_month(). | ||
| 495 | } | ||
| 496 | |||
| 497 | sub download_popular_videos_all_time_xml { | ||
| 498 | |||
| 499 | #Turn on strict and warnings. | ||
| 500 | use strict; | ||
| 501 | use warnings; | ||
| 502 | |||
| 503 | #get xml using LWP::Simple. | ||
| 504 | $popular_videos_all_time_xml = get $popular_videos_all_time_url; | ||
| 505 | |||
| 506 | #get rid of non-ascii chars. | ||
| 507 | $popular_videos_all_time_xml =~ s/[^[:ascii:]]+//g; | ||
| 508 | |||
| 509 | #save XML to file. | ||
| 510 | open( my $POPULAR_VIDEOS_ALL_TIME_FH, ">", "HuluPopularVideosAllTime?format=xml" ) or confess "Can't open file: $!"; | ||
| 511 | |||
| 512 | #print popular videos of all time to file in PWD. | ||
| 513 | print $POPULAR_VIDEOS_ALL_TIME_FH "$popular_videos_all_time_xml"; | ||
| 514 | |||
| 515 | close($POPULAR_VIDEOS_ALL_TIME_FH); | ||
| 516 | |||
| 517 | # sub download_popular_videos_all_time_xml() | ||
| 518 | } | ||
| 519 | |||
| 520 | sub download_soon_to_expire_videos_xml { | ||
| 521 | |||
| 522 | #Turn on strict and warnings. | ||
| 523 | use strict; | ||
| 524 | use warnings; | ||
| 525 | |||
| 526 | #get xml using LWP::Simple. | ||
| 527 | $soon_to_expire_videos_xml = get $soon_to_expire_videos_url; | ||
| 528 | |||
| 529 | #get rid of non-ascii chars. | ||
| 530 | $soon_to_expire_videos_xml =~ s/[^[:ascii:]]+//g; | ||
| 531 | |||
| 532 | #save XML to file. | ||
| 533 | open( my $SOON_TO_EXPIRE_VIDEOS_FH, ">", "videos" ) or confess "Can't open file: $!"; | ||
| 534 | |||
| 535 | #print soon to expire videos to file in PWD. | ||
| 536 | print $SOON_TO_EXPIRE_VIDEOS_FH "$soon_to_expire_videos_xml"; | ||
| 537 | |||
| 538 | close($SOON_TO_EXPIRE_VIDEOS_FH); | ||
| 539 | |||
| 540 | # sub download_soon_to_expire_videos_xml(). | ||
| 541 | } | ||
| 542 | |||
| 543 | sub download_recent_blog_postings_xml { | ||
| 544 | |||
| 545 | #Turn on strict and warnings. | ||
| 546 | use strict; | ||
| 547 | use warnings; | ||
| 548 | |||
| 549 | #get xml using LWP::Simple. | ||
| 550 | $recent_blog_postings_xml = get $recent_blog_postings_url; | ||
| 551 | |||
| 552 | #get rid of non-ascii chars. | ||
| 553 | $recent_blog_postings_xml =~ s/[^[:ascii:]]+//g; | ||
| 554 | |||
| 555 | #save XML to file. | ||
| 556 | open( my $RECENT_BLOG_POSTINGS_FH, ">", "HuluBlog?format=xml" ) or confess "Can't open file: $!"; | ||
| 557 | |||
| 558 | #print recent blog postings to file in PWD. | ||
| 559 | print $RECENT_BLOG_POSTINGS_FH "$recent_blog_postings_xml"; | ||
| 560 | |||
| 561 | close($RECENT_BLOG_POSTINGS_FH); | ||
| 562 | |||
| 563 | # sub download_recent_blog_postings_xml(). | ||
| 564 | } | ||
| 565 | |||
| 566 | # Modules must return a true value | ||
| 567 | 1; | ||