From: Michael Orlitzky Date: Sat, 15 Oct 2011 13:24:43 +0000 (-0400) Subject: Re-fix the Youtube itag parameter. It works in both duplicated and non-duplicated... X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fwhatever-dl.git;a=commitdiff_plain;h=6e95377fe761bb0988e6e5e27327c0f189a2ecb7;hp=3bf657c5b1de3e1a9f718212ed7090a5e073b57d Re-fix the Youtube itag parameter. It works in both duplicated and non-duplicated cases now. --- diff --git a/src/websites/youtube.rb b/src/websites/youtube.rb index f9fd05a..bdf2c2c 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -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