tivohmo 0.3.0 → 0.3.1

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +5 -0
  3. data/README.md +8 -0
  4. data/TODO +4 -0
  5. data/lib/tivohmo/adapters/filesystem/application.rb +37 -0
  6. data/lib/tivohmo/adapters/filesystem/file_item.rb +3 -1
  7. data/lib/tivohmo/adapters/filesystem/folder_container.rb +33 -29
  8. data/lib/tivohmo/adapters/filesystem/group.rb +22 -0
  9. data/lib/tivohmo/adapters/filesystem.rb +1 -0
  10. data/lib/tivohmo/adapters/plex/category.rb +20 -13
  11. data/lib/tivohmo/adapters/plex/episode.rb +2 -2
  12. data/lib/tivohmo/adapters/plex/movie.rb +2 -2
  13. data/lib/tivohmo/adapters/streamio/transcoder.rb +4 -13
  14. data/lib/tivohmo/api/container.rb +4 -1
  15. data/lib/tivohmo/subtitles_util.rb +109 -0
  16. data/lib/tivohmo/version.rb +1 -1
  17. data/spec/adapters/filesystem/application_spec.rb +66 -0
  18. data/spec/adapters/filesystem/file_item_spec.rb +12 -0
  19. data/spec/adapters/filesystem/folder_container_spec.rb +23 -21
  20. data/spec/adapters/plex/category_spec.rb +15 -5
  21. data/spec/adapters/plex/episode_spec.rb +11 -0
  22. data/spec/adapters/plex/movie_spec.rb +11 -0
  23. data/spec/adapters/streamio/transcoder_spec.rb +24 -0
  24. data/spec/fixtures/vcr/TivoHMO_Adapters_Plex_Category/_children/should_have_children.yml +698 -168
  25. data/spec/fixtures/vcr/TivoHMO_Adapters_Plex_Category/_children/should_have_children_with_embedded_subtitles.yml +22 -22
  26. data/spec/fixtures/vcr/TivoHMO_Adapters_Plex_Category/_children/should_have_children_with_subtitles.yml +262 -91
  27. data/spec/fixtures/vcr/TivoHMO_Adapters_Plex_Episode/_initialize/should_instantiate_with_subtitle.yml +444 -0
  28. data/spec/fixtures/vcr/TivoHMO_Adapters_Plex_Movie/_initialize/should_instantiate_with_subtitle.yml +334 -0
  29. data/spec/spec_helper.rb +21 -0
  30. data/spec/subtitles_util_spec.rb +68 -0
  31. data/tivohmo.gemspec +1 -0
  32. metadata +24 -3
@@ -42,6 +42,14 @@ describe TivoHMO::Adapters::Plex::Category, :vcr do
42
42
 
43
43
  describe "#children" do
44
44
 
45
+ before(:each) do
46
+ if ENV['CI']
47
+ stub_subtitles("/Users/mconway/Movies/TivoHMOTest/Movies/3 Idiots (2009).avi")
48
+ stub_subtitles("/Users/mconway/Movies/TivoHMOTest/Movies/Wyrmwood (2014).avi", language_code: nil)
49
+ stub_subtitles("/Users/mconway/Movies/TivoHMOTest/Movies/Rurouni Kenshin Kyoto Inferno (2014).mkv", language_code: nil)
50
+ end
51
+ end
52
+
45
53
  it "should memoize" do
46
54
  section = described_class.new(plex_delegate, :newest)
47
55
  expect(section.children.object_id).to eq(section.children.object_id)
@@ -52,9 +60,9 @@ describe TivoHMO::Adapters::Plex::Category, :vcr do
52
60
 
53
61
  expect(section.children.size).to_not be(0)
54
62
 
55
- keys = section.children.collect(&:delegate).collect(&:key)
56
- expected_keys = plex_delegate.newest.collect(&:key)
57
- expect(keys).to include(*expected_keys)
63
+ titles = section.children.collect(&:title)
64
+ expected_titles = plex_delegate.newest.collect(&:title)
65
+ expect(titles).to include(*expected_titles)
58
66
  end
59
67
 
60
68
  it "should display non-zero child_count once children fetched" do
@@ -67,6 +75,7 @@ describe TivoHMO::Adapters::Plex::Category, :vcr do
67
75
  end
68
76
 
69
77
  it "should have children with subtitles" do
