addic7ed 4.0.0.pre.beta.5 → 4.0.0.pre.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/addic7ed.rb +2 -0
- data/lib/addic7ed/common.rb +3 -1
- data/lib/addic7ed/errors.rb +2 -0
- data/lib/addic7ed/models/episode.rb +3 -1
- data/lib/addic7ed/models/search.rb +3 -1
- data/lib/addic7ed/models/subtitle.rb +2 -0
- data/lib/addic7ed/models/subtitles_collection.rb +3 -1
- data/lib/addic7ed/models/video_file.rb +2 -0
- data/lib/addic7ed/service.rb +2 -0
- data/lib/addic7ed/services/check_compatibility.rb +15 -5
- data/lib/addic7ed/services/download_subtitle.rb +8 -2
- data/lib/addic7ed/services/get_shows_list.rb +5 -3
- data/lib/addic7ed/services/normalize_comment.rb +2 -0
- data/lib/addic7ed/services/normalize_version.rb +2 -0
- data/lib/addic7ed/services/parse_page.rb +3 -1
- data/lib/addic7ed/services/parse_subtitle.rb +5 -3
- data/lib/addic7ed/services/url_encode_show_name.rb +3 -1
- data/lib/addic7ed/version.rb +3 -1
- metadata +3 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2a0a0fd093c29b07a62a7259c773df5343c4c2c
|
4
|
+
data.tar.gz: 03110733e1ba66da173b5ad852ea3668dcbc7f4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c06455d2aad3610b7321dffd54f88f6d426087872083d96ae3284d21e6853936d883d76eff11390f7ffd8774ff0177126edce6460bec03288d1ad1789e6ec89d
|
7
|
+
data.tar.gz: 6b2a108af177c4b6096ef55152b233319893a7cd967e1e1a11daea8006f76933ecc783a44b585fdceb29f0dd32e446b0865a363c553fe20e7d027536d46e8fd4
|
data/lib/addic7ed.rb
CHANGED
data/lib/addic7ed/common.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
|
3
5
|
module Addic7ed
|
4
6
|
CONFIG_FILE = File.join(File.dirname(__FILE__), "config.json").freeze
|
5
|
-
CONFIG = JSON.
|
7
|
+
CONFIG = JSON.parse(File.read(CONFIG_FILE), symbolize_names: true).freeze
|
6
8
|
LANGUAGES = CONFIG[:languages].freeze
|
7
9
|
USER_AGENTS = CONFIG[:user_agents].freeze
|
8
10
|
SHOWS_URL = CONFIG[:urls][:shows].freeze
|
data/lib/addic7ed/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "net/http"
|
2
4
|
require "open-uri"
|
3
5
|
|
@@ -91,7 +93,7 @@ module Addic7ed
|
|
91
93
|
localized_urls[language]
|
92
94
|
end
|
93
95
|
|
94
|
-
|
96
|
+
private
|
95
97
|
|
96
98
|
def localized_urls
|
97
99
|
@localized_urls ||= languages_hash { |code, lang| { code => localized_url(lang[:id]) } }
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Addic7ed
|
2
4
|
# Represents a subtitle search for a +video_filename+ in a +language+ with
|
3
5
|
# multiple search +criterias+.
|
@@ -79,7 +81,7 @@ module Addic7ed
|
|
79
81
|
@best_subtitle ||= matching_subtitles.most_popular
|
80
82
|
end
|
81
83
|
|
82
|
-
|
84
|
+
private
|
83
85
|
|
84
86
|
def default_criterias
|
85
87
|
{
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Addic7ed
|
2
4
|
# Represents a collection of {Subtitle} objects.
|
3
5
|
#
|
@@ -54,7 +56,7 @@ module Addic7ed
|
|
54
56
|
sort_by(&:downloads).last
|
55
57
|
end
|
56
58
|
|
57
|
-
|
59
|
+
private
|
58
60
|
|
59
61
|
def select
|
60
62
|
SubtitlesCollection.new(super)
|
data/lib/addic7ed/service.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Addic7ed
|
2
4
|
class CheckCompatibility
|
3
5
|
include Service
|
@@ -13,7 +15,7 @@ module Addic7ed
|
|
13
15
|
defined_as_compatible? || generally_compatible? || commented_as_compatible?
|
14
16
|
end
|
15
17
|
|
16
|
-
|
18
|
+
private
|
17
19
|
|
18
20
|
def defined_as_compatible?
|
19
21
|
subtitle.version.split(",").include? group
|
@@ -24,13 +26,21 @@ module Addic7ed
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def commented_as_compatible?
|
27
|
-
return false if
|
28
|
-
return false if
|
29
|
-
|
29
|
+
return false if comment_explicitely_wont_work?
|
30
|
+
return false if comment_is_a_resync?
|
31
|
+
comment_matches_a_compatible_group?
|
30
32
|
end
|
31
33
|
|
32
34
|
def comment_matches_a_compatible_group?
|
33
|
-
Regexp.new("(#{compatible_groups.join(
|
35
|
+
!Regexp.new("(#{compatible_groups.join("|")})", "i").match(subtitle.comment).nil?
|
36
|
+
end
|
37
|
+
|
38
|
+
def comment_explicitely_wont_work?
|
39
|
+
!/(won'?t|doesn'?t|not) +work/i.match(subtitle.comment).nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
def comment_is_a_resync?
|
43
|
+
!/resync +(from|of|for)/i.match(subtitle.comment).nil?
|
34
44
|
end
|
35
45
|
|
36
46
|
def compatible_groups
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Addic7ed
|
2
4
|
class DownloadSubtitle
|
3
5
|
include Service
|
@@ -15,17 +17,21 @@ module Addic7ed
|
|
15
17
|
|
16
18
|
def call
|
17
19
|
raise DownloadError, "Too many HTTP redirections" if redirect_count >= HTTP_REDIRECT_LIMIT
|
18
|
-
raise DailyLimitExceeded, "Daily limit exceeded" if
|
20
|
+
raise DailyLimitExceeded, "Daily limit exceeded" if download_limit_exceeded?
|
19
21
|
return follow_redirection(response["location"]) if response.is_a? Net::HTTPRedirection
|
20
22
|
write(response.body)
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
private
|
24
26
|
|
25
27
|
def uri
|
26
28
|
@uri ||= URI(url)
|
27
29
|
end
|
28
30
|
|
31
|
+
def download_limit_exceeded?
|
32
|
+
!%r{^/downloadexceeded.php}.match(url).nil?
|
33
|
+
end
|
34
|
+
|
29
35
|
def response
|
30
36
|
@response ||= Net::HTTP.start(uri.hostname, uri.port) do |http|
|
31
37
|
request = Net::HTTP::Get.new(uri.request_uri)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "singleton"
|
2
4
|
|
3
5
|
module Addic7ed
|
@@ -9,13 +11,13 @@ module Addic7ed
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def call
|
12
|
-
@shows ||= homepage_body.css("select#qsShow option
|
14
|
+
@shows ||= homepage_body.css("select#qsShow option").to_a[1..-1].map(&:text)
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
private
|
16
18
|
|
17
19
|
def homepage_body
|
18
|
-
|
20
|
+
Oga.parse_html(addic7ed_homepage.body)
|
19
21
|
end
|
20
22
|
|
21
23
|
def addic7ed_homepage
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "oga"
|
2
4
|
require "net/http"
|
3
5
|
require "open-uri"
|
@@ -17,7 +19,7 @@ module Addic7ed
|
|
17
19
|
subtitles_nodes.map { |subtitle_node| Addic7ed::ParseSubtitle.call(subtitle_node) }
|
18
20
|
end
|
19
21
|
|
20
|
-
|
22
|
+
private
|
21
23
|
|
22
24
|
def page_dom
|
23
25
|
raise EpisodeNotFound if server_response.body.nil? || server_response.body.empty?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "oga"
|
2
4
|
|
3
5
|
module Addic7ed
|
@@ -6,7 +8,7 @@ module Addic7ed
|
|
6
8
|
|
7
9
|
attr_reader :subtitle_node
|
8
10
|
|
9
|
-
FIELDS = [
|
11
|
+
FIELDS = %i[version language status url source hi downloads comment].freeze
|
10
12
|
|
11
13
|
def initialize(subtitle_node)
|
12
14
|
@subtitle_node = subtitle_node
|
@@ -16,7 +18,7 @@ module Addic7ed
|
|
16
18
|
Addic7ed::Subtitle.new(extract_fields)
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
private
|
20
22
|
|
21
23
|
def extract_fields
|
22
24
|
FIELDS.map do |field|
|
@@ -48,7 +50,7 @@ module Addic7ed
|
|
48
50
|
|
49
51
|
def extract_url
|
50
52
|
extract_field("a.buttonDownload:last-of-type") do |node|
|
51
|
-
"http://www.addic7ed.com#{node[
|
53
|
+
"http://www.addic7ed.com#{node["href"]}"
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Addic7ed
|
2
4
|
class URLEncodeShowName
|
3
5
|
include Service
|
@@ -18,7 +20,7 @@ module Addic7ed
|
|
18
20
|
matching_shows.last.tr(" ", "_")
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
private
|
22
24
|
|
23
25
|
def matching_shows(opts)
|
24
26
|
addic7ed_shows.select { |show_name| matching?(show_name, opts) }
|
data/lib/addic7ed/version.rb
CHANGED
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: 4.0.0.pre.beta.
|
4
|
+
version: 4.0.0.pre.beta.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Baudino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2.7'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: json
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.8.3
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.8.3
|
139
125
|
description: Ruby script (cli) to fetch subtitles on Addic7ed
|
140
126
|
email: michael.baudino@alpine-lab.com
|
141
127
|
executables: []
|
@@ -182,9 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
168
|
version: 1.3.1
|
183
169
|
requirements: []
|
184
170
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.6.11
|
186
172
|
signing_key:
|
187
173
|
specification_version: 4
|
188
174
|
summary: Addic7ed auto-downloader
|
189
175
|
test_files: []
|
190
|
-
has_rdoc:
|