addic7ed 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/addic7ed/episode.rb +4 -2
- data/lib/addic7ed/subtitle.rb +4 -3
- data/lib/addic7ed/version.rb +1 -1
- data/spec/addic7ed-subtitle_spec.rb +26 -26
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Ruby command-line script to fetch subtitles on Addic7ed
|
5
5
|
|
6
|
-
Current version: **0.1.
|
6
|
+
Current version: **0.1.8**
|
7
7
|
|
8
8
|
### Is it working ?
|
9
9
|
|
@@ -68,6 +68,7 @@ There's some work remaining:
|
|
68
68
|
|
69
69
|
### Changelog
|
70
70
|
|
71
|
+
* 0.1.8: Added priority to subtitles uploaded by Addic7ed staff
|
71
72
|
* 0.1.7: Fixed a bug when a subtitle had multiple revisions on Addic7ed.com
|
72
73
|
* 0.1.6: Enhanced subtitles version string filters (remove heading and trailing dashes)
|
73
74
|
* 0.1.5: Enhanced subtitles version string filters (remove heading and trailing spaces and dots)
|
data/lib/addic7ed/episode.rb
CHANGED
@@ -41,7 +41,7 @@ module Addic7ed
|
|
41
41
|
@best_subtitle ||= {}
|
42
42
|
subtitles(lang).each do |sub|
|
43
43
|
if sub.status == 'Completed' and (sub.version == @filename.group or COMPATIBILITY_720P[sub.version] == @filename.group)
|
44
|
-
@best_subtitle[lang] = sub unless @best_subtitle[lang] and @best_subtitle[lang].downloads > sub.downloads
|
44
|
+
@best_subtitle[lang] = sub unless @best_subtitle[lang] and (@best_subtitle[lang].downloads > sub.downloads or @best_subtitle[lang].via == 'http://addic7ed.com')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
raise NoSubtitleFound unless @best_subtitle[lang]
|
@@ -93,9 +93,11 @@ module Addic7ed
|
|
93
93
|
status = status_node.content.strip
|
94
94
|
url_node = sub_node.css('a.buttonDownload').last
|
95
95
|
url = 'http://www.addic7ed.com' + url_node['href']
|
96
|
+
via_node = sub_node.css('tr:nth-child(3) td:first-child a').first
|
97
|
+
via = via_node['href'] if via_node
|
96
98
|
downloads_node = sub_node.css('tr:nth-child(4) td.newsDate').first
|
97
99
|
downloads = /(?<downloads>\d*) Downloads/.match(downloads_node.content)[:downloads]
|
98
|
-
Addic7ed::Subtitle.new(version, language, status, url, downloads)
|
100
|
+
Addic7ed::Subtitle.new(version, language, status, url, via, downloads)
|
99
101
|
rescue
|
100
102
|
raise ParsingError
|
101
103
|
end
|
data/lib/addic7ed/subtitle.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
module Addic7ed
|
2
2
|
class Subtitle
|
3
3
|
|
4
|
-
attr_reader :version, :language, :status, :downloads
|
4
|
+
attr_reader :version, :language, :status, :via, :downloads
|
5
5
|
attr_accessor :url
|
6
6
|
|
7
|
-
def initialize(version, language, status, url, downloads)
|
7
|
+
def initialize(version, language, status, url, via, downloads)
|
8
8
|
@version = normalized_version(version)
|
9
9
|
@language = language
|
10
10
|
@status = status
|
11
11
|
@url = url
|
12
|
+
@via = via
|
12
13
|
@downloads = downloads.to_i
|
13
14
|
end
|
14
15
|
|
15
16
|
def to_s
|
16
|
-
"#{url}\t->\t#{@version} (#{language}, #{status}) [#{@downloads} downloads]"
|
17
|
+
"#{url}\t->\t#{@version} (#{language}, #{status}) [#{@downloads} downloads]#{" (via #{via})" if @via}"
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
data/lib/addic7ed/version.rb
CHANGED
@@ -7,50 +7,50 @@ describe Addic7ed::Subtitle do
|
|
7
7
|
|
8
8
|
describe '#normalized_version' do
|
9
9
|
it 'should upcase the version string' do
|
10
|
-
Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '0').version.should == 'DIMENSION'
|
10
|
+
Addic7ed::Subtitle.new('DiMENSiON', '', '', '', '', '0').version.should == 'DIMENSION'
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should remove heading and trailing dots' do
|
14
|
-
Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
15
|
-
Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '0').version.should == 'DIMENSION'
|
16
|
-
Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '0').version.should == 'DIMENSION'
|
14
|
+
Addic7ed::Subtitle.new('.DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
15
|
+
Addic7ed::Subtitle.new('DIMENSION.', '', '', '', '', '0').version.should == 'DIMENSION'
|
16
|
+
Addic7ed::Subtitle.new('.DIMENSION.', '', '', '', '', '0').version.should == 'DIMENSION'
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should remove heading and trailing whitespaces' do
|
20
|
-
Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
21
|
-
Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '0').version.should == 'DIMENSION'
|
22
|
-
Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '0').version.should == 'DIMENSION'
|
20
|
+
Addic7ed::Subtitle.new(' DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
21
|
+
Addic7ed::Subtitle.new('DIMENSION ', '', '', '', '', '0').version.should == 'DIMENSION'
|
22
|
+
Addic7ed::Subtitle.new(' DIMENSION ', '', '', '', '', '0').version.should == 'DIMENSION'
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should remove heading and trailing dashes' do
|
26
|
-
Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
27
|
-
Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '0').version.should == 'DIMENSION'
|
28
|
-
Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '0').version.should == 'DIMENSION'
|
26
|
+
Addic7ed::Subtitle.new('-DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
27
|
+
Addic7ed::Subtitle.new('DIMENSION-', '', '', '', '', '0').version.should == 'DIMENSION'
|
28
|
+
Addic7ed::Subtitle.new('-DIMENSION-', '', '', '', '', '0').version.should == 'DIMENSION'
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should automatically remove "720p" in version string' do
|
32
|
-
Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
33
|
-
Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
34
|
-
Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '0').version.should == 'DIMENSION'
|
35
|
-
Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '0').version.should == 'DIMENSION'
|
32
|
+
Addic7ed::Subtitle.new('720p DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
33
|
+
Addic7ed::Subtitle.new('720P DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
34
|
+
Addic7ed::Subtitle.new('DIMENSION 720p', '', '', '', '', '0').version.should == 'DIMENSION'
|
35
|
+
Addic7ed::Subtitle.new('DIMENSION 720P', '', '', '', '', '0').version.should == 'DIMENSION'
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should automatically remove "HDTV" in version string' do
|
39
|
-
Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
40
|
-
Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
41
|
-
Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '0').version.should == 'DIMENSION'
|
42
|
-
Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '0').version.should == 'DIMENSION'
|
39
|
+
Addic7ed::Subtitle.new('hdtv DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
40
|
+
Addic7ed::Subtitle.new('HDTV DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
41
|
+
Addic7ed::Subtitle.new('DIMENSION hdtv', '', '', '', '', '0').version.should == 'DIMENSION'
|
42
|
+
Addic7ed::Subtitle.new('DIMENSION HDTV', '', '', '', '', '0').version.should == 'DIMENSION'
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should automatically remove "x264" in version string' do
|
46
|
-
Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
47
|
-
Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
48
|
-
Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
49
|
-
Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '0').version.should == 'DIMENSION'
|
50
|
-
Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '0').version.should == 'DIMENSION'
|
51
|
-
Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '0').version.should == 'DIMENSION'
|
52
|
-
Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '0').version.should == 'DIMENSION'
|
53
|
-
Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '0').version.should == 'DIMENSION'
|
46
|
+
Addic7ed::Subtitle.new('x264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
47
|
+
Addic7ed::Subtitle.new('X264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
48
|
+
Addic7ed::Subtitle.new('x.264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
49
|
+
Addic7ed::Subtitle.new('X.264 DIMENSION', '', '', '', '', '0').version.should == 'DIMENSION'
|
50
|
+
Addic7ed::Subtitle.new('DIMENSION x264', '', '', '', '', '0').version.should == 'DIMENSION'
|
51
|
+
Addic7ed::Subtitle.new('DIMENSION X264', '', '', '', '', '0').version.should == 'DIMENSION'
|
52
|
+
Addic7ed::Subtitle.new('DIMENSION x.264', '', '', '', '', '0').version.should == 'DIMENSION'
|
53
|
+
Addic7ed::Subtitle.new('DIMENSION X.264', '', '', '', '', '0').version.should == 'DIMENSION'
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|