]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/commitdiff
Re-fix the Youtube itag parameter. It works in both duplicated and non-duplicated...
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 15 Oct 2011 13:24:43 +0000 (09:24 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 15 Oct 2011 13:24:43 +0000 (09:24 -0400)
src/websites/youtube.rb

index f9fd05a764f0eef64e4221d24dae7b3e2ea6026f..bdf2c2c4ba7bd28d25ecd1a236e8534142f8d2aa 100644 (file)
@@ -74,8 +74,14 @@ class Youtube < Website
       fmt_streams = get_fmt_stream_list(page_data)
       video_url = self.choose_best_fmt_stream_url(fmt_streams)
 
-      # The "itag" parameter makes the 403 happen.
-      video_url.gsub!(/itag=\d+&/, '')
+      # A duplicated "itag" parameter results in a 403.
+      itag_regex = /&itag=\d+/
+      matches = video_url.scan(itag_regex)
+
+      if matches.length > 1
+        # Get rid of the first occurrence.
+        video_url.sub!(itag_regex, '')
+      end
     end
 
     return video_url