]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/commitdiff
Fix all Ruby 1.9 errors and warnings.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 11 Jun 2012 00:23:39 +0000 (20:23 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 11 Jun 2012 00:23:39 +0000 (20:23 -0400)
12 files changed:
bin/whatever-dl
src/websites/efukt.rb
src/websites/generic.rb
src/websites/megaporn.rb
src/websites/redtube.rb
src/websites/tnaflix.rb
src/websites/veoh.rb
src/websites/vimeo.rb
src/websites/yikers.rb
src/websites/youporn.rb
src/websites/youtube.rb
vendor/ruby-progressbar/progressbar.rb

index 787e9dbb93c748ed5f949bce8e50052a15968081..146dbeca69cc48087eefb2914f0e065c7fe8322f 100755 (executable)
@@ -32,7 +32,7 @@ require 'getoptlong'
 # Thus, our require statements will work regardless of
 # how or from where the script was run.
 executable = Pathname.new(__FILE__).realpath.to_s
-$: << File.dirname(executable) + '/../'
+$LOAD_PATH << File.dirname(executable) + '/../'
 
 # Load our config file.
 require 'bin/configuration'
@@ -95,7 +95,7 @@ if (__FILE__ == $0) then
   end
 
   # Warn about nonsensical options.
-  if options[:continue] and not (Configuration::DOWNLOAD_METHOD == :wget)
+  if options[:continue] and not Configuration::DOWNLOAD_METHOD == :wget
     puts 'WARNING: The --continue flag does nothing unless DOWNLOAD_METHOD is :wget.'
   end
 
index 0a1e10e8dad9ea50c3a7a35ae87d8d51d1c9a6cd..0818eacb9d24c79f98138c9ca9a98c339686eb8d 100644 (file)
@@ -49,7 +49,7 @@ class Efukt < Website
     matches = filename_regex.match(@url)
 
     # Overwrite the default if our regex worked.
-    filename = matches[1] if not (matches.nil? || matches.length < 1)
+    filename = matches[1] if not matches.nil? || matches.length < 1
 
     return (filename + '.flv')
   end
@@ -63,7 +63,7 @@ class Efukt < Website
     video_url_regex = /flashvars\.file = "(http:\/\/.*\.flv)"/i
     matches = video_url_regex.match(page_data)
 
-    if not (matches.nil? || matches.length < 2)
+    if not matches.nil? || matches.length < 2
       return matches[1]
     else
       raise StandardError.new('Could not find the "file" Flash variable.');
index 51fe07820025b5c50b0eed583120804e3dce5713..04537279cc2866c8473cecf651ea491a39588015 100644 (file)
@@ -51,14 +51,14 @@ class Generic < Website
     full_video_url_regex = /(http:\/\/[^\"\']+?\.(flv|mp4))/i
     matches = full_video_url_regex.match(page_data)
 
-    if not (matches.nil? || matches.length < 2)
+    if not matches.nil? || matches.length < 2
       return matches[1]
     end
 
     partial_video_url_regex = /([^\=\"\']+\.(flv|mp4))/i
     matches = partial_video_url_regex.match(page_data)
 
-    if not (matches.nil? || matches.length < 2)
+    if not matches.nil? || matches.length < 2
       return base_url + matches[1]
     end
 
index bbd55c273505580d39b1ecbe21d99c6360941634..57a61a7e1332b86d5bce7cd8fa9f300989b7fcab 100644 (file)
@@ -16,8 +16,6 @@
 # http://www.fsf.org/licensing/licenses/gpl.html
 #
 
-# jcode still needed for String.each_char in Ruby 1.8.6.
-require 'jcode'
 require 'src/website'
 
 class Megaporn < Website
index 4de8772e9f27a8f695f231b16bbd7e00a934536e..78480c96c9969b5c21416b20506f9c8f98e93b64 100644 (file)
@@ -34,7 +34,7 @@ class Redtube < Website
       # We prefer to parse the HTML5 version because it can come in a
       # nicer container format.
       return parse_html5_src(page_data)
-    rescue StandardError => e
+    rescue StandardError
       return self.parse_hashlink(page_data)
     end
   end
index 7fd5f9098990f20398e7be3bd05f052c6fe58cb6..cc6bfd0d1ff069c506a441168274bc919f40b7b7 100644 (file)
@@ -29,11 +29,6 @@ class Tnaflix < Website
 
   
   def get_video_url()
-    # First, figure out the video id from the URL.
-    # Then we download the page, and parse the Flash
-    # variable that we need to construct the URL.
-    video_id = self.parse_video_id()
-
     # The old player page has the video URL conveniently
     # stored in one variable.
     old_player_url = @url + '&player=old'
@@ -53,7 +48,7 @@ class Tnaflix < Website
   def parse_video_id()
     video_id_regex = /([[:alnum:]]+)(&player=old)?$/
     matches = video_id_regex.match(@url)
-    video_id = matches[1] if not (matches.nil? || matches.length < 2)
+    video_id = matches[1] if not matches.nil? || matches.length < 2
     
     return video_id
   end
@@ -64,7 +59,7 @@ class Tnaflix < Website
   def parse_video_url(page_data)
     video_url_regex = /addVariable\(\'videoUrl\',\'([^\']+)/
     matches = video_url_regex.match(page_data)
-    video_url = matches[1] if not (matches.nil? || matches.length < 1)
+    video_url = matches[1] if not matches.nil? || matches.length < 1
     
     return video_url
   end
index d2744c3f81ef450361efaf1e6f6f2b4396a84e30..951d87dabc9975dc959bd2d327f25acbd8bcd0bc 100644 (file)
@@ -66,7 +66,7 @@ class Veoh < Website
   def parse_redirect_url(page_data)
     redirect_url_regex = /fullPreviewHashPath=\"(.*?)\"/
     matches = redirect_url_regex.match(page_data)
-    redirect_url = matches[1] if not (matches.nil? || matches.length < 2)
+    redirect_url = matches[1] if not matches.nil? || matches.length < 2
     
     return redirect_url
   end
index f8e6ad3525f2d681597ccc931c3018452b7bfe95..a6a4ea36b3e5ae793b4fadf7aa24972535304956 100644 (file)
@@ -77,9 +77,9 @@ class Vimeo < Website
       # If that didn't work, the URL must be of the clip_id= form.
       video_id_regex = /clip_id\=(\d+)/
       matches = video_id_regex.match(@url)
-      video_id = matches[1] if not (matches.nil? || matches.length < 1)
+      video_id = matches[1] if not matches.nil? || matches.length < 1
     else
-      video_id = matches[1] if not (matches.nil? || matches.length < 1)
+      video_id = matches[1] if not matches.nil? || matches.length < 1
     end
     
     return video_id
@@ -90,7 +90,7 @@ class Vimeo < Website
     # It's XML.
     rs_regex = /<request_signature>(.*?)<\/request_signature>/
     matches = rs_regex.match(page_data)
-    request_signature = matches[1] if not (matches.nil? || matches.length < 1)
+    request_signature = matches[1] if not matches.nil? || matches.length < 1
     
     return request_signature
   end
@@ -99,16 +99,16 @@ class Vimeo < Website
   def parse_request_signature_expires(page_data)
     rse_regex = /<request_signature_expires>(.*?)<\/request_signature_expires>/
     matches = rse_regex.match(page_data)
-    request_signature_expires = matches[1] if not (matches.nil? || matches.length < 1)
+    rse = matches[1] if not matches.nil? || matches.length < 1
     
-    return request_signature_expires
+    return rse
   end
 
 
   def parse_quality(page_data)
-    quality_regex = /<isHD>([01])<\isHD>/
+    quality_regex = /<isHD>([01])<\/isHD>/
     matches = quality_regex.match(page_data)
-    is_hd = matches[1] if not (matches.nil? || matches.length < 1)
+    is_hd = matches[1] if not matches.nil? || matches.length < 1
 
     if is_hd == '1' then
        # High-definition
index 8cf407aa4d4ec18083cb2f7f99dfd4ada7227e20..9784cf5b27978038a7eea51ac3c0eb5aa0b88f7b 100644 (file)
@@ -57,7 +57,7 @@ class Yikers < Website
     matches = filename_regex.match(@url)
 
     # Overwrite the default if our regex worked.
-    filename = matches[1] if not (matches.nil? || matches.length < 1)
+    filename = matches[1] if not matches.nil? || matches.length < 1
     
     return (filename + '.flv')
   end
index 3e98e9bbabfb4c400daaaa203acb9d94be692c12..2c453dd4bef4895bedafe2a0def3c29f8daad717 100644 (file)
@@ -66,6 +66,7 @@ class Youporn < Website
   def get_headers()
     headers = { 'Referer' => @url,
                 'Content-Type' => 'application/x-www-form-urlencoded' }
+    return headers
   end
 
   
index bdf2c2c4ba7bd28d25ecd1a236e8534142f8d2aa..2ab4678c11dae6660c0128765281eefffd38e61b 100644 (file)
@@ -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
index 507082d6aa6be82dc03df26edcf2396ebe316cc6..cb5605637b260d9ae190988171b050d7ecc7dca8 100644 (file)
@@ -126,7 +126,8 @@ class ProgressBar
       tiocgwinsz = 0x5413
       data = [0, 0, 0, 0].pack("SSSS")
       if @out.ioctl(tiocgwinsz, data) >= 0 then
-        rows, cols, xpixels, ypixels = data.unpack("SSSS")
+        # rows,cols,xpixels,ypixels
+        cols = data.unpack("SSSS")[1]
         if cols >= 0 then cols else default_width end
       else
         default_width