royw-dvdprofiler2xbmc 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,132 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ require 'tempfile'
4
+
5
+ describe "FanartController" do
6
+
7
+ before(:all) do
8
+ logger = Log4r::Logger.new('dvdprofiler2xbmc')
9
+ logger.outputters = Log4r::StdoutOutputter.new(:console)
10
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
11
+ logger.level = Log4r::WARN
12
+ AppConfig.default
13
+ AppConfig[:logger] = logger
14
+ AppConfig.load
15
+ File.mkdirs(TMPDIR)
16
+ AppConfig[:logger].warn { "\nFanartController Specs" }
17
+ end
18
+
19
+ before(:each) do
20
+ Dir.glob(File.join(TMPDIR,'foo-fanart*')).each { |filename| File.delete(filename) }
21
+ end
22
+
23
+ after(:all) do
24
+ Dir.glob(File.join(TMPDIR,'foo-fanart*')).each { |filename| File.delete(filename) }
25
+ end
26
+
27
+ it 'should generate "original.0" size destination filespec' do
28
+ fanart = {'size' => 'original', 'content' => 'http://example.com/foobar.jpg'}
29
+ indexes = {}
30
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes)
31
+ filespec.should == "/tmp/movie title-fanart.original.0.jpg"
32
+ end
33
+ it 'should generate "mid.0" size destination filespec' do
34
+ fanart = {'size' => 'mid', 'content' => 'http://example.com/foobar.jpg'}
35
+ indexes = {}
36
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes)
37
+ filespec.should == "/tmp/movie title-fanart.mid.0.jpg"
38
+ end
39
+ it 'should generate "thumb.0" size destination filespec' do
40
+ fanart = {'size' => 'thumb', 'content' => 'http://example.com/foobar.jpg'}
41
+ indexes = {}
42
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes)
43
+ filespec.should == "/tmp/movie title-fanart.thumb.0.jpg"
44
+ end
45
+ it 'should generate "cover.0" size destination filespec' do
46
+ fanart = {'size' => 'cover', 'content' => 'http://example.com/foobar.jpg'}
47
+ indexes = {}
48
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes)
49
+ filespec.should == "/tmp/movie title-fanart.cover.0.jpg"
50
+ end
51
+
52
+ it 'should generate "original.1" size destination filespec' do
53
+ fanart = {'size' => 'original', 'content' => 'http://example.com/foobar.jpg'}
54
+ indexes = {'original' => 0}
55
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes)
56
+ filespec.should == "/tmp/movie title-fanart.original.1.jpg"
57
+ end
58
+
59
+ it 'should increment indexes' do
60
+ fanart = {'size' => 'cover', 'content' => 'http://example.com/foobar.jpg'}
61
+ indexes = {}
62
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes) # indexex['cover'] => 0
63
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes) # indexex['cover'] => 1
64
+ filespec = FanartController.get_destination_filespec('/tmp/movie title.m4v', fanart, indexes) # indexex['cover'] => 2
65
+ indexes['cover'].should == 2 && filespec.should == "/tmp/movie title-fanart.cover.2.jpg"
66
+ end
67
+
68
+ it 'should link to a fanart file' do
69
+ dest_filespec = "#{TMPDIR}/foo-fanart"
70
+ link_filespec = "#{dest_filespec}.jpg"
71
+ touch("#{dest_filespec}.original.0.jpg")
72
+ controller = FanartController.new(nil)
73
+ controller.link_fanart(dest_filespec)
74
+ File.exist?(link_filespec).should be_true
75
+ end
76
+
77
+ it 'should link to the first, largest (original) fanart file' do
78
+ dest_filespec = "#{TMPDIR}/foo-fanart"
79
+ link_filespec = "#{dest_filespec}.jpg"
80
+ ['original', 'mid', 'cover', 'thumb'].each do |size|
81
+ 0.upto(2) do |index|
82
+ touch("#{dest_filespec}.#{size}.#{index}.jpg")
83
+ end
84
+ end
85
+ controller = FanartController.new(nil)
86
+ controller.link_fanart(dest_filespec)
87
+ (File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.original.0.jpg\n")
88
+ end
89
+
90
+ it 'should link to the first, largest (mid) fanart file' do
91
+ dest_filespec = "#{TMPDIR}/foo-fanart"
92
+ link_filespec = "#{dest_filespec}.jpg"
93
+ ['mid', 'cover', 'thumb'].each do |size|
94
+ 0.upto(2) do |index|
95
+ touch("#{dest_filespec}.#{size}.#{index}.jpg")
96
+ end
97
+ end
98
+ controller = FanartController.new(nil)
99
+ controller.link_fanart(dest_filespec)
100
+ (File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.mid.0.jpg\n")
101
+ end
102
+
103
+ it 'should link to the first, largest (cover) fanart file' do
104
+ dest_filespec = "#{TMPDIR}/foo-fanart"
105
+ link_filespec = "#{dest_filespec}.jpg"
106
+ ['cover', 'thumb'].each do |size|
107
+ 0.upto(2) do |index|
108
+ touch("#{dest_filespec}.#{size}.#{index}.jpg")
109
+ end
110
+ end
111
+ controller = FanartController.new(nil)
112
+ controller.link_fanart(dest_filespec)
113
+ (File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.cover.0.jpg\n")
114
+ end
115
+
116
+ it 'should link to the first, largest (thumb) fanart file' do
117
+ dest_filespec = "#{TMPDIR}/foo-fanart"
118
+ link_filespec = "#{dest_filespec}.jpg"
119
+ ['thumb'].each do |size|
120
+ 0.upto(2) do |index|
121
+ touch("#{dest_filespec}.#{size}.#{index}.jpg")
122
+ end
123
+ end
124
+ controller = FanartController.new(nil)
125
+ controller.link_fanart(dest_filespec)
126
+ (File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.thumb.0.jpg\n")
127
+ end
128
+
129
+ def touch(filespec)
130
+ File.open(filespec, 'w') { |f| f.puts(filespec)}
131
+ end
132
+ end
@@ -0,0 +1,86 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ require 'tempfile'
4
+
5
+ describe "Media" do
6
+
7
+ before(:all) do
8
+ logger = Log4r::Logger.new('dvdprofiler2xbmc')
9
+ logger.outputters = Log4r::StdoutOutputter.new(:console)
10
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
11
+ logger.level = Log4r::WARN
12
+ AppConfig.default
13
+ AppConfig[:logger] = logger
14
+ AppConfig.load
15
+ File.mkdirs(TMPDIR)
16
+ AppConfig[:logger].warn { "\nMedia Specs" }
17
+ end
18
+
19
+ # "movie title - yyyy.ext"
20
+ # "movie title (yyyy).ext"
21
+ # "movie title.ext"
22
+ # "movie title - yyyy.partN.ext"
23
+ # "movie title (yyyy).partN.ext"
24
+ # "movie title.partN.ext"
25
+
26
+ it 'should parse "movie title.m4v"' do
27
+ result = Media.parse('movie title.m4v')
28
+ result.should == {:title => 'movie title', :extension => 'm4v'}
29
+ end
30
+
31
+ it 'should parse "movie title - 1999.m4v"' do
32
+ result = Media.parse('movie title - 1999.m4v')
33
+ result.should == {:title => 'movie title', :year => '1999', :extension => 'm4v'}
34
+ end
35
+
36
+ it 'should parse "movie title-1999.m4v"' do
37
+ result = Media.parse('movie title-1999.m4v')
38
+ result.should == {:title => 'movie title', :year => '1999', :extension => 'm4v'}
39
+ end
40
+
41
+ it 'should parse "movie title (1999).m4v"' do
42
+ result = Media.parse('movie title (1999).m4v')
43
+ result.should == {:title => 'movie title', :year => '1999', :extension => 'm4v'}
44
+ end
45
+
46
+ it 'should parse "movie title ( 1999 ) .m4v"' do
47
+ result = Media.parse('movie title ( 1999 ) .m4v')
48
+ result.should == {:title => 'movie title', :year => '1999', :extension => 'm4v'}
49
+ end
50
+
51
+ it 'should parse "movie title.cd1.m4v"' do
52
+ result = Media.parse('movie title.cd1.m4v')
53
+ result.should == {:title => 'movie title', :part => 'cd1', :extension => 'm4v'}
54
+ end
55
+
56
+ it 'should parse "movie title - 1999.cd1.m4v"' do
57
+ result = Media.parse('movie title - 1999.cd1.m4v')
58
+ result.should == {:title => 'movie title', :year => '1999', :part => 'cd1', :extension => 'm4v'}
59
+ end
60
+
61
+ it 'should parse "movie title-1999.cd1.m4v"' do
62
+ result = Media.parse('movie title-1999.cd1.m4v')
63
+ result.should == {:title => 'movie title', :year => '1999', :part => 'cd1', :extension => 'm4v'}
64
+ end
65
+
66
+ it 'should parse "movie title (1999).cd1.m4v"' do
67
+ result = Media.parse('movie title (1999).cd1.m4v')
68
+ result.should == {:title => 'movie title', :year => '1999', :part => 'cd1', :extension => 'm4v'}
69
+ end
70
+
71
+ it 'should parse "movie title ( 1999 ) .cd1.m4v"' do
72
+ result = Media.parse('movie title ( 1999 ) .cd1.m4v')
73
+ result.should == {:title => 'movie title', :year => '1999', :part => 'cd1', :extension => 'm4v'}
74
+ end
75
+
76
+ it 'should generate path_to(:nfo)' do
77
+ media = Media.new(File.join(File.dirname(__FILE__), 'samples'), 'The Egg and I.dummy')
78
+ media.path_to(:nfo).should == File.expand_path('spec/samples/The Egg and I.nfo')
79
+ end
80
+
81
+ it 'should generate path_to(:nfo) for multipart media' do
82
+ media = Media.new(File.join(File.dirname(__FILE__), 'samples'), 'Ma and Pa Kettle.cd1.dummy')
83
+ media.path_to(:nfo).should == File.expand_path('spec/samples/Ma and Pa Kettle.nfo')
84
+ end
85
+
86
+ end
@@ -21,7 +21,7 @@ describe "NfoController" do
21
21
 
22
22
  before(:each) do
23
23
  @media = Media.new(SAMPLES_DIR, 'The Egg and I.dummy')
24
- [:nfo_extension, :imdb_xml_extension, :tmdb_xml_extension].each do |extension|
24
+ [:imdb_xml, :tmdb_xml, :nfo].each do |extension|
25
25
  filespec = @media.path_to(extension)
26
26
  File.delete(filespec) if File.exist?(filespec)
27
27
  end
@@ -30,8 +30,8 @@ describe "NfoController" do
30
30
 
31
31
  after(:all) do
32
32
  Dir.glob(File.join(TMPDIR, "nfo_controller_spec*")).each { |filename| File.delete(filename) }
33
- ['imdb.xml', 'tmdb.xml', 'nfo'].each do |extension|
34
- filespec = File.join(File.dirname(__FILE__), "samples/The Egg and I.#{extension}")
33
+ [:imdb_xml, :tmdb_xml, :nfo].each do |extension|
34
+ filespec = File.join(File.dirname(__FILE__), "samples/The Egg and I.#{AppConfig[:extensions][extension]}")
35
35
  File.delete(filespec) if File.exist?(filespec)
36
36
  end
37
37
  end
@@ -39,7 +39,7 @@ describe "NfoController" do
39
39
 
40
40
  it "should use certifications if mpaa not available" do
41
41
  NfoController.update(@media)
42
- filespec = @media.path_to(:nfo_extension)
42
+ filespec = @media.path_to(:nfo)
43
43
  xml = open(filespec).read
44
44
  hash = XmlSimple.xml_in(xml)
45
45
  hash['mpaa'].should == ['Approved']
@@ -51,7 +51,7 @@ describe "NfoController" do
51
51
 
52
52
  it "should generate populated nfo file on update" do
53
53
  NfoController.update(@media)
54
- filespec = @media.path_to(:nfo_extension)
54
+ filespec = @media.path_to(:nfo)
55
55
  xml = open(filespec).read
56
56
  hash = XmlSimple.xml_in(xml)
57
57
  hash['runtime'].should == ['108 min']
@@ -59,7 +59,7 @@ describe "NfoController" do
59
59
 
60
60
  it "should generate populated imdb.xml file on update" do
61
61
  NfoController.update(@media)
62
- filespec = @media.path_to(:imdb_xml_extension)
62
+ filespec = @media.path_to(:imdb_xml)
63
63
  xml = open(filespec).read
64
64
  hash = XmlSimple.xml_in(xml)
65
65
  hash['length'].should == ['108 min']
@@ -67,10 +67,15 @@ describe "NfoController" do
67
67
 
68
68
  it "should generate populated tmdb.xml file on update" do
69
69
  NfoController.update(@media)
70
- filespec = @media.path_to(:tmdb_xml_extension)
70
+ filespec = @media.path_to(:tmdb_xml)
71
71
  xml = open(filespec).read
72
72
  hash = XmlSimple.xml_in(xml)
73
73
  hash.should be_empty
74
74
  end
75
75
 
76
+ # it "should handle different movies with the same title" do
77
+ # media1 = Media.new('Sabrina - 1954')
78
+ # media2 = Media.new('Sabrina - 1995')
79
+ # end
80
+
76
81
  end
@@ -20,6 +20,7 @@ describe "TmdbProfile" do
20
20
  end
21
21
 
22
22
  before(:each) do
23
+ # tt0465234 => National Treasure: Book of Secrets
23
24
  @profile = TmdbProfile.first(:imdb_id => 'tt0465234')
24
25
  end
25
26
 
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestDvdprofiler2xbmc < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), "test_helper.rb")
2
+ require 'dvdprofiler2xbmc/cli'
3
+
4
+ class TestDvdprofiler2xbmcCli < Test::Unit::TestCase
5
+ def setup
6
+ Dvdprofiler2xbmc::CLI.execute(@stdout_io = StringIO.new, [])
7
+ @stdout_io.rewind
8
+ @stdout = @stdout_io.read
9
+ end
10
+
11
+ def test_not_print_default_output
12
+ assert_no_match(/To update this executable/, @stdout)
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/dvdprofiler2xbmc'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-dvdprofiler2xbmc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 -07:00
12
+ date: 2009-04-14 00:00:00 -07:00
13
13
  default_executable: dvdprofiler2xbmc
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -72,6 +72,16 @@ dependencies:
72
72
  - !ruby/object:Gem::Version
73
73
  version: 0.0.3
74
74
  version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: highline
77
+ type: :runtime
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.5.0
84
+ version:
75
85
  - !ruby/object:Gem::Dependency
76
86
  name: newgem
77
87
  type: :development
@@ -92,7 +102,7 @@ dependencies:
92
102
  - !ruby/object:Gem::Version
93
103
  version: 1.8.0
94
104
  version:
95
- description: "This script will attempt to match up media files from a set of directories to the collection.xml file exported from DVD Profiler. For matches, the script will then create a {moviename}.nfo from the data in collections.xml and also copy the front cover image to {moviename}.tbn. Both files will be placed in the same directory as the source media file. Also the specific profile information for each movie will be saved into {moviename}.dvdprofiler.xml. The script will then search IMDB for a title or also known as (AKA) match. If necessary, the script will refine the search by using the media year (year in media filename), then dvdprofiler production year, then dvdprofiler release year, then try again with each year plus or minus a year. The IMDB profile found will be saved as {moviename}.imdb.xml. Next the script will use the IMDB ID to query themovieDb.com. This is primarily to retrieve any fanart but will also add any missing parameters to the .nfo file (very unlikely). The TMDB profile found will be saved as {moviename}.tmdb.xml. So in summary the files generated are: {moviename}.tmdb.xml - profile from themovieDb.com {moviename}.imdb.xml - profile from imdb.com {moviename}.dvdprofiler.xml - profile from collection.xml {moviename}-fanart.jpg - first fanart image from themovieDb.com {moviename}.tbn - image from DVD Profiler {moviename}.nfo - generated info profile for xbmc To force regeneration, simply delete these files then run the script again. Then on XBMC, set the source content to none to remove the meta data from the library, then set the source content back to Movies to import the media. This time, the data in the .nfo files will be used instead of scraping."
105
+ description: "This script will attempt to match up media files from a set of directories to the collection.xml file exported from DVD Profiler. For matches, the script will then create a {moviename}.nfo from the data in collections.xml and also copy the front cover image to {moviename}.tbn. Both files will be placed in the same directory as the source media file. Also the specific profile information for each movie will be saved into {moviename}.dvdprofiler.xml. The script will then search IMDB for a title or also known as (AKA) match. If necessary, the script will refine the search by using the media year (year in media filename), then dvdprofiler production year, then dvdprofiler release year, then try again with each year plus or minus a year. The IMDB profile found will be saved as {moviename}.imdb.xml. Next the script will use the IMDB ID to query themovieDb.com. This is primarily to retrieve any fanart but will also add any missing parameters to the .nfo file (very unlikely). The TMDB profile found will be saved as {moviename}.tmdb.xml. So in summary the files generated are: {moviename}.tmdb.xml - profile from themovieDb.com {moviename}.imdb.xml - profile from imdb.com {moviename}.dvdprofiler.xml - profile from collection.xml {moviename}-fanart.jpg - first fanart image from themovieDb.com {moviename}.tbn - image from DVD Profiler {moviename}.nfo - generated info profile for xbmc To force regeneration, simply delete these files then run the script again. Then on XBMC, set the source content to none to remove the meta data from the library, then set the source content back to Movies to import the media. This time, the data in the .nfo files will be used instead of scraping. Note, XBMC pre-9.04 r19177 does not successfully scan all media. The work-around is after the scan is complete to restart XBMC so it will scan again (if you have autoscan enabled)."
96
106
  email:
97
107
  - roy@wright.org
98
108
  executables:
@@ -130,14 +140,19 @@ files:
130
140
  - lib/dvdprofiler2xbmc/models/xbmc_info.rb
131
141
  - lib/dvdprofiler2xbmc/open_cache_extension.rb
132
142
  - lib/dvdprofiler2xbmc/views/cli.rb
143
+ - lib/dvdprofiler2xbmc/views/config_editor.rb
144
+ - spec/app_spec.rb
133
145
  - spec/cache_extensions.rb
146
+ - spec/config_editor_spec.rb
134
147
  - spec/dvdprofiler2xbmc_spec.rb
135
148
  - spec/dvdprofiler_profile_spec.rb
149
+ - spec/fanart_controller_spec.rb
136
150
  - spec/imdb_profile_spec.rb
151
+ - spec/media_spec.rb
137
152
  - spec/nfo_controller_spec.rb
138
153
  - spec/samples/Collection.xml
139
- - spec/samples/Collection.yaml
140
154
  - spec/samples/Die Hard - 1988.nfo
155
+ - spec/samples/Ma and Pa Kettle.cd1.dummy
141
156
  - spec/samples/The Egg and I.dummy
142
157
  - spec/spec.opts
143
158
  - spec/spec_helper.rb
@@ -146,8 +161,8 @@ files:
146
161
  - spec/xbmc_info_spec.rb
147
162
  - tasks/rspec.rake
148
163
  - test/test_dvdprofiler2xbmc.rb
149
- - test/test_dvdprofiler2xbmc_cli.rb
150
164
  - test/test_helper.rb
165
+ - test/test_dvdprofiler2xbmc_cli.rb
151
166
  has_rdoc: true
152
167
  homepage: http://www.github.com/royw/dvdprofiler2xbmc
153
168
  post_install_message: PostInstall.txt