lolink 0.0.4

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/lolink +27 -0
  3. data/lib/lolink.rb +55 -0
  4. metadata +86 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9338988456e1e6e99478be8e40c7474da6a9925b
4
+ data.tar.gz: 63aebb3329924e942c790587ce2b565a1fbc68ef
5
+ SHA512:
6
+ metadata.gz: cd9ea4610412d3d24a50be992aa8f0b1464e8f00c9cd0e6613f111f3550c85e6f9b967338115c54128355b633bcacd75db12f2a56eafc20510f9d9e990242277
7
+ data.tar.gz: 354341f135dd5a296927d402005a6f339820e925ca595a6278ea5f86b5996cc389e2f08fe91f94669251e2c20e5c6cda0e320f8fa75b94195bde177fbd80828a
data/bin/lolink ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lolink'
4
+ require 'optparse'
5
+
6
+ options= {}
7
+ OptionParser.new do |opts|
8
+ opts.banner = "Usage: lolink [options]"
9
+ opts.on("-d", "--download", "Download directly") do |v|
10
+ options[:download] = true
11
+ end
12
+ opts.on("-p", "--patch", "Patch links") do |v|
13
+ options[:patch] = true
14
+ end
15
+ end.parse!
16
+
17
+ d = Lolink.new
18
+ if options.include? :patch
19
+ links=d.patch_links
20
+ else
21
+ links=d.full_links
22
+ end
23
+ if options.include? :download
24
+ Lolink.aria2(links)
25
+ else
26
+ links.each{|l| puts l}
27
+ end
data/lib/lolink.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'http'
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+
5
+ class Lolink
6
+ def initialize
7
+ @base_url = "http://down.qq.com/lol"
8
+ parse_version
9
+ end
10
+
11
+ def parse_version
12
+ @doc = Nokogiri::HTML(open("http://lol.qq.com/download.shtml"))
13
+
14
+ link = @doc.search('.downlst.fl a#xzq').first.attr('href')
15
+
16
+ @versions = link.match(/(V.+-V.+)_PATCH/)[1]
17
+
18
+ @version = @versions.split('-').last
19
+ end
20
+
21
+ def test_link
22
+ i = 0
23
+ links = []
24
+ loop do
25
+ i+=1
26
+ link = yield('%.3d' % i)
27
+ if HTTP.follow.head(link).code == 404
28
+ break
29
+ else
30
+ links << link
31
+ end
32
+ end
33
+ links
34
+ end
35
+
36
+ def full_links
37
+ files = ["#{@base_url}/full/LOL_#{@version}_FULL.exe"]
38
+
39
+ files += test_link do |i|
40
+ "#{@base_url}/full/LOL_#{@version}_FULL.7z.#{i}"
41
+ end
42
+ end
43
+
44
+ def patch_links
45
+ files = ["#{@base_url}/patch/LOL_#{@versions}_PATCH.exe"]
46
+
47
+ files += test_link do |i|
48
+ "#{@base_url}/patch/LOL_#{@version}_PATCH.7z.#{i}"
49
+ end
50
+ end
51
+
52
+ def self.aria2(links)
53
+ system "aria2c -Z #{links.join(' ')}"
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lolink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - kikyous
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.7'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.7.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.7'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.7.0
53
+ description: lol中国区客户端和升级补丁下载器
54
+ email: kikyous@163.com
55
+ executables:
56
+ - lolink
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - bin/lolink
61
+ - lib/lolink.rb
62
+ homepage: https://github.com/kikyous/lolink
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.5.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: get lol download links!
86
+ test_files: []