]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/commitdiff
Updated the Youtube URL regex to allow any hostname.youtube.com pattern.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 2 Mar 2009 00:14:09 +0000 (19:14 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 2 Mar 2009 00:14:09 +0000 (19:14 -0500)
Added a test to ensure that uk.youtube.com URLs are handled properly.

src/websites/youtube.rb
test/youtube_test.rb

index 3388100769b689b94e7b7ed6ef1e398ab2694f7e..cbda4e27d77d0ac1001b87ba83753cf8b8dc5175 100644 (file)
@@ -26,7 +26,7 @@ require 'uri'
 
 class Youtube < Website
 
-  VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?(www\.)?(in\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i
+  VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i
   
   def self.owns_url?(url)
     return url =~ VALID_YOUTUBE_URL_REGEX
index 507e43e3dbebcf7ed89a64ae8bd441272d6e44de..fa61cb27feb12087e676318cb37cc6f497705c9a 100644 (file)
@@ -34,6 +34,7 @@ class YoutubeTest < Test::Unit::TestCase
     assert(Youtube.owns_url?('http://www.youtube.com/watch?v=83-hlYMH1XE'))
     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'))
   end