X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fwhatever-dl.git;a=blobdiff_plain;f=src%2Fwebsites%2Fyoutube.rb;h=2ab4678c11dae6660c0128765281eefffd38e61b;hp=bdf2c2c4ba7bd28d25ecd1a236e8534142f8d2aa;hb=8e886df259246365023322b78f58e4037cb536a4;hpb=34e42ad8644d4f25b2dc3734abf7407055e9992c diff --git a/src/websites/youtube.rb b/src/websites/youtube.rb index bdf2c2c..2ab4678 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -67,7 +67,7 @@ class Youtube < Website # fmt_url_map hash. video_url = fmt_url_map[desired_format] return video_url - rescue StandardError => e + rescue StandardError # If at first you do not succeed, maybe someone decided to # change some shit. This alternate method parses # url_encoded_fmt_stream_map. @@ -173,20 +173,23 @@ class Youtube < Website # We'll call /watch?v=video_id the "first form." first_form_video_id_regex = /v=([0-9a-z_\-]+)/i first_form_matches = first_form_video_id_regex.match(@url) - return first_form_matches[1] if not (first_form_matches.nil? || - first_form_matches.length < 2) + if not first_form_matches.nil? || first_form_matches.length < 2 + return first_form_matches[1] + end # First form didn't work? Try the second. second_form_video_id_regex = /\/v\/([0-9a-z_\-]+)/i second_form_matches = second_form_video_id_regex.match(@url) - return second_form_matches[1] if not (second_form_matches.nil? || - second_form_matches.length < 2) + if not second_form_matches.nil? || second_form_matches.length < 2 + return second_form_matches[1] + end # ...and the third. third_form_video_id_regex = /\/([[:alnum:]]+)$/i third_form_matches = third_form_video_id_regex.match(@url) - return third_form_matches[1] if not (third_form_matches.nil? || - third_form_matches.length < 2) + if not third_form_matches.nil? || third_form_matches.length < 2 + return third_form_matches[1] + end # If we made it here, we couldn't figure out the video id. Yes, # this is fatal, since we don't know where the video file is