addic7ed 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/addic7ed/common.rb +47 -48
- data/lib/addic7ed/parser.rb +8 -1
- data/lib/addic7ed/subtitle.rb +31 -19
- data/lib/addic7ed/version.rb +1 -1
- data/spec/lib/addic7ed/subtitle_spec.rb +13 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b67396fb48a509f39c40ea0eb6cf675ea957f4
|
4
|
+
data.tar.gz: a384a2c19ed9d8531779fe3c017b9b0b3c3b14ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2fe1f944482ddf0283db063f94f5b038c59864b8f52bfcb9b7a8e1fce6c0df7686923b4c0f36b8adb8b248dbf7ad46591cabb8d591ec04602482b0af0a21a35
|
7
|
+
data.tar.gz: 08008fd711a85eb153cc61646b5bc57ac0dd24bc19642ada643cc3ba3beddb55da97bee6521f685a1247e7f941140f74dcf888cc5350e07ab1b56ecdb8156ddc
|
data/lib/addic7ed/common.rb
CHANGED
@@ -2,63 +2,63 @@
|
|
2
2
|
|
3
3
|
module Addic7ed
|
4
4
|
|
5
|
-
SHOWS_URL
|
6
|
-
EPISODES_URL
|
5
|
+
SHOWS_URL = 'http://www.addic7ed.com/ajax_getShows.php'
|
6
|
+
EPISODES_URL = 'http://www.addic7ed.com/ajax_getEpisodes.php'
|
7
7
|
EPISODE_REDIRECT_URL = 'http://www.addic7ed.com/re_episode.php'
|
8
8
|
|
9
9
|
COMPATIBILITY_720P = {
|
10
|
-
'LOL'
|
11
|
-
'SYS'
|
12
|
-
'XII'
|
10
|
+
'LOL' => 'DIMENSION',
|
11
|
+
'SYS' => 'DIMENSION',
|
12
|
+
'XII' => 'IMMERSE',
|
13
13
|
'ASAP' => 'IMMERSE'
|
14
14
|
}
|
15
15
|
|
16
16
|
LANGUAGES = {
|
17
|
-
'ar'
|
18
|
-
'az'
|
19
|
-
'bn'
|
20
|
-
'bs'
|
21
|
-
'bg'
|
22
|
-
'ca'
|
23
|
-
'cn'
|
24
|
-
'zh'
|
25
|
-
'hr'
|
26
|
-
'cs'
|
27
|
-
'da'
|
28
|
-
'nl'
|
29
|
-
'en'
|
30
|
-
'eu'
|
31
|
-
'fi'
|
32
|
-
'fr'
|
33
|
-
'gl'
|
34
|
-
'de'
|
35
|
-
'el'
|
36
|
-
'he'
|
37
|
-
'hu'
|
38
|
-
'id'
|
39
|
-
'it'
|
40
|
-
'ja'
|
41
|
-
'ko'
|
42
|
-
'mk'
|
43
|
-
'ms'
|
44
|
-
'no'
|
45
|
-
'fa'
|
46
|
-
'pl'
|
47
|
-
'pt'
|
17
|
+
'ar' => {name: 'Arabic', id: 38},
|
18
|
+
'az' => {name: 'Azerbaijani', id: 48},
|
19
|
+
'bn' => {name: 'Bengali', id: 47},
|
20
|
+
'bs' => {name: 'Bosnian', id: 44},
|
21
|
+
'bg' => {name: 'Bulgarian', id: 35},
|
22
|
+
'ca' => {name: 'Català', id: 12},
|
23
|
+
'cn' => {name: 'Chinese (Simplified)', id: 41},
|
24
|
+
'zh' => {name: 'Chinese (Traditional)', id: 24},
|
25
|
+
'hr' => {name: 'Croatian', id: 31},
|
26
|
+
'cs' => {name: 'Czech', id: 14},
|
27
|
+
'da' => {name: 'Danish', id: 30},
|
28
|
+
'nl' => {name: 'Dutch', id: 17},
|
29
|
+
'en' => {name: 'English', id: 1},
|
30
|
+
'eu' => {name: 'Euskera', id: 13},
|
31
|
+
'fi' => {name: 'Finnish', id: 28},
|
32
|
+
'fr' => {name: 'French', id: 8},
|
33
|
+
'gl' => {name: 'Galego', id: 15},
|
34
|
+
'de' => {name: 'German', id: 11},
|
35
|
+
'el' => {name: 'Greek', id: 27},
|
36
|
+
'he' => {name: 'Hebrew', id: 23},
|
37
|
+
'hu' => {name: 'Hungarian', id: 20},
|
38
|
+
'id' => {name: 'Indonesian', id: 37},
|
39
|
+
'it' => {name: 'Italian', id: 7},
|
40
|
+
'ja' => {name: 'Japanese', id: 32},
|
41
|
+
'ko' => {name: 'Korean', id: 42},
|
42
|
+
'mk' => {name: 'Macedonian', id: 49},
|
43
|
+
'ms' => {name: 'Malay', id: 40},
|
44
|
+
'no' => {name: 'Norwegian', id: 29},
|
45
|
+
'fa' => {name: 'Persian', id: 43},
|
46
|
+
'pl' => {name: 'Polish', id: 21},
|
47
|
+
'pt' => {name: 'Portuguese', id: 9},
|
48
48
|
'pt-br' => {name: 'Portuguese (Brazilian)', id: 10},
|
49
|
-
'ro'
|
50
|
-
'ru'
|
51
|
-
'sr'
|
49
|
+
'ro' => {name: 'Romanian', id: 26},
|
50
|
+
'ru' => {name: 'Russian', id: 19},
|
51
|
+
'sr' => {name: 'Serbian (Cyrillic)', id: 39},
|
52
52
|
'sr-la' => {name: 'Serbian (Latin)', id: 36},
|
53
|
-
'sk'
|
54
|
-
'sl'
|
55
|
-
'es'
|
53
|
+
'sk' => {name: 'Slovak', id: 25},
|
54
|
+
'sl' => {name: 'Slovenian', id: 22},
|
55
|
+
'es' => {name: 'Spanish', id: 4},
|
56
56
|
'es-la' => {name: 'Spanish (Latin America)', id: 6},
|
57
57
|
'es-es' => {name: 'Spanish (Spain)', id: 5},
|
58
|
-
'sv'
|
59
|
-
'th'
|
60
|
-
'tr'
|
61
|
-
'vi'
|
58
|
+
'sv' => {name: 'Swedish', id: 18},
|
59
|
+
'th' => {name: 'Thai', id: 46},
|
60
|
+
'tr' => {name: 'Turkish', id: 16},
|
61
|
+
'vi' => {name: 'Vietnamese', id: 45}
|
62
62
|
}
|
63
63
|
|
64
64
|
USER_AGENTS = [
|
@@ -1284,7 +1284,6 @@ module Addic7ed
|
|
1284
1284
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.0 Safari/534.13",
|
1285
1285
|
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.0 Safari/534.13",
|
1286
1286
|
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.0 Safari/534.13",
|
1287
|
-
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.0 Safari/534.13"
|
1288
|
-
|
1287
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.0 Safari/534.13"
|
1289
1288
|
]
|
1290
1289
|
end
|
data/lib/addic7ed/parser.rb
CHANGED
@@ -44,7 +44,8 @@ module Addic7ed
|
|
44
44
|
status: extract_status(sub_node),
|
45
45
|
url: extract_url(sub_node),
|
46
46
|
source: extract_source(sub_node),
|
47
|
-
downloads: extract_downloads(sub_node)
|
47
|
+
downloads: extract_downloads(sub_node),
|
48
|
+
comment: extract_comment(sub_node)
|
48
49
|
)
|
49
50
|
end
|
50
51
|
|
@@ -83,5 +84,11 @@ module Addic7ed
|
|
83
84
|
/(?<downloads>\d*) Downloads/.match(downloads_node.content)[:downloads]
|
84
85
|
end
|
85
86
|
|
87
|
+
def extract_comment(sub_node)
|
88
|
+
comment_node = sub_node.css('tr:nth-child(2) td.newsDate').first
|
89
|
+
raise Addic7ed::ParsingError unless comment_node
|
90
|
+
comment_node.content.gsub(/<img[^>]+\>/i, "")
|
91
|
+
end
|
92
|
+
|
86
93
|
end
|
87
94
|
end
|
data/lib/addic7ed/subtitle.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Addic7ed
|
2
2
|
class Subtitle
|
3
3
|
|
4
|
-
attr_reader :version, :language, :status, :via, :downloads
|
4
|
+
attr_reader :version, :language, :status, :via, :downloads, :comment
|
5
5
|
attr_accessor :url
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@version = options[:version]
|
8
|
+
@version = normalize_version(options[:version])
|
9
9
|
@language = options[:language]
|
10
10
|
@status = options[:status]
|
11
11
|
@url = options[:url]
|
12
12
|
@via = options[:via]
|
13
13
|
@downloads = options[:downloads].to_i || 0
|
14
|
-
|
14
|
+
@comment = normalize_comment(options[:comment])
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_s
|
@@ -40,30 +40,42 @@ module Addic7ed
|
|
40
40
|
|
41
41
|
protected
|
42
42
|
|
43
|
-
def normalize_version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
def normalize_version(version)
|
44
|
+
(version || "").
|
45
|
+
gsub(/^Version */i, '').
|
46
|
+
gsub(/720p/i, '').
|
47
|
+
gsub(/hdtv/i, '').
|
48
|
+
gsub(/proper/i, '').
|
49
|
+
gsub(/rerip/i, '').
|
50
|
+
gsub(/x\.?264/i, '').
|
51
|
+
gsub(/^[- \.]*/, '').
|
52
|
+
gsub(/[- \.]*$/, '').
|
53
|
+
upcase
|
54
|
+
end
|
55
|
+
|
56
|
+
def normalize_comment(comment)
|
57
|
+
(comment || "").downcase
|
54
58
|
end
|
55
59
|
|
56
60
|
def is_compatible_with?(other_version)
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
generally_compatible_with?(other_version) || commented_as_compatible_with?(other_version)
|
62
|
+
end
|
63
|
+
|
64
|
+
def generally_compatible_with?(other_version)
|
65
|
+
version == other_version || COMPATIBILITY_720P[version] == other_version || COMPATIBILITY_720P[other_version] == version
|
66
|
+
end
|
67
|
+
|
68
|
+
def commented_as_compatible_with?(other_version)
|
69
|
+
res = comment.include? other_version.downcase
|
70
|
+
res ||= comment.include? COMPATIBILITY_720P[other_version].downcase if COMPATIBILITY_720P[other_version]
|
71
|
+
res ||= comment.include? COMPATIBILITY_720P[version].downcase if COMPATIBILITY_720P[version]
|
72
|
+
!!res
|
60
73
|
end
|
61
74
|
|
62
75
|
def is_more_popular_than?(other_subtitle)
|
63
76
|
return true if other_subtitle.nil?
|
64
77
|
return false if other_subtitle.is_featured?
|
65
|
-
return
|
78
|
+
return downloads > other_subtitle.downloads
|
66
79
|
end
|
67
|
-
|
68
80
|
end
|
69
81
|
end
|
data/lib/addic7ed/version.rb
CHANGED
@@ -57,7 +57,7 @@ describe Addic7ed::Subtitle, "#to_s" do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe Addic7ed::Subtitle, "#works_for?" do
|
60
|
-
let(:subtitle) { Addic7ed::Subtitle.new(version: "DIMENSION") }
|
60
|
+
let(:subtitle) { Addic7ed::Subtitle.new(version: "DIMENSION", comment: "Works with IMMERSE") }
|
61
61
|
|
62
62
|
context "when it is incomplete" do
|
63
63
|
before { allow(subtitle).to receive(:is_completed?).and_return(false) }
|
@@ -81,6 +81,18 @@ describe Addic7ed::Subtitle, "#works_for?" do
|
|
81
81
|
it "returns false given an incompatible version" do
|
82
82
|
expect(subtitle.works_for? "EVOLVE").to be false
|
83
83
|
end
|
84
|
+
|
85
|
+
it "returns true given the same version as comment" do
|
86
|
+
expect(subtitle.works_for? "IMMERSE").to be true
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns true given a compatible version as comment" do
|
90
|
+
expect(subtitle.works_for? "ASAP").to be true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns false given an incompatible version as comment" do
|
94
|
+
expect(subtitle.works_for? "KILLERS").to be false
|
95
|
+
end
|
84
96
|
end
|
85
97
|
end
|
86
98
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addic7ed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Baudino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.4.
|
134
|
+
rubygems_version: 2.4.8
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Addic7ed auto-downloader
|