From 6e95377fe761bb0988e6e5e27327c0f189a2ecb7 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 Oct 2011 09:24:43 -0400 Subject: [PATCH] Re-fix the Youtube itag parameter. It works in both duplicated and non-duplicated cases now. --- src/websites/youtube.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 -- 2.43.2