viddl-rb 0.92 → 0.93

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/plugins/vimeo.rb +20 -14
  3. data/plugins/youtube.rb +37 -15
  4. metadata +16 -15
  5. data/Gemfile.lock +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 853bc3df8900fb25eafdd54f2365aad77436392e
4
- data.tar.gz: 7bcf6e8a8150df714e6abf6e61cfed35e38023cc
3
+ metadata.gz: 8fb50f14d1549e3f6db7dd502c8fc912f3d55f27
4
+ data.tar.gz: 0a4dcc19bb0d2fc17f28722041aa7ea930c2b6a7
5
5
  SHA512:
6
- metadata.gz: a499a5cf2eb7a49833c4f6c9501a482528a5b29558452c63e760004844f89464d2b36ceb3f8174bfe9d3fefadc4257c338ef188ebe6f28fea2fa1d04b6903685
7
- data.tar.gz: af6ae26586aa365ea8803c99daf71fa722fd71ff9438cb2fd99e029cd71ce416a9af3830a69c14adc603682627511ba70a76744bd9a19188da7d8d7107a3c7e3
6
+ metadata.gz: 99fd447ea4287875aca446e1e8fad11cd56d9f2a899d1fa06c53dd964247a8c90c6227e9e0ac8508ddde2af3be4e082abbf85d5ff771dc793ce87c76c84f1073
7
+ data.tar.gz: 30f6225573ac116c54c04f090b296ffc4eaca2c0f06569d268f3e6834e4315235f775985a95fc1f517c6758b375a3e2748d0825459c44968d0fe06f874ae937c
@@ -1,4 +1,6 @@
1
+
1
2
  class Vimeo < PluginBase
3
+
2
4
  #this will be called by the main app to check whether this plugin is responsible for the url passed
3
5
  def self.matches_provider?(url)
4
6
  url.include?("vimeo.com")
@@ -8,25 +10,29 @@ class Vimeo < PluginBase
8
10
  #the vimeo ID consists of 7 decimal numbers in the URL
9
11
  vimeo_id = url[/\d{7,8}/]
10
12
 
11
- agent = Mechanize.new #use Mechanize for the automatic cookie handeling
12
- agent.redirect_ok = false #don't follow redirects so we do not download the video when we get it's url
13
+ video_url = "http://player.vimeo.com/v2/video/#{vimeo_id}"
14
+ video_page = open(video_url).read
13
15
 
