addic7ed 2.0.1 → 2.0.2

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: 0d3890d1e46e13f0c3723d7920aafd15010445ff
4
- data.tar.gz: 26c22db148789cfe188f49b2b9dbd36ac77ade91
3
+ metadata.gz: 32e131ca12d3e3478d6b1c74165907737e3ee5c9
4
+ data.tar.gz: 433d4e43d15508a69a1ecd373dc59f2940763278
5
5
  SHA512:
6
- metadata.gz: dc559f309a1fc2a4fdb7cd891ca464afc4db7ee5027961b70c7768f33b64c5e5ae16d69184eea4ffd682671c679c3ad2aec657a298753d5e4c7ce1bac9f6b6e6
7
- data.tar.gz: 3cbd2bd9e0283ac42695fcae3e39e0fde44020257c2ab9e5314a0a58c0c4d832f932d7ae933fbf2cba2b5a77c0287c8e9073be9943b89faba51d69e5732f9234
6
+ metadata.gz: d48aff4625c23cac1618b4b053bf8f9a0e5a68cb1c9d5f1105d35c2e3e916aa044e69276074c1abda129ea292b797d9f67522bc162697fff57ebb8f31574a11b
7
+ data.tar.gz: 26e1a7d7e651016edfc33050bfcca18945e724ab6b256edb1867d4696a4aea217da25e90eab9f1d021b4c0c4d1bffa55795b869e9da647d583014d608a03e358
@@ -116,7 +116,7 @@ options[:filenames].each do |filename|
116
116
  puts "Show not found on Addic7ed : #{ep.video_file.showname}. Skipping.".gsub(/^/, options[:verbose] ? ' ' : '') unless options[:quiet]
117
117
  next
118
118
  rescue Addic7ed::EpisodeNotFound
119
- puts "Episode not found on Addic7ed : #{Addic7ed::ShowList.find(ep.video_file.showname)} S#{ep.video_file.season}E#{ep.video_file.episode}. Skipping.".gsub(/^/, options[:verbose] ? ' ' : '') unless options[:quiet]
119
+ puts "Episode not found on Addic7ed : #{Addic7ed::ShowList.url_segment_for(ep.video_file.showname)} S#{ep.video_file.season}E#{ep.video_file.episode}. Skipping.".gsub(/^/, options[:verbose] ? ' ' : '') unless options[:quiet]
120
120
  next
121
121
  rescue Addic7ed::LanguageNotSupported
122
122
  puts "Addic7ed does not support language '#{options[:language]}'. Exiting.".gsub(/^/, options[:verbose] ? ' ' : '') unless options[:quiet]
@@ -11,12 +11,34 @@ module Addic7ed
11
11
  end
12
12
 
13
13
  def url_segment_for
14
- raise ShowNotFound if matching_shows.empty?
15
- matching_shows.first.gsub(' ', '_')
14
+ shows_matching = shows_matching_exactly
15
+ shows_matching = shows_matching_without_year if shows_matching.empty?
16
+ raise ShowNotFound if shows_matching.empty?
17
+ shows_matching.last.gsub(' ', '_')
16
18
  end
17
19
 
18
20
  private
19
21
 
22
+ def shows_matching_exactly
23
+ @shows_matching_exactly ||= addic7ed_shows.select{ |addic7ed_show| is_matching? addic7ed_show }
24
+ end
25
+
26
+ def shows_matching_without_year
27
+ @shows_matching_without_year ||= addic7ed_shows.select{ |addic7ed_show| is_matching? addic7ed_show, :comparer_without_year }
28
+ end
29
+
30
+ def default_comparer(showname)
31
+ showname.downcase.gsub("'", "")
32
+ end
33
+
34
+ def comparer_without_year(showname)
35
+ default_comparer(showname).gsub(/ \(\d{4}\)( |$)/, '\1')
36
+ end
37
+
38
+ def is_matching?(addic7ed_show, comparer = :default_comparer)
39
+ [humanized_name, addic7ed_show].map(&method(comparer)).reduce(:==)
40
+ end
41
+
20
42
  def humanized_name
21
43
  @humanized_name ||= raw_name.
22
44
  gsub(/[_\.]+/, ' ').
@@ -24,12 +46,6 @@ module Addic7ed
24
46
  gsub(/ (\d{4})( |$)/i, ' (\1)\2')
25
47
  end
26
48
 
27
- def matching_shows
28
- @matching_shows ||= addic7ed_shows.select do |addic7ed_show|
29
- [addic7ed_show, humanized_name].map{ |showname| showname.downcase.gsub("'", "") }.reduce(:==)
30
- end
31
- end
32
-
33
49
  def addic7ed_shows
34
50
  @@addic7ed_shows ||= Nokogiri::HTML(addic7ed_homepage.body).css("select#qsShow option:not(:first-child)").map(&:text)
35
51
  end
@@ -1,3 +1,3 @@
1
1
  module Addic7ed
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -19,6 +19,11 @@ describe Addic7ed::ShowList, ".url_segment_for" do
19
19
  expect(Addic7ed::ShowList.url_segment_for("Vikings.2013")).to eq "Vikings_(2013)"
20
20
  end
21
21
 
22
+ it "returns last show when production year is unspecified" do
23
+ expect(Addic7ed::ShowList.url_segment_for("Empire")).to eq "Empire_(2015)"
24
+ expect(Addic7ed::ShowList.url_segment_for("American.Crime")).to eq "American_Crime_(2015)"
25
+ end
26
+
22
27
  it "handles when both country code and production year are present" do
23
28
  expect(Addic7ed::ShowList.url_segment_for("Legacy.2013.UK")).to eq "Legacy_(2013)_(UK)"
24
29
  end
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: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Baudino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec