get-addic7ed 0.1.0 → 0.2.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 +4 -4
- data/lib/addic7ed/subtitle.rb +36 -11
- data/lib/addic7ed/version.rb +1 -1
- data/lib/addic7ed/videofile.rb +1 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0aa248ebc4fcafb170fae075a92411a680dc0d6
|
4
|
+
data.tar.gz: 15f47c43f826b6c36e766174da212a974f9e0739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c27a33fe83c0c872f2e9c1ae58f80bf146c074df9a788ae741c84a111be5fa4f91b9f218c934419f1dbca9a56fcf568aa57956b625dda30103976faa8114d3
|
7
|
+
data.tar.gz: 1f2eedc563450c9f068f914f171dc9dc2fecb1672683e64a165053bb4e6995f32896af60fca4a0832dc93779f8202c62f253e6c3d9c1f6987e16594912b7b739
|
data/lib/addic7ed/subtitle.rb
CHANGED
@@ -5,38 +5,57 @@ require 'net/http'
|
|
5
5
|
|
6
6
|
module GetAddic7ed
|
7
7
|
class Subtitle
|
8
|
-
attr_reader :episode, :lang, :link, :
|
8
|
+
attr_reader :episode, :lang, :page_link, :all, :link, :group
|
9
9
|
|
10
10
|
def initialize episode, lang = 'fr'
|
11
11
|
@episode = episode # Episode instance
|
12
12
|
@lang = lang
|
13
13
|
@page = get_page_link
|
14
|
-
|
14
|
+
|
15
|
+
@all = get_subtitles
|
16
|
+
if @all.length == 1
|
17
|
+
@link = @all.first[:link]
|
18
|
+
@group = @all.first[:group]
|
19
|
+
end
|
20
|
+
|
15
21
|
end
|
16
22
|
|
17
23
|
def inspect
|
18
|
-
puts "Sub Lang".ljust(
|
19
|
-
puts "Hearing Impaired".ljust(
|
20
|
-
puts "Page Link".ljust(
|
21
|
-
|
24
|
+
puts "Sub Lang".ljust(25) + ": #{GetAddic7ed::LANGUAGES[@lang][:name]}"
|
25
|
+
#TODO puts "Hearing Impaired".ljust(25) + ": #{@hi}"
|
26
|
+
puts "Page Link".ljust(25) + ": #{@page}"
|
27
|
+
unless @link == nil
|
28
|
+
puts "Group".ljust(25) + ": #{@group}"
|
29
|
+
puts "Download Link".ljust(25) + ": #{@link}"
|
30
|
+
else
|
31
|
+
puts "#{@all.length} subtitles available"
|
32
|
+
=begin
|
33
|
+
@all.each do |item|
|
34
|
+
print "\n-".ljust(3)
|
35
|
+
print "#{item[:group]}".ljust(25)
|
36
|
+
print "#{item[:lang]}".ljust(25)
|
37
|
+
print "#{item[:completed]}".ljust(20)
|
38
|
+
end
|
39
|
+
print "\n"
|
40
|
+
=end
|
41
|
+
end
|
42
|
+
|
22
43
|
end
|
23
44
|
|
24
45
|
def get_page_link
|
25
46
|
return "http://www.addic7ed.com/ajax_loadShow.php?show=#{@episode.id}&season=#{@episode.season}&langs=&hd=undeENDed&hi=#{@hi}"
|
26
47
|
end
|
27
48
|
|
28
|
-
def
|
49
|
+
def get_subtitles
|
29
50
|
puts "Searching for <#{GetAddic7ed::LANGUAGES[@lang][:name]}> subtitles..." unless GetAddic7ed::OPT_QUIET
|
30
51
|
|
31
52
|
# sub list
|
32
53
|
sub_list = get_sub_list
|
33
54
|
|
34
|
-
if sub_list.length ==
|
35
|
-
return sub_list.first[:link]
|
36
|
-
elsif sub_list.length == 0
|
55
|
+
if sub_list.length == 0
|
37
56
|
raise NoSubtitleFound
|
38
57
|
else
|
39
|
-
return sub_list
|
58
|
+
return sub_list
|
40
59
|
end
|
41
60
|
end
|
42
61
|
|
@@ -134,6 +153,12 @@ module GetAddic7ed
|
|
134
153
|
end
|
135
154
|
|
136
155
|
def download_sub
|
156
|
+
|
157
|
+
if @link == nil
|
158
|
+
the_one = @all[choose_sub(@all)]
|
159
|
+
@link = the_one[:link]
|
160
|
+
end
|
161
|
+
|
137
162
|
dir_path = File.dirname(@episode.filepath)
|
138
163
|
sub_name = File.basename(@episode.filepath, '.*')
|
139
164
|
|
data/lib/addic7ed/version.rb
CHANGED
data/lib/addic7ed/videofile.rb
CHANGED
@@ -4,12 +4,7 @@ module GetAddic7ed
|
|
4
4
|
|
5
5
|
def initialize(file)
|
6
6
|
@filepath = File.expand_path(file)
|
7
|
-
|
8
|
-
if self.class.file? (@filepath)
|
9
|
-
@filename = File.basename(@filepath)
|
10
|
-
else
|
11
|
-
raise InvalidVideoFile
|
12
|
-
end
|
7
|
+
@filename = File.basename(@filepath)
|
13
8
|
end
|
14
9
|
|
15
10
|
def inspect
|
@@ -17,24 +12,5 @@ module GetAddic7ed
|
|
17
12
|
puts "Filepath".ljust(10) + ": #{@filepath}"
|
18
13
|
end
|
19
14
|
|
20
|
-
def self.file? filepath
|
21
|
-
if File.file? (filepath)
|
22
|
-
return true
|
23
|
-
else
|
24
|
-
raise InvalidFile
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.video? filepath
|
29
|
-
if File.file? (filepath)
|
30
|
-
=begin
|
31
|
-
TODO : Find a way to make it work on windows, mac os x and linux
|
32
|
-
=end
|
33
|
-
return mimetype(filepath).start_with?("video") || File.extname(filepath) == ".mkv"
|
34
|
-
else
|
35
|
-
raise WrongArgument
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
15
|
end
|
40
16
|
end
|