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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d5ff8f9da39da43045c9cad1deb440fa6a54d8c
4
- data.tar.gz: bad8feb10529aebe17e1507fd30b7db2f77d7c01
3
+ metadata.gz: e0aa248ebc4fcafb170fae075a92411a680dc0d6
4
+ data.tar.gz: 15f47c43f826b6c36e766174da212a974f9e0739
5
5
  SHA512:
6
- metadata.gz: f76e8571f9d431a8ce5fbaa6b958ae334e6fb2a88210ba5fe3a5964f0e07723fa32648aa557507e35ee9e8e44c0100a7b1c6b66d7b6f89ac6c6bf63792074b80
7
- data.tar.gz: 5d5241b0f9a27a839eff5f1cbbf47112fd83932e136bfa9d629b9cfad1ea62dc89c1ef432158281b21927b31b9a7063a71509c85af7e86c7b596accb0aec105f
6
+ metadata.gz: 40c27a33fe83c0c872f2e9c1ae58f80bf146c074df9a788ae741c84a111be5fa4f91b9f218c934419f1dbca9a56fcf568aa57956b625dda30103976faa8114d3
7
+ data.tar.gz: 1f2eedc563450c9f068f914f171dc9dc2fecb1672683e64a165053bb4e6995f32896af60fca4a0832dc93779f8202c62f253e6c3d9c1f6987e16594912b7b739
@@ -5,38 +5,57 @@ require 'net/http'
5
5
 
6
6
  module GetAddic7ed
7
7
  class Subtitle
8
- attr_reader :episode, :lang, :link, :page_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
- @link = get_subtitle_link
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(20) + ": #{GetAddic7ed::LANGUAGES[@lang][:name]}"
19
- puts "Hearing Impaired".ljust(20) + ": #{@hi}"
20
- puts "Page Link".ljust(20) + ": #{@page}"
21
- puts "Download Link".ljust(20) + ": #{@link}"
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 get_subtitle_link
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 == 1
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[choose_sub(sub_list)][:link]
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
 
@@ -1,3 +1,3 @@
1
1
  module GetAddic7ed
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get-addic7ed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Vergoz