78
+ described_class.config_set(:enable_subtitles, true)
70
79
  section = described_class.new(plex_delegate, :newest)
71
80
 
72
81
  subgroup = section.children.find {|c| c.is_a?(TivoHMO::Adapters::Plex::Group) }
@@ -85,11 +94,12 @@ describe TivoHMO::Adapters::Plex::Category, :vcr do
85
94
  end
86
95
 
87
96
  it "should have children with embedded subtitles" do
97
+ described_class.config_set(:enable_subtitles, true)
88
98
  section = described_class.new(plex_delegate, :newest)
89
99
 
90
100
  subgroup = section.children.find {|c|
91
101
  c.is_a?(TivoHMO::Adapters::Plex::Group) &&
92
- c.children.any? {|m| m.subtitle && m.subtitle.language == 'Embedded' }
102
+ c.children.any? {|m| m.subtitle && m.subtitle.type == :embedded }
93
103
  }
94
104
  expect(subgroup).to_not be_nil
95
105
  primary = subgroup.children[0]
@@ -97,7 +107,7 @@ describe TivoHMO::Adapters::Plex::Category, :vcr do
97
107
  expect(primary.title).to_not match(/sub\]/)
98
108
  expect(sub.title).to match(primary.title)
99
109
  expect(sub.title).to match(/sub\]/)
100
- expect(sub.subtitle.language).to eq('Embedded')
110
+ expect(sub.subtitle.language).to_not be_nil
101
111
  expect(sub.subtitle.language_code).to_not be_nil
102
112
  expect(sub.subtitle.location).to eq(0)
103
113
  end
@@ -24,6 +24,17 @@ describe TivoHMO::Adapters::Plex::Episode, :vcr do
24
24
  expect(episode.created_at).to eq(Time.parse(plex_delegate.originally_available_at))
25
25
  end
26
26
 
27
+ it "should instantiate with subtitle" do
28
+ st = TivoHMO::API::Subtitle.new()
29
+ st.language_code = 'en'
30
+ st.language = 'English'
31
+ st.type = :file
32
+ episode = described_class.new(plex_delegate, st)
33
+ expect(episode).to be_a described_class
34
+ expect(episode.subtitle).to eq(st)
35
+ expect(episode.title).to eq "[en file sub] #{plex_delegate.title}"
36
+ end
37
+
27
38
  end
28
39
 
29
40
  describe "#metadata" do
@@ -19,6 +19,17 @@ describe TivoHMO::Adapters::Plex::Movie, :vcr do
19
19
  expect(movie.created_at).to eq(Time.parse(plex_delegate.originally_available_at))
20
20
  end
21
21
 
22
+ it "should instantiate with subtitle" do
23
+ st = TivoHMO::API::Subtitle.new()
24
+ st.language_code = 'en'
25
+ st.language = 'English'
26
+ st.type = :file
27
+ movie = described_class.new(plex_delegate, st)
28
+ expect(movie).to be_a described_class
29
+ expect(movie.subtitle).to eq(st)
30
+ expect(movie.title).to eq "[en file sub] #{plex_delegate.title}"
31
+ end
32
+
22
33
  end
23
34
 
24
35
  describe "#metadata" do
@@ -24,6 +24,30 @@ describe TivoHMO::Adapters::StreamIO::Transcoder do
24
24
  expect(opts).to be_instance_of(Hash)
25
25
  end
26
26
 
27
+ it "handles file subtitles" do
28
+ st = TivoHMO::API::Subtitle.new()
29
+ st.language_code = 'en'
30
+ st.language = 'English'
31
+ st.type = :file
32
+ st.location = Tempfile.new(['subtitle', '.en.srt']).path
33
+ item.subtitle = st
34
+
35
+ opts = subject.transcoder_options
36
+ expect(opts[:custom]).to match("-vf subtitles=\"#{st.location}\"")
37
+ end
38
+
39
+ it "handles embedded subtitles" do
40
+ st = TivoHMO::API::Subtitle.new()
41
+ st.language_code = 'en'
42
+ st.language = 'English'
43
+ st.type = :embedded
44
+ st.location = 3
45
+ item.subtitle = st
46
+
47
+ opts = subject.transcoder_options
48
+ expect(opts[:custom]).to match("-vf subtitles=\"#{item.file}\":si=#{st.location}")
49
+ end
50
+
27
51
  end
28
52
 
29
53
  describe "#transcode" do