1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
From 68253c3831632787164f37d61b8fb5f148ba508a Mon Sep 17 00:00:00 2001
From: Toni Gundogdu <legatvs.git@gmail.com>
Date: Sat, 18 Dec 2010 16:49:25 +0200
Subject: [PATCH] Vimeo.pm: Fix video ID parsing [#2]
- http://sourceforge.net/apps/trac/clive/ticket/2
---
lib/clive/Host/Vimeo.pm | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/lib/clive/Host/Vimeo.pm b/lib/clive/Host/Vimeo.pm
index 515ff58..e11edc9 100644
--- a/lib/clive/Host/Vimeo.pm
+++ b/lib/clive/Host/Vimeo.pm
@@ -23,29 +23,31 @@ package clive::Host::Vimeo;
use warnings;
use strict;
-sub new {
- return bless( {}, shift );
-}
+use clive::Error qw(CLIVE_REGEXP);
+
+sub new { return bless ({}, shift); }
sub parsePage {
my ( $self, $content, $props ) = @_;
$$props->video_host("vimeo");
- my %re = ( id => qr|clip_id=(.*?)[&"]|, );
+ my $id = $1 if $$props->page_link =~ /vimeo\.com\/(\d+)/;
- my $tmp;
- if ( clive::Util::matchRegExps( \%re, \$tmp, $content ) == 0 ) {
- my $config = "http://vimeo.com/moogaloop/load/clip:$tmp->{id}";
+ unless ($1) {
+ clive::Log->instance->err (CLIVE_REGEXP, "no match: video id");
+ return (1);
+ }
- if ( _parseConfig( $self, $config, $tmp->{id} ) == 0 ) {
- $$props->video_id( $tmp->{id} );
- $$props->video_link( $self->{video_link} );
+ my $config_url = "http://vimeo.com/moogaloop/load/clip:$1";
+ my $rc = _parseConfig ($self, $config_url, $1);
- return (0);
- }
+ unless ($rc) {
+ $$props->video_id ($id);
+ $$props->video_link ($self->{video_link});
}
- return (1);
+
+ return ($rc);
}
sub _parseConfig {
--
1.7.3.3
|