xunlei 0.0.6 → 0.0.7
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 +12 -0
- data/bin/xunlei +68 -18
- data/lib/xunlei/engine.rb +26 -0
- data/lib/xunlei/search.rb +17 -2
- data/lib/xunlei/version.rb +1 -1
- metadata +16 -16
data/README.md
CHANGED
@@ -39,11 +39,23 @@ Download files according to pattern in file names
|
|
39
39
|
|
40
40
|
xunlei download --only matrix
|
41
41
|
xunlei download --except bourne
|
42
|
+
|
43
|
+
Add ed2k or magnet link as new task
|
44
|
+
|
45
|
+
xunlei add ed2k_or_magment_link
|
42
46
|
|
43
47
|
Google for ed2k and magnet links
|
44
48
|
|
45
49
|
xunlei google Repulsion --with 720p
|
46
50
|
|
51
|
+
Search simplecd.org for ed2k links
|
52
|
+
|
53
|
+
xunlei simplecd Vendetta 720p
|
54
|
+
|
55
|
+
I am feeling lucky :)
|
56
|
+
|
57
|
+
xunlei lucky KEYWORDS
|
58
|
+
|
47
59
|
Pass --help to see more tasks and options
|
48
60
|
|
49
61
|
xunlei --help
|
data/bin/xunlei
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "xunlei"
|
4
4
|
# require File.expand_path("lib/xunlei/version.rb")
|
5
5
|
# require File.expand_path("lib/xunlei/engine.rb")
|
6
|
+
# require File.expand_path("lib/xunlei/search.rb")
|
6
7
|
require "yaml"
|
7
8
|
require "commander/import"
|
8
9
|
|
@@ -24,25 +25,29 @@ def filter_files(options = nil)
|
|
24
25
|
files
|
25
26
|
end
|
26
27
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
engine.dump_cookies.each do |line|
|
39
|
-
file.write(line)
|
40
|
-
end
|
28
|
+
def execute_dump_action(args, options)
|
29
|
+
options.default :driver => "chrome"
|
30
|
+
|
31
|
+
check_for_config_files
|
32
|
+
check_for_chromedriver
|
33
|
+
credentials = YAML.load_file(xunlei_credential_file_path)
|
34
|
+
engine = Xunlei::Engine.new(credentials[:username], credentials[:password], options.driver.downcase.to_sym)
|
35
|
+
|
36
|
+
File.open(xunlei_cookies_path, "w") do |file|
|
37
|
+
engine.dump_cookies.each do |line|
|
38
|
+
file.write(line)
|
41
39
|
end
|
40
|
+
end
|
42
41
|
|
43
|
-
|
42
|
+
yield(engine, args) if block_given?
|
43
|
+
|
44
|
+
engine.stop
|
45
|
+
end
|
44
46
|
|
45
|
-
|
47
|
+
def do_dump_cookies(c)
|
48
|
+
c.option "--driver DRIVER", String, "use a different webdriver (e.g. firefox). default is chrome"
|
49
|
+
c.action do |args, options|
|
50
|
+
execute_dump_action(args, options)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
@@ -180,7 +185,7 @@ command :dump_tasks do |c|
|
|
180
185
|
c.syntax= "dump_tasks"
|
181
186
|
c.description = "dump all files to #{xunlei_tasks_path}"
|
182
187
|
|
183
|
-
do_dump_cookies(c) do |engine|
|
188
|
+
do_dump_cookies(c) do |engine, args|
|
184
189
|
tasks = engine.dump_tasks
|
185
190
|
|
186
191
|
current_downloaded_tasks = all_downloaded_tasks & tasks.map { |task| task[:name] }
|
@@ -206,6 +211,15 @@ command :dump_tasks do |c|
|
|
206
211
|
end
|
207
212
|
end
|
208
213
|
|
214
|
+
command :add do |c|
|
215
|
+
c.syntax= "add KEYWORD"
|
216
|
+
c.description = "add new task(s)."
|
217
|
+
|
218
|
+
do_dump_cookies(c) do |engine, args|
|
219
|
+
engine.add_task(args.first)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
209
223
|
command :dump_cookies do |c|
|
210
224
|
c.syntax = "dump_cookies"
|
211
225
|
c.description = "dump cookies to #{xunlei_cookies_path}"
|
@@ -278,7 +292,7 @@ command :google do |c|
|
|
278
292
|
c.option "--without WORDS", String, "exclude additional info when Googling"
|
279
293
|
c.action do |args, options|
|
280
294
|
options.default :with => nil, :without => nil
|
281
|
-
puts "Searching the web for #{args.join(" ")}..."
|
295
|
+
puts "Searching the web for '#{args.join(" ")}'..."
|
282
296
|
puts
|
283
297
|
search = Xunlei::Search.new
|
284
298
|
links = search.google(args, options)
|
@@ -287,6 +301,42 @@ command :google do |c|
|
|
287
301
|
end
|
288
302
|
end
|
289
303
|
|
304
|
+
command :simplecd do |c|
|
305
|
+
c.syntax = "simplecd KEYWORD"
|
306
|
+
c.description = "search simplecd for ed2k links using given KEYWORD"
|
307
|
+
c.option "--with WORDS", String, "include additional info when searching"
|
308
|
+
c.option "--without WORDS", String, "exclude additional info when searching"
|
309
|
+
c.action do |args, options|
|
310
|
+
options.default :with => nil, :without => nil
|
311
|
+
puts "Searching simplecd.org for '#{args.join(" ")}'..."
|
312
|
+
puts
|
313
|
+
search = Xunlei::Search.new
|
314
|
+
links = search.google_simplecd(args, options)
|
315
|
+
puts
|
316
|
+
puts "#{links.count} links found."
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
command :lucky do |c|
|
321
|
+
c.syntax = "lucky KEYWORD"
|
322
|
+
c.description = "search simplecd for ed2k links using given KEYWORD and create new tasks :)"
|
323
|
+
c.action do |args, options|
|
324
|
+
puts "Searching simplecd.org for '#{args.join(" ")}'..."
|
325
|
+
puts
|
326
|
+
search = Xunlei::Search.new
|
327
|
+
links = search.google_simplecd(args, options)
|
328
|
+
puts
|
329
|
+
puts "#{links.count} links found."
|
330
|
+
|
331
|
+
execute_dump_action(args, options) do |engine, args|
|
332
|
+
links.each do |link|
|
333
|
+
engine.add_task(link)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
290
339
|
alias_command :down, :download
|
291
340
|
alias_command :dump, :dump_tasks
|
292
341
|
alias_command :search, :google
|
342
|
+
alias_command :scd, :simplecd
|
data/lib/xunlei/engine.rb
CHANGED
@@ -41,6 +41,32 @@ module Xunlei
|
|
41
41
|
all_files
|
42
42
|
end
|
43
43
|
|
44
|
+
def add_task(target_address)
|
45
|
+
puts "Adding new task..."
|
46
|
+
# open('|pbcopy', 'w') { |io| io << target_address }
|
47
|
+
|
48
|
+
@browser.execute_script("add_task_new(0)")
|
49
|
+
|
50
|
+
@browser.text_field(:id => 'task_url').wait_until_present
|
51
|
+
|
52
|
+
# @browser.send_keys [:command, 'v']
|
53
|
+
@browser.execute_script("document.getElementById('task_url').value = '#{target_address}'")
|
54
|
+
|
55
|
+
puts "Task URL = \"#{target_address}\""
|
56
|
+
expire_count = 0
|
57
|
+
sleep(2.0)
|
58
|
+
while !(@browser.button(:id => 'down_but').enabled? && expire_count <= 5000)
|
59
|
+
expire_count += 1
|
60
|
+
end
|
61
|
+
if expire_count <= 5000
|
62
|
+
print "Submitting... "
|
63
|
+
@browser.button(:id => 'down_but').when_present.click
|
64
|
+
puts "Done."
|
65
|
+
else
|
66
|
+
puts "Timed out, the button is unavailable."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
44
70
|
def stop
|
45
71
|
@browser.close
|
46
72
|
end
|
data/lib/xunlei/search.rb
CHANGED
@@ -9,10 +9,20 @@ module Xunlei
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def google(keywords, options)
|
12
|
+
do_google(keywords, options, "http://www.google.com/search?q=", 10)
|
13
|
+
end
|
14
|
+
|
15
|
+
def google_simplecd(keywords, options)
|
16
|
+
do_google(keywords, options, "http://www.google.com/search?q=site:simplecd.org+", 1)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def do_google(keywords, options, prefix, limit)
|
12
22
|
q = [keywords, options.with, "ed2k"].flatten.join("+")
|
13
23
|
q += "+-" + options.without unless options.without.nil?
|
14
24
|
|
15
|
-
@browser.goto "
|
25
|
+
@browser.goto "#{prefix}#{q}"
|
16
26
|
|
17
27
|
@browser.div(:id => "ires").wait_until_present
|
18
28
|
|
@@ -20,17 +30,22 @@ module Xunlei
|
|
20
30
|
@browser.lis(:class => "g").each { |li| page_links << li.as.first.href }
|
21
31
|
|
22
32
|
ed2k_links = []
|
33
|
+
|
23
34
|
page_links.each do |page_link|
|
24
35
|
@browser.goto page_link
|
25
36
|
doc = Nokogiri::HTML(@browser.html)
|
26
37
|
doc.css("a").each do |link|
|
27
38
|
next if link['href'].nil?
|
28
|
-
href = URI.escape(link['href'])
|
39
|
+
# href = URI.escape(link['href'])
|
40
|
+
href = link['href']
|
29
41
|
if href =~ /ed2k:|magnet:/ && !ed2k_links.include?(href)
|
30
42
|
puts href
|
31
43
|
ed2k_links << href
|
32
44
|
end
|
33
45
|
end
|
46
|
+
|
47
|
+
limit -= 1
|
48
|
+
break unless limit > 1
|
34
49
|
end
|
35
50
|
|
36
51
|
@browser.close
|
data/lib/xunlei/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xunlei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70299977384620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70299977384620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70299977384200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70299977384200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: simplecov
|
38
|
-
requirement: &
|
38
|
+
requirement: &70299977383780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70299977383780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: watir-webdriver
|
49
|
-
requirement: &
|
49
|
+
requirement: &70299977383280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70299977383280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: commander
|
60
|
-
requirement: &
|
60
|
+
requirement: &70299977382860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70299977382860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: nokogiri
|
71
|
-
requirement: &
|
71
|
+
requirement: &70299977382440 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70299977382440
|
80
80
|
description: A browser script to access lixian.vip.xunlei.com tasks automatically
|
81
81
|
email:
|
82
82
|
- afu@forresty.com
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash:
|
118
|
+
hash: 1170829789028878004
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash:
|
127
|
+
hash: 1170829789028878004
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project: xunlei
|
130
130
|
rubygems_version: 1.8.11
|