From 175ca8d76aa24dd2bd58d165eebc5463f6ac96aa Mon Sep 17 00:00:00 2001 From: legatvs Date: Sat, 13 Jun 2009 00:45:34 +0300 Subject: [PATCH] Fix: Redtube video title parsing. --- CHANGES | 2 ++ lib/clive/Host/Redtube.pm | 13 ++++++++++--- lib/clive/Video.pm | 18 +++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index c74012d..4be76ae 100644 --- a/CHANGES +++ b/CHANGES @@ -77,6 +77,8 @@ SUMMARY of CHANGES --savedir="/home/user/videos" ----------------------------------------------- + * Fix: Redtube video title parsing + * Cache changes 1. Cache is now passive (read:no, write:yes) 2. Add: --cache- option prefix diff --git a/lib/clive/Host/Redtube.pm b/lib/clive/Host/Redtube.pm index be2068c..23a6991 100644 --- a/lib/clive/Host/Redtube.pm +++ b/lib/clive/Host/Redtube.pm @@ -48,7 +48,10 @@ sub parsePage { return substr( $foo, $digit, 1 ); } - my %re = ( id => qr|videoid=(.*?)'| ); + my %re = ( + id => qr|videoid=(.*?)'|, + title => qr|videotitle'>(.*?)video_id($id); $$props->video_link($xurl); + # no longer contains the video title. Use the string + # extracted from the html instead. + $$props->page_title(undef, $tmp->{title}); + return (0); } return (1); diff --git a/lib/clive/Video.pm b/lib/clive/Video.pm index abfd7a5..90176fd 100644 --- a/lib/clive/Video.pm +++ b/lib/clive/Video.pm @@ -58,13 +58,17 @@ sub new { sub page_title { my $self = shift; if (@_) { - require HTML::TokeParser; - my $content = shift; - - my $p = HTML::TokeParser->new($content); - $p->get_tag("title"); - $self->{page_title} = $p->get_trimmed_text; - _cleanupTitle($self); + my ($content, $title) = @_; + if (!$title) { + require HTML::TokeParser; + my $p = HTML::TokeParser->new($content); + $p->get_tag("title"); + $self->{page_title} = $p->get_trimmed_text; + _cleanupTitle($self); + } + else { + $self->{page_title} = $title; + } } return $self->{page_title}; } -- 2.11.4.GIT