From: Michael Orlitzky Date: Wed, 31 Mar 2010 18:56:21 +0000 (-0400) Subject: Added a new URL format for the Youtube class. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=3dbd698397f041569cb729822a5ea7e909af62a5;p=dead%2Fwhatever-dl.git Added a new URL format for the Youtube class. Created a test for the new URL format. --- diff --git a/src/websites/youtube.rb b/src/websites/youtube.rb index 532d8ca..ee9a115 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -21,7 +21,7 @@ require 'cgi' class Youtube < Website - VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i + VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/)|([a-z]+\#[a-z]\/[a-z]\/[0-9]\/))[a-z0-9_\-]+(\&.*)?\#?$/i def self.owns_url?(url) return url =~ VALID_YOUTUBE_URL_REGEX diff --git a/test/youtube_test.rb b/test/youtube_test.rb index ec91d35..ab92f2d 100644 --- a/test/youtube_test.rb +++ b/test/youtube_test.rb @@ -35,6 +35,7 @@ class YoutubeTest < Test::Unit::TestCase assert(Youtube.owns_url?('http://www.youtube.com/watch?v=83-hlYMH1XE&feature=dir')) assert(Youtube.owns_url?('http://in.youtube.com/watch?v=VcydqSpYN00&feature=channel_page')) assert(Youtube.owns_url?('http://uk.youtube.com/watch?v=LN4Ov6ZLcrI')) + assert(Youtube.owns_url?('http://www.youtube.com/meetlocalbiz#p/u/0/rJVWV4aA6Jk')) end