viddl-rb 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/plugins/youtube.rb CHANGED
@@ -81,33 +81,35 @@ class Youtube < PluginBase
81
81
  token = video_info_hash["token"]
82
82
 
83
83
 
84
- #Standard = 34 <- flv
85
- #Medium = 18 <- mp4
86
- #High = 35 <- flv
87
- #720p = 22 <- mp4
88
- #1080p = 37 <- mp4
89
- #mobile = 17 <- 3gp
90
- # --> 37 > 22 > 35 > 18 > 34 > 17
91
- formats = video_info_hash["fmt_map"].keys
84
+ #for the formats, see: http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
85
+ available_formats = video_info_hash["fmt_map"].keys
92
86
 
93
87
  format_ext = {}
94
- format_ext["37"] = ["mp4", "MP4 Highest Quality 1920x1080"]
95
- format_ext["22"] = ["mp4", "MP4 1280x720"]
96
- format_ext["35"] = ["flv", "FLV 854x480"]
97
- format_ext["34"] = ["flv", "FLV 640x360"]
98
- format_ext["18"] = ["mp4", "MP4 480x270"]
99
- format_ext["17"] = ["3gp", "3gp"]
100
- format_ext["5"] = ["flv", "old default?"]
88
+ format_ext["38"] = {:extension => "mp4", :name => "MP4 Highest Quality 4096x3027 (H.264, AAC)"}
89
+ format_ext["37"] = {:extension => "mp4", :name => "MP4 Highest Quality 1920x1080 (H.264, AAC)"}
90
+ format_ext["22"] = {:extension => "mp4", :name => "MP4 1280x720 (H.264, AAC)"}
91
+ format_ext["45"] = {:extension => "webm", :name => "WebM 1280x720 (VP8, Vorbis)"}
92
+ format_ext["44"] = {:extension => "webm", :name => "WebM 854x480 (VP8, Vorbis)"}
93
+ format_ext["18"] = {:extension => "mp4", :name => "MP4 640x360 (H.264, AAC)"}
94
+ format_ext["35"] = {:extension => "flv", :name => "FLV 854x480 (H.264, AAC)"}
95
+ format_ext["34"] = {:extension => "flv", :name => "FLV 640x360 (H.264, AAC)"}
96
+ format_ext["5"] = {:extension => "flv", :name => "FLV 400x240 (Soerenson H.263)"}
97
+ format_ext["17"] = {:extension => "3gp", :name => "3gp"}
98
+
99
+ #since 1.8 doesn't do ordered hashes
100
+ prefered_order = ["38","37","22","45","44","18","35","34","5","17"]
101
+
102
+ selected_format = prefered_order.select{|possible_format| available_formats.include?(possible_format)}.first
101
103
 
102
104
  puts "[YOUTUBE] Title: #{title}"
103
105
  puts "[YOUTUBE] Length: #{length_s} s"
104
106
  puts "[YOUTUBE] t-parameter: #{token}"
105
107
  #best quality seems always to be firsts
106
- puts "[YOUTUBE] formats available: #{formats} (downloading ##{formats.first} -> #{format_ext[formats.first].last})"
108
+ puts "[YOUTUBE] formats available: #{available_formats.inspect} (downloading format #{selected_format} -> #{format_ext[selected_format][:name]})"
107
109
 
108
110
 
109
- download_url = video_info_hash["fmt_url_map"][formats.first]
110
- file_name = title.delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[formats.first].first
111
+ download_url = video_info_hash["fmt_url_map"][selected_format]
112
+ file_name = title.delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[selected_format][:extension]
111
113
  puts "downloading to " + file_name
112
114
  {:url => download_url, :name => file_name}
113
115
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viddl-rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marc Seeger
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-16 00:00:00 +02:00
18
+ date: 2011-07-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - plugins/vimeo.rb
49
49
  - plugins/youtube.rb
50
50
  - CHANGELOG.txt
51
+ - My_Boyfriend_the_Sex_Tourist___Thailand.mp4
51
52
  - README.txt
52
53
  has_rdoc: true
53
54
  homepage: https://github.com/rb2k/viddl-rb