X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fwhatever-dl.git;a=blobdiff_plain;f=src%2Fwebsites%2Fyoutube.rb;h=bdf2c2c4ba7bd28d25ecd1a236e8534142f8d2aa;hp=f9fd05a764f0eef64e4221d24dae7b3e2ea6026f;hb=6e95377fe761bb0988e6e5e27327c0f189a2ecb7;hpb=3bf657c5b1de3e1a9f718212ed7090a5e073b57d 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