viddl-rb 0.5.5 → 0.6
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/Gemfile.lock +24 -0
- data/plugins/metacafe.rb +0 -1
- data/plugins/soundcloud.rb +42 -0
- metadata +7 -6
- data/plugins/megavideo.rb +0 -96
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
viddl-rb (0.5.5)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
mime-types (1.17.2)
|
11
|
+
minitest (2.11.1)
|
12
|
+
nokogiri (1.5.0)
|
13
|
+
rake (0.9.2.2)
|
14
|
+
rest-client (1.6.7)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
minitest
|
22
|
+
rake
|
23
|
+
rest-client
|
24
|
+
viddl-rb!
|
data/plugins/metacafe.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Note: unfortunaley, only videos that are hosted on Metacafe.com's content server can be downloaded.
|
2
2
|
# They have an URL that looks somehting like this: http://www.metacafe.com/watch/7731483/
|
3
3
|
# Vidoes that have URLs that look like this: http://www.metacafe.com/watch/cb-q78rA_lp9s1_9EJsqKJ5BdIHdDNuHa1l/ cannot be downloaded.
|
4
|
-
require 'cgi'
|
5
4
|
|
6
5
|
class Metacafe < PluginBase
|
7
6
|
BASE_FILE_URL = "http://v.mccont.com/ItemFiles/%5BFrom%20www.metacafe.com%5D%20"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Soundcloud < PluginBase
|
2
|
+
require 'iconv'
|
3
|
+
# this will be called by the main app to check whether this plugin is responsible for the url passed
|
4
|
+
def self.matches_provider?(url)
|
5
|
+
url.include?("soundcloud.com")
|
6
|
+
end
|
7
|
+
|
8
|
+
# return the url for original video file and title
|
9
|
+
def self.get_urls_and_filenames(url)
|
10
|
+
doc = Nokogiri::XML(open(url))
|
11
|
+
download_filename = doc.at("#main-content-inner img[class=waveform]").attributes["src"].value.to_s.match(/\.com\/(.+)\_/)[1]
|
12
|
+
download_url = "http://media.soundcloud.com/stream/#{download_filename}"
|
13
|
+
file_name = transliterate("#{doc.at('//h1/em').text.chomp}") + ".mp3"
|
14
|
+
|
15
|
+
[{:url => download_url, :name => file_name}]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.transliterate(str)
|
19
|
+
# Based on permalink_fu by Rick Olsen
|
20
|
+
|
21
|
+
# Escape str by transliterating to UTF-8 with Iconv
|
22
|
+
s = Iconv.iconv('ascii//ignore//translit', 'utf-8', str).to_s
|
23
|
+
|
24
|
+
# Downcase string
|
25
|
+
s.downcase!
|
26
|
+
|
27
|
+
# Remove apostrophes so isn't changes to isnt
|
28
|
+
s.gsub!(/'/, '')
|
29
|
+
|
30
|
+
# Replace any non-letter or non-number character with a space
|
31
|
+
s.gsub!(/[^A-Za-z0-9]+/, ' ')
|
32
|
+
|
33
|
+
# Remove spaces from beginning and end of string
|
34
|
+
s.strip!
|
35
|
+
|
36
|
+
# Replace groups of spaces with single hyphen
|
37
|
+
s.gsub!(/\ +/, '-')
|
38
|
+
|
39
|
+
return s
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viddl-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.5.5
|
8
|
+
- 6
|
9
|
+
version: "0.6"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Marc Seeger
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2012-03-06 00:00:00 Z
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
21
20
|
name: nokogiri
|
@@ -86,13 +85,14 @@ files:
|
|
86
85
|
- helper/download-helper.rb
|
87
86
|
- helper/plugin-helper.rb
|
88
87
|
- plugins/blip.rb
|
89
|
-
- plugins/megavideo.rb
|
90
88
|
- plugins/metacafe.rb
|
89
|
+
- plugins/soundcloud.rb
|
91
90
|
- plugins/veoh.rb
|
92
91
|
- plugins/vimeo.rb
|
93
92
|
- plugins/youtube.rb
|
94
93
|
- CHANGELOG.txt
|
95
94
|
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
96
|
- Rakefile
|
97
97
|
- README.md
|
98
98
|
homepage: https://github.com/rb2k/viddl-rb
|
@@ -132,3 +132,4 @@ specification_version: 3
|
|
132
132
|
summary: An extendable commandline video downloader for flash video sites.
|
133
133
|
test_files: []
|
134
134
|
|
135
|
+
has_rdoc: false
|
data/plugins/megavideo.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
class Megavideo < PluginBase
|
2
|
-
#this will be called by the main app to check whether this plugin is responsible for the url passed
|
3
|
-
def self.matches_provider?(url)
|
4
|
-
url.include?("megavideo.com")
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.decrypt(un,k1,k2)
|
8
|
-
#thanks to http://userscripts.org/scripts/review/42944
|
9
|
-
k1 = k1.to_i
|
10
|
-
k2 = k2.to_i
|
11
|
-
|
12
|
-
#convert the hex "un" to binary
|
13
|
-
location1 = Array.new
|
14
|
-
un.each_char do |char|
|
15
|
-
#puts "#{char} => #{char.to_i(16).to_s(2)}"
|
16
|
-
location1 << ("000" + char.to_i(16).to_s(2))[-4,4]
|
17
|
-
end
|
18
|
-
|
19
|
-
location1 = location1.join("").split("")
|
20
|
-
|
21
|
-
location6 = Array.new
|
22
|
-
0.upto(383) do |n|
|
23
|
-
k1 = (k1 * 11 + 77213) % 81371
|
24
|
-
k2 = (k2 * 17 + 92717) % 192811
|
25
|
-
location6[n] = (k1 + k2) % 128
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
location3 = Array.new
|
31
|
-
location4 = Array.new
|
32
|
-
location5 = Array.new
|
33
|
-
location8 = Array.new
|
34
|
-
256.downto(0) do |n|
|
35
|
-
location5 = location6[n]
|
36
|
-
location4 = n % 128
|
37
|
-
location8 = location1[location5]
|
38
|
-
location1[location5] = location1[location4]
|
39
|
-
location1[location4] = location8
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
0.upto(127) do |n|
|
44
|
-
location1[n] = location1[n].to_i ^ location6[n+256] & 1
|
45
|
-
end
|
46
|
-
|
47
|
-
location12 = location1.join("")
|
48
|
-
location7 = Array.new
|
49
|
-
|
50
|
-
n = 0
|
51
|
-
while (n < location12.length) do
|
52
|
-
location9 = location12[n,4]
|
53
|
-
location7 << location9
|
54
|
-
n+=4
|
55
|
-
end
|
56
|
-
|
57
|
-
result = ""
|
58
|
-
location7.each do |bin|
|
59
|
-
result = result + bin.to_i(2).to_s(16)
|
60
|
-
end
|
61
|
-
result
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
def self.get_urls_and_filenames(url)
|
66
|
-
#the megavideo video ID looks like this: http://www.megavideo.com/?v=ABCDEF72 , we only want the ID (the \w in the brackets)
|
67
|
-
video_id = url[/v[\/=](\w*)&?/, 1]
|
68
|
-
puts "[MEGAVIDEO] ID FOUND: " + video_id
|
69
|
-
video_page = Nokogiri::XML(open("http://www.megavideo.com/xml/videolink.php?v=#{video_id}"))
|
70
|
-
info = video_page.at("//ROWS/ROW")
|
71
|
-
title = info["title"]
|
72
|
-
puts "[MEGAVIDEO] title: #{title}"
|
73
|
-
runtime = info["runtimehms"]
|
74
|
-
puts "[MEGAVIDEO] runtime: #{runtime}"
|
75
|
-
size = info["size"].to_i / 1024 / 1024
|
76
|
-
puts "[MEGAVIDEO] size: #{size} MB"
|
77
|
-
#lame crypto stuff
|
78
|
-
key_s = info["s"]
|
79
|
-
key_un = info["un"]
|
80
|
-
key_k1 = info["k1"]
|
81
|
-
key_k2 = info["k2"]
|
82
|
-
puts "[MEGAVIDEO] lame pseudo crypto keys:"
|
83
|
-
puts "[MEGAVIDEO] s=#{key_s}"
|
84
|
-
puts "[MEGAVIDEO] un=#{key_un}"
|
85
|
-
puts "[MEGAVIDEO] k1=#{key_k1}"
|
86
|
-
puts "[MEGAVIDEO] k2=#{key_k2}"
|
87
|
-
puts "decrypting"
|
88
|
-
download_url = "http://www#{key_s}.megavideo.com/files/#{decrypt(key_un,key_k1,key_k2)}/#{title}.flv"
|
89
|
-
puts download_url
|
90
|
-
puts "done decrypting"
|
91
|
-
file_name = title + ".flv"
|
92
|
-
puts "downloading to " + file_name
|
93
|
-
[{:url => download_url, :name => file_name}]
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|