addic7ed 0.4.1 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1800793b2db8084946ab2e586e23e56b2f37b9f2
4
- data.tar.gz: 9b5c9bc2c534172da64ad0181390791eb8fc1974
3
+ metadata.gz: c8b67396fb48a509f39c40ea0eb6cf675ea957f4
4
+ data.tar.gz: a384a2c19ed9d8531779fe3c017b9b0b3c3b14ae
5
5
  SHA512:
6
- metadata.gz: b10e85551899f8d7a069d6555593f8cfda790a2a64b5494421d861c1d04da37e8a5aaa65ea687f5325c8b1c39fb79545df839aeacc283864c25fa52fd2ba3930
7
- data.tar.gz: 50d9f97ecc9dfaabaa396540df9ab10b692fc330ff331ee6cbdba13cdd9f5c35ed0772730dd4c754ee22c9b7dce60d8ce024dc6c2baeecf6742f20b8b31414b7
6
+ metadata.gz: a2fe1f944482ddf0283db063f94f5b038c59864b8f52bfcb9b7a8e1fce6c0df7686923b4c0f36b8adb8b248dbf7ad46591cabb8d591ec04602482b0af0a21a35
7
+ data.tar.gz: 08008fd711a85eb153cc61646b5bc57ac0dd24bc19642ada643cc3ba3beddb55da97bee6521f685a1247e7f941140f74dcf888cc5350e07ab1b56ecdb8156ddc
@@ -2,63 +2,63 @@
2
2
 
3
3
  module Addic7ed
4
4
 
5
- SHOWS_URL = 'http://www.addic7ed.com/ajax_getShows.php'
6
- EPISODES_URL = 'http://www.addic7ed.com/ajax_getEpisodes.php'
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' => 'DIMENSION',
11
- 'SYS' => 'DIMENSION',
12
- 'XII' => 'IMMERSE',
10
+ 'LOL' => 'DIMENSION',
11
+ 'SYS' => 'DIMENSION',
12
+ 'XII' => 'IMMERSE',
13
13
  'ASAP' => 'IMMERSE'
14
14
  }
15
15
 
16
16
  LANGUAGES = {
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},
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' => {name: 'Romanian', id: 26},
50
- 'ru' => {name: 'Russian', id: 19},
51
- 'sr' => {name: 'Serbian (Cyrillic)', id: 39},
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' => {name: 'Slovak', id: 25},
54
- 'sl' => {name: 'Slovenian', id: 22},
55
- 'es' => {name: 'Spanish', id: 4},
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' => {name: 'Swedish', id: 18},
59
- 'th' => {name: 'Thai', id: 46},
60
- 'tr' => {name: 'Turkish', id: 16},
61
- 'vi' => {name: 'Vietnamese', id: 45}
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
@@ -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
@@ -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
- normalize_version!
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
- @version ||= ""
45
- @version.gsub!(/^Version */i, '')
46
- @version.gsub!(/720p/i, '')
47
- @version.gsub!(/hdtv/i, '')
48
- @version.gsub!(/proper/i, '')
49
- @version.gsub!(/rerip/i, '')
50
- @version.gsub!(/x\.?264/i, '')
51
- @version.gsub!(/^[- \.]*/, '')
52
- @version.gsub!(/[- \.]*$/, '')
53
- @version.upcase!
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
- self.version == other_version ||
58
- COMPATIBILITY_720P[self.version] == other_version ||
59
- COMPATIBILITY_720P[other_version] == self.version
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 self.downloads > other_subtitle.downloads
78
+ return downloads > other_subtitle.downloads
66
79
  end
67
-
68
80
  end
69
81
  end
@@ -1,3 +1,3 @@
1
1
  module Addic7ed
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -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.1
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: 2015-05-20 00:00:00.000000000 Z
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.6
134
+ rubygems_version: 2.4.8
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Addic7ed auto-downloader