viddl-rb 0.67 → 0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/plugins/metacafe.rb +54 -54
- metadata +5 -5
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Download a video and extract the audio:
|
|
18
18
|
|
19
19
|
In both cases we'll name the output file according to the video title.
|
20
20
|
|
21
|
-
__Youtube plugin specifics:__
|
21
|
+
__Youtube plugin specifics:__
|
22
22
|
|
23
23
|
Download all videos on a playlist:
|
24
24
|
viddl-rb http://www.youtube.com/playlist?list=PL7E8DA0A515924126
|
data/plugins/metacafe.rb
CHANGED
@@ -3,60 +3,60 @@
|
|
3
3
|
# Vidoes that have URLs that look like this: http://www.metacafe.com/watch/cb-q78rA_lp9s1_9EJsqKJ5BdIHdDNuHa1l/ cannot be downloaded.
|
4
4
|
|
5
5
|
class Metacafe < PluginBase
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
file_info = get_file_info(redirect_url, video_id)
|
26
|
-
key_string = get_file_key(redirect_url)
|
27
|
-
file_url_with_key = file_info[:file_url] + "?__gda__=#{key_string}"
|
28
|
-
escaped_url = CGI::escape(file_url_with_key)
|
29
|
-
|
30
|
-
[{:url => escaped_url, :name => get_video_name(video_swf_url) + file_info[:extension]}]
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.get_video_id(url)
|
34
|
-
id = url[/watch\/(\d+)/, 1]
|
35
|
-
unless id
|
36
|
-
puts "ERROR: Can only download videos that has the ID in the URL."
|
37
|
-
exit
|
38
|
-
end
|
39
|
-
id
|
40
|
-
end
|
6
|
+
BASE_FILE_URL = "http://v.mccont.com/ItemFiles/%5BFrom%20www.metacafe.com%5D%20"
|
7
|
+
API_BASE = "http://www.metacafe.com/api/"
|
8
|
+
|
9
|
+
#this will be called by the main app to check whether this plugin is responsible for the url passed
|
10
|
+
def self.matches_provider?(url)
|
11
|
+
url.include?("metacafe.com")
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get_urls_and_filenames(url)
|
15
|
+
video_id = get_video_id(url)
|
16
|
+
info_url = API_BASE + "item/#{video_id}" #use the API to get the full video url
|
17
|
+
info_doc = Nokogiri::XML(open(info_url))
|
18
|
+
|
19
|
+
video_swf_url = get_video_swf_url(info_doc, video_id)
|
20
|
+
|
21
|
+
#by getting the video swf url we get a http redirect url with all info needed
|
22
|
+
http_response = Net::HTTP.get_response(URI(video_swf_url))
|
23
|
+
redirect_url = CGI::unescape(http_response['location'])
|
41
24
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
25
|
+
file_info = get_file_info(redirect_url, video_id)
|
26
|
+
key_string = get_file_key(redirect_url)
|
27
|
+
file_url_with_key = file_info[:file_url] + "?__gda__=#{key_string}"
|
28
|
+
escaped_url = CGI::escape(file_url_with_key)
|
29
|
+
|
30
|
+
[{:url => escaped_url, :name => get_video_name(video_swf_url) + file_info[:extension]}]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.get_video_id(url)
|
34
|
+
id = url[/watch\/(\d+)/, 1]
|
35
|
+
unless id
|
36
|
+
puts "ERROR: Can only download videos that has the ID in the URL."
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
id
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.get_video_swf_url(info_doc, video_id)
|
43
|
+
video_url = info_doc.xpath("//rss/channel/item/link").text
|
44
|
+
video_url.sub!("watch", "fplayer")
|
45
|
+
video_url.sub!(/\/\z/, ".swf") # remove last '/' and add .swf in it's place
|
46
|
+
end
|
47
|
+
|
48
|
+
#$1 = file name part 1, $2 = file name part 2, $3 = file extension
|
49
|
+
def self.get_file_info(redirect_url, video_id)
|
50
|
+
redirect_url =~ /mediaURL.+?metacafe\.com%.+?%\d+\.(\d+)\.(\d+)(\.[\d\w]+)/
|
51
|
+
{:file_url => "#{BASE_FILE_URL}#{video_id}\.#{$1}\.#{$2}#{$3}", :extension => $3}
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.get_file_key(redirect_url)
|
55
|
+
redirect_url[/key.+?value":"([\w\d]+)"/, 1]
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_video_name(url)
|
59
|
+
name = url[/fplayer\/\d+\/([\d\w]+)\.swf/, 1]
|
60
60
|
PluginBase.make_filename_safe(name)
|
61
|
-
|
61
|
+
end
|
62
62
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viddl-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 131
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 68
|
9
|
+
version: "0.68"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marc Seeger
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-08-18 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements: []
|
143
143
|
|
144
144
|
rubyforge_project: viddl-rb
|
145
|
-
rubygems_version: 1.
|
145
|
+
rubygems_version: 1.6.2
|
146
146
|
signing_key:
|
147
147
|
specification_version: 3
|
148
148
|
summary: An extendable commandline video downloader for flash video sites.
|