14
- video_page = agent.get("http://vimeo.com/#{vimeo_id}")
15
- page_html = video_page.root.inner_html
16
- doc = Nokogiri::HTML(page_html)
17
- title = doc.at('meta[property="og:title"]').attributes['content'].value
18
- puts "[VIMEO] Title: #{title.inspect}"
16
+ info_json = video_page[/a=(\{.+?);/, 1]
17
+ parsed = MultiJson.load(info_json)
19
18
 
20
- #the timestamp and sig info is in the embedded player javascript in the video page
21
- timestamp = page_html[/"timestamp":(\d+),/, 1]
22
- signature = page_html[/"signature":"([\d\w]+)",/, 1]
19
+ files = parsed["request"]["files"]
20
+ codecs = files["codecs"]
23
21
 
24
- redirect_url = "http://player.vimeo.com/play_redirect?clip_id=#{vimeo_id}&sig=#{signature}&time=#{timestamp}&quality=hd,sd&codecs=H264,VP8,VP6"
22
+ unless codecs.include?("h264")
23
+ raise CouldNotDownloadVideoError, "Unexpected codecs: #{codecs.inspect}\n" +
24
+ "Please report this bug at github.com/rb2k/viddl-rb so it can be fixed!"
25
+ end
25
26
 
26
- #the download url is the value of the location (redirect) header
27
- download_url = agent.get(redirect_url).header["location"]
28
- file_name = PluginBase.make_filename_safe(title) + ".mp4"
27
+ h264 = files["h264"]
28
+ quality = ["hd", "sd"].find { |q| h264.keys.include?(q) }
29
+ quality = h264.keys.first if quality.nil?
30
+
31
+ download_url = h264[quality]["url"]
32
+ extension = download_url[/.+?(\.[\w\d]+?)\?/, 1]
33
+ file_name = PluginBase.make_filename_safe(parsed["video"]["title"]) + extension
29
34
 
30
35
  [{:url => download_url, :name => file_name}]
31
36
  end
32
37
  end
38
+
@@ -5,21 +5,43 @@ class Youtube < PluginBase
5
5
  # see http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
6
6
  # TODO: we don't have all the formats from the wiki article here
7
7
  VIDEO_FORMATS = {
8
- "38" => {:extension => "mp4", :name => "MP4 Highest Quality 4096x3027 (H.264, AAC)"},
9
- "37" => {:extension => "mp4", :name => "MP4 Highest Quality 1920x1080 (H.264, AAC)"},
10
- "22" => {:extension => "mp4", :name => "MP4 1280x720 (H.264, AAC)"},
11
- "46" => {:extension => "webm", :name => "WebM 1920x1080 (VP8, Vorbis)"},
12
- "45" => {:extension => "webm", :name => "WebM 1280x720 (VP8, Vorbis)"},
13
- "44" => {:extension => "webm", :name => "WebM 854x480 (VP8, Vorbis)"},
14
- "43" => {:extension => "webm", :name => "WebM 480x360 (VP8, Vorbis)"},
15
- "18" => {:extension => "mp4", :name => "MP4 640x360 (H.264, AAC)"},
16
- "35" => {:extension => "flv", :name => "FLV 854x480 (H.264, AAC)"},
17
- "34" => {:extension => "flv", :name => "FLV 640x360 (H.264, AAC)"},
18
- "5" => {:extension => "flv", :name => "FLV 400x240 (Soerenson H.263)"},
19
- "17" => {:extension => "3gp", :name => "3gp"}
8
+ "38" => {:extension => "mp4", :name => "MP4 Highest Quality 4096x3027 (H.264, AAC)"},
9
+ "37" => {:extension => "mp4", :name => "MP4 Highest Quality 1920x1080 (H.264, AAC)"},
10
+ "22" => {:extension => "mp4", :name => "MP4 1280x720 (H.264, AAC)"},
11
+ "46" => {:extension => "webm", :name => "WebM 1920x1080 (VP8, Vorbis)"},
12
+ "45" => {:extension => "webm", :name => "WebM 1280x720 (VP8, Vorbis)"},
13
+ "44" => {:extension => "webm", :name => "WebM 854x480 (VP8, Vorbis)"},
14
+ "43" => {:extension => "webm", :name => "WebM 480x360 (VP8, Vorbis)"},
15
+ "18" => {:extension => "mp4", :name => "MP4 640x360 (H.264, AAC)"},
16
+ "35" => {:extension => "flv", :name => "FLV 854x480 (H.264, AAC)"},
17
+ "34" => {:extension => "flv", :name => "FLV 640x360 (H.264, AAC)"},
18
+ "6" => {:extension => "flv", :name => "FLV 640x360 (Soerenson H.263)"},
19
+ "5" => {:extension => "flv", :name => "FLV 400x240 (Soerenson H.263)"},
20
+ "36" => {:extension => "3gp", :name => "3gp Medium Quality - 320x240 (MPEG-4 Visual, AAC)"},
21
+ "17" => {:extension => "3gp", :name => "3gp Medium Quality - 176x144 (MPEG-4 Visual, AAC)"},
22
+ "13" => {:extension => "3gp", :name => "3gp Low Quality - 176x144 (MPEG-4 Visual, AAC)"},
23
+ "82" => {:extension => "mp4", :name => "MP4 360p (H.264 AAC)"},
24
+ "83" => {:extension => "mp4", :name => "MP4 240p (H.264 AAC)"},
25
+ "84" => {:extension => "mp4", :name => "MP4 720p (H.264 AAC)"},
26
+ "85" => {:extension => "mp4", :name => "MP4 520p (H.264 AAC)"},
27
+ "100" => {:extension => "webm", :name => "WebM 360p (VP8 Vorbis)"},
28
+ "101" => {:extension => "webm", :name => "WebM 360p (VP8 Vorbis)"},
29
+ "102" => {:extension => "webm", :name => "WebM 720p (VP8 Vorbis)"},
30
+ "120" => {:extension => "flv", :name => "FLV 720p (H.264 AAC)"},
31
+ "133" => {:extension => "mp4", :name => "MP4 240p (H.264)"},
32
+ "134" => {:extension => "mp4", :name => "MP4 360p (H.264)"},
33
+ "135" => {:extension => "mp4", :name => "MP4 480p (H.264)"},
34
+ "136" => {:extension => "mp4", :name => "MP4 720p (H.264)"},
35
+ "137" => {:extension => "mp4", :name => "MP4 1080p (H.264)"},
36
+ "139" => {:extension => "mp4", :name => "MP4 (AAC)"},
37
+ "140" => {:extension => "mp4", :name => "MP4 (AAC"},
38
+ "141" => {:extension => "mp4", :name => "MP4 (AAC)"},
39
+ "160" => {:extension => "mp4", :name => "MP4 (H.264)"},
40
+ "171" => {:extension => "webm", :name => "WebM (Vorbis)"},
41
+ "172" => {:extension => "webm", :name => "WebM (Vorbis)"}
20
42
  }
21
43
 
22
- DEFAULT_FORMAT_ORDER = %w[38 37 22 46 45 44 43 18 35 34 5 17]
44
+ DEFAULT_FORMAT_ORDER = %w[38 37 22 46 45 44 43 18 35 34 6 5 36 17 13 82 83 84 85 100 101 102 120 133 134 135 136 137 139 140 141 160 171 172]
23
45
  VIDEO_INFO_URL = "http://www.youtube.com/get_video_info?video_id="
24
46
  VIDEO_INFO_PARMS = "&ps=default&eurl=&gl=US&hl=en"
25
47
 
@@ -146,9 +168,9 @@ class Youtube < PluginBase
146
168
 
147
169
  if @quality #if the user specified a format
148
170
  ext = @quality[:extension]
149
- res = @quality[:resolution]
171
+ res = @quality[:resolution] || ""
150
172
  #gets a nested array with all the formats of the same res as the user wanted
151
- requested = VIDEO_FORMATS.select { |id, format| format[:name].include?(res) }.to_a
173
+ requested = VIDEO_FORMATS.select { |id, format| available_formats.include?(id) && format[:name].include?(res) }.to_a
152
174
 
153
175
  if requested.empty?
154
176
  Youtube.notify "Requested format \"#{res}:#{ext}\" not found. Downloading default format."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viddl-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.92"
4
+ version: "0.93"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Seeger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-12-08 00:00:00 Z
12
+ date: 2014-01-21 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
@@ -36,26 +36,28 @@ dependencies:
36
36
  prerelease: false
37
37
  requirement: &id003 !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - &id004
40
- - ">="
39
+ - - "="
41
40
  - !ruby/object:Gem::Version
42
- version: "0"
41
+ version: 2.7.2
43
42
  type: :runtime
44
43
  version_requirements: *id003
45
44
  - !ruby/object:Gem::Dependency
46
45
  name: progressbar
47
46
  prerelease: false
48
- requirement: &id005 !ruby/object:Gem::Requirement
47
+ requirement: &id004 !ruby/object:Gem::Requirement
49
48
  requirements:
50
- - *id004
49
+ - &id005
50
+ - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
51
53
  type: :runtime
52
- version_requirements: *id005
54
+ version_requirements: *id004
53
55
  - !ruby/object:Gem::Dependency
54
56
  name: multi_json
55
57
  prerelease: false
56
58
  requirement: &id006 !ruby/object:Gem::Requirement
57
59
  requirements:
58
- - *id004
60
+ - *id005
59
61
  type: :runtime
60
62
  version_requirements: *id006
61
63
  - !ruby/object:Gem::Dependency
@@ -63,7 +65,7 @@ dependencies:
63
65
  prerelease: false
64
66
  requirement: &id007 !ruby/object:Gem::Requirement
65
67
  requirements:
66
- - *id004
68
+ - *id005
67
69
  type: :development
68
70
  version_requirements: *id007
69
71
  - !ruby/object:Gem::Dependency
@@ -71,7 +73,7 @@ dependencies:
71
73
  prerelease: false
72
74
  requirement: &id008 !ruby/object:Gem::Requirement
73
75
  requirements:
74
- - *id004
76
+ - *id005
75
77
  type: :development
76
78
  version_requirements: *id008
77
79
  - !ruby/object:Gem::Dependency
@@ -79,7 +81,7 @@ dependencies:
79
81
  prerelease: false
80
82
  requirement: &id009 !ruby/object:Gem::Requirement
81
83
  requirements:
82
- - *id004
84
+ - *id005
83
85
  type: :development
84
86
  version_requirements: *id009
85
87
  description: An extendable commandline video downloader for flash video sites. Includes plugins for vimeo, youtube, dailymotion and more
@@ -109,7 +111,6 @@ files:
109
111
  - plugins/vimeo.rb
110
112
  - plugins/youtube.rb
111
113
  - Gemfile
112
- - Gemfile.lock
113
114
  - Rakefile
114
115
  - README.md
115
116
  homepage: https://github.com/rb2k/viddl-rb
@@ -124,7 +125,7 @@ require_paths:
124
125
  - lib
125
126
  required_ruby_version: !ruby/object:Gem::Requirement
126
127
  requirements:
127
- - *id004
128
+ - *id005
128
129
  required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  requirements:
130
131
  - - ">="
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  requirements: []
134
135
 
135
136
  rubyforge_project: viddl-rb
136
- rubygems_version: 2.0.13
137
+ rubygems_version: 2.0.14
137
138
  signing_key:
138
139
  specification_version: 4
139
140
  summary: An extendable commandline video downloader for flash video sites.
@@ -1,49 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- viddl-rb (0.84)
5
- mechanize
6
- multi_json
7
- nokogiri (~> 1.5.0)
8
- progressbar
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- domain_name (0.5.13)
14
- unf (>= 0.0.5, < 1.0.0)
15
- http-cookie (1.0.1)
16
- domain_name (~> 0.5)
17
- mechanize (2.7.2)
18
- domain_name (~> 0.5, >= 0.5.1)
19
- http-cookie (~> 1.0.0)
20
- mime-types (~> 1.17, >= 1.17.2)
21
- net-http-digest_auth (~> 1.1, >= 1.1.1)
22
- net-http-persistent (~> 2.5, >= 2.5.2)
23
- nokogiri (~> 1.4)
24
- ntlm-http (~> 0.1, >= 0.1.1)
25
- webrobots (>= 0.0.9, < 0.2)
26
- mime-types (1.24)
27
- minitest (5.0.6)
28
- multi_json (1.8.0)
29
- net-http-digest_auth (1.4)
30
- net-http-persistent (2.9)
31
- nokogiri (1.5.10)
32
- ntlm-http (0.1.1)
33
- progressbar (0.20.0)
34
- rake (10.1.0)
35
- rest-client (1.6.7)
36
- mime-types (>= 1.16)
37
- unf (0.1.2)
38
- unf_ext
39
- unf_ext (0.0.6)
40
- webrobots (0.1.1)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- minitest
47
- rake
48
- rest-client
49
- viddl-rb!