royw-dvdprofiler2xbmc 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -3
- data/VERSION.yml +1 -1
- data/lib/dvdprofiler2xbmc/app_config.rb +5 -1
- data/lib/dvdprofiler2xbmc/controllers/fanart_controller.rb +23 -37
- data/lib/dvdprofiler2xbmc/controllers/nfo_controller.rb +36 -7
- data/lib/string_extensions.rb +8 -0
- data/spec/cache_extensions.rb +58 -0
- data/spec/fanart_controller_spec.rb +66 -44
- data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0095016&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
- data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0108171&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
- data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0110413&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
- data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0114924&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4_.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4__poster.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4__thumb.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_poster.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_thumb.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016_poster.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016_thumb.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart_poster.jpg +0 -0
- data/spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart_thumb.jpg +0 -0
- metadata +21 -5
data/Rakefile
CHANGED
@@ -17,9 +17,9 @@ begin
|
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
gem.add_dependency('activesupport','>= 2.0.2')
|
19
19
|
gem.add_dependency('xml-simple','>= 1.0.12')
|
20
|
-
gem.add_dependency('royw-imdb','>= 0.
|
21
|
-
gem.add_dependency('royw-tmdb','>= 0.
|
22
|
-
gem.add_dependency('royw-dvdprofiler_collection','>= 0.
|
20
|
+
gem.add_dependency('royw-imdb','>= 0.1.1')
|
21
|
+
gem.add_dependency('royw-tmdb','>= 0.1.1')
|
22
|
+
gem.add_dependency('royw-dvdprofiler_collection','>= 0.1.1')
|
23
23
|
gem.add_dependency('log4r','>= 1.0.5')
|
24
24
|
gem.add_dependency('commandline','>= 0.7.10')
|
25
25
|
gem.add_dependency('mash','>= 0.0.3')
|
data/VERSION.yml
CHANGED
@@ -269,11 +269,13 @@ module AppConfig
|
|
269
269
|
].join("\n")
|
270
270
|
@initial.genre_maps = {
|
271
271
|
'SciFi' => 'Science Fiction',
|
272
|
+
'Sci-Fi' => 'Science Fiction',
|
272
273
|
'Science-Fiction' => 'Science Fiction',
|
273
274
|
'Anime' => 'Animation',
|
274
275
|
'Musical' => 'Musicals',
|
275
276
|
'Music' => 'Musicals',
|
276
|
-
'War Film' => 'War'
|
277
|
+
'War Film' => 'War',
|
278
|
+
'Western' => 'Westerns'
|
277
279
|
}
|
278
280
|
@config.genre_maps = @initial.genre_maps
|
279
281
|
@data_type.genre_maps = :HASH_STRING_KEYS_STRING_VALUES
|
@@ -321,6 +323,8 @@ module AppConfig
|
|
321
323
|
:tmdb_xml => 'tmdb.xml',
|
322
324
|
:new => 'new',
|
323
325
|
:backup => '~',
|
326
|
+
:isbn => 'isbn',
|
327
|
+
:imdb => 'imdb',
|
324
328
|
:no_isbn => 'no_isbn',
|
325
329
|
:no_imdb_lookup => 'no_imdb_lookup',
|
326
330
|
:no_tmdb_lookup => 'no_tmdb_lookup',
|
@@ -29,8 +29,11 @@ class FanartController
|
|
29
29
|
result
|
30
30
|
end
|
31
31
|
|
32
|
+
protected
|
33
|
+
|
34
|
+
# link the largest fanart to moviename-fanart.jpg
|
32
35
|
def link_fanart(dest_filespec)
|
33
|
-
|
36
|
+
%w(original mid thumb).each do |size|
|
34
37
|
files = Dir.glob("#{dest_filespec}.#{size}.*")
|
35
38
|
unless files.blank?
|
36
39
|
filespec = files.sort.first
|
@@ -44,52 +47,35 @@ class FanartController
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
# fetch all of the fanart for the movie
|
51
|
+
# save to files using format: moviename-fanart.size.N.jpg
|
52
|
+
# where size is the fanart size ['original', 'mid', 'thumb']
|
53
|
+
# and N is a sequential integer starting at 0
|
49
54
|
def fetch_fanart(imdb_id)
|
50
|
-
profile = TmdbProfile.new(imdb_id, TMDB_API_KEY, @media.path_to(:tmdb_xml))
|
51
55
|
indexes = {}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
src_url = fanart['content']
|
59
|
-
unless src_url.blank?
|
60
|
-
dest_filespec = FanartController.get_destination_filespec(@media.media_path, fanart, indexes)
|
61
|
-
unless File.exist?(dest_filespec)
|
62
|
-
AppConfig[:logger].info { "src_url => #{src_url}" }
|
63
|
-
AppConfig[:logger].info { "dest_fanart_filespec => #{dest_filespec}" }
|
64
|
-
copy_fanart(src_url, dest_filespec)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
56
|
+
profile = TmdbProfile.new(imdb_id, TMDB_API_KEY, @media.path_to(:tmdb_xml), AppConfig[:logger])
|
57
|
+
image = profile.image
|
58
|
+
unless image.nil?
|
59
|
+
image.fanart_sizes.each do |size|
|
60
|
+
dest_filespec = get_destination_filespec(@media.media_path, size, indexes)
|
61
|
+
image.fanart(size, dest_filespec)
|
68
62
|
end
|
69
63
|
end
|
70
64
|
end
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
# generate a filespec using format: moviename-fanart.size.N
|
67
|
+
# where size is the fanart size ['original', 'mid', 'thumb']
|
68
|
+
# and N is a sequential integer starting at 0
|
69
|
+
# Note, the calling routine should add the appropriate media extenstion like ".jpg"
|
70
|
+
def get_destination_filespec(media_path, size, indexes)
|
71
|
+
filespec = nil
|
75
72
|
unless size.blank?
|
76
73
|
indexes[size] ||= -1
|
77
74
|
indexes[size] += 1
|
78
|
-
extension = ".#{size}.#{indexes[size]}
|
79
|
-
|
80
|
-
fanart_filename = DvdProfiler2Xbmc.generate_filespec(media_path, :fanart, :extension => extension)
|
81
|
-
end
|
82
|
-
|
83
|
-
# download the fanart
|
84
|
-
def copy_fanart(src_url, dest_filespec)
|
85
|
-
begin
|
86
|
-
data = open(src_url).read
|
87
|
-
File.open(dest_filespec, 'w') do |file|
|
88
|
-
file.print(data)
|
89
|
-
end
|
90
|
-
rescue Exception => e
|
91
|
-
AppConfig[:logger].error { "Error fetching fanart.\n src_url => #{src_url},\n dest_filespec => #{dest_filespec}\n #{e.to_s}" }
|
75
|
+
extension = ".#{size}.#{indexes[size]}"
|
76
|
+
filespec = DvdProfiler2Xbmc.generate_filespec(media_path, :fanart, :extension => extension)
|
92
77
|
end
|
78
|
+
filespec
|
93
79
|
end
|
94
80
|
|
95
81
|
end
|
@@ -33,19 +33,22 @@ class NfoController
|
|
33
33
|
AppConfig[:logger].info { "\n#{@media.title}" }
|
34
34
|
@info.merge!(@xbmc_info.movie)
|
35
35
|
|
36
|
+
# load any manually cached IDs
|
37
|
+
self.isbn ||= load_isbn_id
|
38
|
+
self.imdb_id ||= load_imdb_id
|
39
|
+
|
40
|
+
# load the profiles
|
36
41
|
dvd_hash = load_dvdprofiler
|
37
42
|
imdb_hash = load_imdb(dvd_hash)
|
38
43
|
tmdb_hash = load_tmdb
|
39
44
|
|
45
|
+
# merge the profiles into the @info hash
|
40
46
|
@info.merge!(tmdb_hash_to_info(tmdb_hash))
|
41
47
|
@info.merge!(imdb_hash_to_info(imdb_hash))
|
42
48
|
@info.merge!(dvd_hash_to_info(dvd_hash))
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
genres += @media.media_subdirs.split('/') if AppConfig[:subdirs_as_genres]
|
47
|
-
new_genres = map_genres(genres.uniq).uniq.compact
|
48
|
-
@info['genre'] = new_genres unless new_genres.blank?
|
50
|
+
# map any genres
|
51
|
+
@info['genre'] = remap_genres(@info['genre'])
|
49
52
|
|
50
53
|
save
|
51
54
|
result = true
|
@@ -56,6 +59,14 @@ class NfoController
|
|
56
59
|
result
|
57
60
|
end
|
58
61
|
|
62
|
+
def remap_genres(genres)
|
63
|
+
genres ||= []
|
64
|
+
genres += @media.media_subdirs.split('/') if AppConfig[:subdirs_as_genres]
|
65
|
+
new_genres = map_genres(genres.uniq).uniq.compact
|
66
|
+
new_genres = nil if new_genres.blank?
|
67
|
+
new_genres
|
68
|
+
end
|
69
|
+
|
59
70
|
# return the ISBN or nil
|
60
71
|
def isbn
|
61
72
|
unless @info['isbn'].blank?
|
@@ -109,6 +120,24 @@ class NfoController
|
|
109
120
|
end
|
110
121
|
end
|
111
122
|
|
123
|
+
def load_isbn_id
|
124
|
+
ident = nil
|
125
|
+
filespec = @media.path_to(:isbn)
|
126
|
+
if File.exist?(filespec)
|
127
|
+
ident = open(filespec).read.strip
|
128
|
+
end
|
129
|
+
ident
|
130
|
+
end
|
131
|
+
|
132
|
+
def load_imdb_id
|
133
|
+
ident = nil
|
134
|
+
filespec = @media.path_to(:imdb)
|
135
|
+
if File.exist?(filespec)
|
136
|
+
ident = open(filespec).read.strip
|
137
|
+
end
|
138
|
+
ident
|
139
|
+
end
|
140
|
+
|
112
141
|
# load from the collection
|
113
142
|
# return movie hash
|
114
143
|
def load_dvdprofiler
|
@@ -182,7 +211,7 @@ class NfoController
|
|
182
211
|
titles = []
|
183
212
|
unless dvd_hash[:boxset].blank?
|
184
213
|
begin
|
185
|
-
AppConfig[:logger].
|
214
|
+
AppConfig[:logger].debug { "Need to find box set parent's title" }
|
186
215
|
parent_isbn = dvd_hash[:boxset].first['parent'].first
|
187
216
|
unless parent_isbn.blank?
|
188
217
|
parent_profile = DvdprofilerProfile.first(:isbn => parent_isbn)
|
@@ -194,7 +223,7 @@ class NfoController
|
|
194
223
|
rescue
|
195
224
|
end
|
196
225
|
end
|
197
|
-
AppConfig[:logger].
|
226
|
+
AppConfig[:logger].debug { "parent titles => #{titles.pretty_inspect}" } unless titles.empty?
|
198
227
|
titles
|
199
228
|
end
|
200
229
|
|
data/lib/string_extensions.rb
CHANGED
@@ -8,6 +8,14 @@ class String
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
# this handles unicode characters by converting each byte to "%XX"
|
12
|
+
# where XX is the hex value
|
13
|
+
my_extension("escape_unicode") do
|
14
|
+
def escape_unicode
|
15
|
+
self.each_byte.collect{|c| c.to_i > 127 ? "%#{c.to_i.to_s(16)}" : c.chr}.join('')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
my_extension("strip_tags") do
|
12
20
|
def strip_tags
|
13
21
|
gsub(/<\/?[^>]*>/, "")
|
data/spec/cache_extensions.rb
CHANGED
@@ -3,6 +3,35 @@
|
|
3
3
|
# override the classes' read_page method and replace with one
|
4
4
|
# that will cache pages in spec/samples/{url}
|
5
5
|
|
6
|
+
class FanartController
|
7
|
+
private
|
8
|
+
def read_page(page)
|
9
|
+
html = nil
|
10
|
+
filespec = page.gsub(/^http:\//, 'spec/samples')
|
11
|
+
if File.exist?(filespec)
|
12
|
+
html = open(filespec).read
|
13
|
+
else
|
14
|
+
html = open(page).read
|
15
|
+
cache_html_files(page, html)
|
16
|
+
end
|
17
|
+
html
|
18
|
+
end
|
19
|
+
|
20
|
+
# this is used to save imdb pages so they may be used by rspec
|
21
|
+
def cache_html_files(page, html)
|
22
|
+
begin
|
23
|
+
filespec = page.gsub(/^http:\//, 'spec/samples')
|
24
|
+
unless File.exist?(filespec)
|
25
|
+
puts "caching #{filespec}"
|
26
|
+
File.mkdirs(File.dirname(filespec))
|
27
|
+
File.open(filespec, 'w') { |f| f.puts html }
|
28
|
+
end
|
29
|
+
rescue Exception => eMsg
|
30
|
+
puts eMsg.to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
6
35
|
class TmdbMovie
|
7
36
|
private
|
8
37
|
def read_page(page)
|
@@ -32,6 +61,35 @@ class TmdbMovie
|
|
32
61
|
end
|
33
62
|
end
|
34
63
|
|
64
|
+
class TmdbImage
|
65
|
+
private
|
66
|
+
def read_page(page)
|
67
|
+
html = nil
|
68
|
+
filespec = page.gsub(/^http:\//, 'spec/samples')
|
69
|
+
if File.exist?(filespec)
|
70
|
+
html = open(filespec).read
|
71
|
+
else
|
72
|
+
html = open(page).read
|
73
|
+
cache_html_files(page, html)
|
74
|
+
end
|
75
|
+
html
|
76
|
+
end
|
77
|
+
|
78
|
+
# this is used to save imdb pages so they may be used by rspec
|
79
|
+
def cache_html_files(page, html)
|
80
|
+
begin
|
81
|
+
filespec = page.gsub(/^http:\//, 'spec/samples')
|
82
|
+
unless File.exist?(filespec)
|
83
|
+
puts "caching #{filespec}"
|
84
|
+
File.mkdirs(File.dirname(filespec))
|
85
|
+
File.open(filespec, 'w') { |f| f.puts html }
|
86
|
+
end
|
87
|
+
rescue Exception => eMsg
|
88
|
+
puts eMsg.to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
35
93
|
class ImdbMovie
|
36
94
|
private
|
37
95
|
def read_page(page)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
3
|
require 'tempfile'
|
4
|
+
require 'ruby-debug'
|
4
5
|
|
5
6
|
describe "FanartController" do
|
6
7
|
|
@@ -17,113 +18,134 @@ describe "FanartController" do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
before(:each) do
|
20
|
-
Dir.glob(File.join(TMPDIR,'
|
21
|
+
Dir.glob(File.join(TMPDIR,'*-fanart*')).each { |filename| File.delete(filename) }
|
22
|
+
Dir.glob(File.join(TMPDIR,'*.dummy')).each { |filename| File.delete(filename) }
|
23
|
+
Dir.glob(File.join(TMPDIR,'*.tmdb.xml')).each { |filename| File.delete(filename) }
|
24
|
+
|
25
|
+
FileUtils.touch(File.join(TMPDIR, 'Die Hard - 1988.dummy'))
|
26
|
+
media = Media.new(TMPDIR, 'Die Hard - 1988.dummy')
|
27
|
+
media.imdb_id = 'tt0095016'
|
28
|
+
@controller = FanartController.new(media)
|
21
29
|
end
|
22
30
|
|
23
31
|
after(:all) do
|
24
|
-
Dir.glob(File.join(TMPDIR,'
|
32
|
+
Dir.glob(File.join(TMPDIR,'*-fanart*')).each { |filename| File.delete(filename) }
|
33
|
+
Dir.glob(File.join(TMPDIR,'*.dummy')).each { |filename| File.delete(filename) }
|
34
|
+
Dir.glob(File.join(TMPDIR,'*.tmdb.xml')).each { |filename| File.delete(filename) }
|
25
35
|
end
|
26
36
|
|
27
37
|
it 'should generate "original.0" size destination filespec' do
|
28
|
-
fanart = {'size' => 'original', 'content' => 'http://example.com/foobar.jpg'}
|
29
38
|
indexes = {}
|
30
|
-
filespec =
|
31
|
-
filespec.should == "/tmp/movie title-fanart.original.0
|
39
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'original', indexes)
|
40
|
+
filespec.should == "/tmp/movie title-fanart.original.0"
|
32
41
|
end
|
42
|
+
|
33
43
|
it 'should generate "mid.0" size destination filespec' do
|
34
|
-
fanart = {'size' => 'mid', 'content' => 'http://example.com/foobar.jpg'}
|
35
44
|
indexes = {}
|
36
|
-
filespec =
|
37
|
-
filespec.should == "/tmp/movie title-fanart.mid.0
|
45
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'mid', indexes)
|
46
|
+
filespec.should == "/tmp/movie title-fanart.mid.0"
|
38
47
|
end
|
48
|
+
|
39
49
|
it 'should generate "thumb.0" size destination filespec' do
|
40
|
-
fanart = {'size' => 'thumb', 'content' => 'http://example.com/foobar.jpg'}
|
41
50
|
indexes = {}
|
42
|
-
filespec =
|
43
|
-
filespec.should == "/tmp/movie title-fanart.thumb.0
|
51
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'thumb', indexes)
|
52
|
+
filespec.should == "/tmp/movie title-fanart.thumb.0"
|
44
53
|
end
|
54
|
+
|
45
55
|
it 'should generate "cover.0" size destination filespec' do
|
46
|
-
fanart = {'size' => 'cover', 'content' => 'http://example.com/foobar.jpg'}
|
47
56
|
indexes = {}
|
48
|
-
filespec =
|
49
|
-
filespec.should == "/tmp/movie title-fanart.cover.0
|
57
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'cover', indexes)
|
58
|
+
filespec.should == "/tmp/movie title-fanart.cover.0"
|
50
59
|
end
|
51
60
|
|
52
61
|
it 'should generate "original.1" size destination filespec' do
|
53
|
-
fanart = {'size' => 'original', 'content' => 'http://example.com/foobar.jpg'}
|
54
62
|
indexes = {'original' => 0}
|
55
|
-
filespec =
|
56
|
-
filespec.should == "/tmp/movie title-fanart.original.1
|
63
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'original', indexes)
|
64
|
+
filespec.should == "/tmp/movie title-fanart.original.1"
|
57
65
|
end
|
58
66
|
|
59
67
|
it 'should increment indexes' do
|
60
|
-
fanart = {'size' => 'cover', 'content' => 'http://example.com/foobar.jpg'}
|
61
68
|
indexes = {}
|
62
|
-
filespec =
|
63
|
-
filespec =
|
64
|
-
filespec =
|
65
|
-
indexes['
|
69
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'original', indexes) # indexex['original'] => 0
|
70
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'original', indexes) # indexex['original'] => 1
|
71
|
+
filespec = @controller.send('get_destination_filespec', '/tmp/movie title.m4v', 'original', indexes) # indexex['original'] => 2
|
72
|
+
indexes['original'].should == 2 && filespec.should == "/tmp/movie title-fanart.original.2"
|
66
73
|
end
|
67
74
|
|
68
75
|
it 'should link to a fanart file' do
|
69
76
|
dest_filespec = "#{TMPDIR}/foo-fanart"
|
70
77
|
link_filespec = "#{dest_filespec}.jpg"
|
71
78
|
touch("#{dest_filespec}.original.0.jpg")
|
72
|
-
controller
|
73
|
-
controller.link_fanart(dest_filespec)
|
79
|
+
@controller.send('link_fanart', dest_filespec)
|
74
80
|
File.exist?(link_filespec).should be_true
|
75
81
|
end
|
76
82
|
|
77
83
|
it 'should link to the first, largest (original) fanart file' do
|
78
84
|
dest_filespec = "#{TMPDIR}/foo-fanart"
|
79
85
|
link_filespec = "#{dest_filespec}.jpg"
|
80
|
-
['original', 'mid', '
|
86
|
+
['original', 'mid', 'thumb'].each do |size|
|
81
87
|
0.upto(2) do |index|
|
82
88
|
touch("#{dest_filespec}.#{size}.#{index}.jpg")
|
83
89
|
end
|
84
90
|
end
|
85
|
-
controller
|
86
|
-
controller.link_fanart(dest_filespec)
|
91
|
+
@controller.send('link_fanart', dest_filespec)
|
87
92
|
(File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.original.0.jpg\n")
|
88
93
|
end
|
89
94
|
|
90
95
|
it 'should link to the first, largest (mid) fanart file' do
|
91
96
|
dest_filespec = "#{TMPDIR}/foo-fanart"
|
92
97
|
link_filespec = "#{dest_filespec}.jpg"
|
93
|
-
['mid', '
|
98
|
+
['mid', 'thumb'].each do |size|
|
94
99
|
0.upto(2) do |index|
|
95
100
|
touch("#{dest_filespec}.#{size}.#{index}.jpg")
|
96
101
|
end
|
97
102
|
end
|
98
|
-
controller
|
99
|
-
controller.link_fanart(dest_filespec)
|
103
|
+
@controller.send('link_fanart', dest_filespec)
|
100
104
|
(File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.mid.0.jpg\n")
|
101
105
|
end
|
102
106
|
|
103
|
-
it 'should link to the first, largest (
|
107
|
+
it 'should link to the first, largest (thumb) fanart file' do
|
104
108
|
dest_filespec = "#{TMPDIR}/foo-fanart"
|
105
109
|
link_filespec = "#{dest_filespec}.jpg"
|
106
|
-
['
|
110
|
+
['thumb'].each do |size|
|
107
111
|
0.upto(2) do |index|
|
108
112
|
touch("#{dest_filespec}.#{size}.#{index}.jpg")
|
109
113
|
end
|
110
114
|
end
|
111
|
-
controller
|
112
|
-
|
113
|
-
(File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.cover.0.jpg\n")
|
115
|
+
@controller.send('link_fanart', dest_filespec)
|
116
|
+
(File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.thumb.0.jpg\n")
|
114
117
|
end
|
115
118
|
|
116
|
-
it 'should
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
it 'should fetch fanart' do
|
120
|
+
@controller.send('fetch_fanart', 'tt0095016')
|
121
|
+
buf = []
|
122
|
+
%w(mid original thumb).each do |size|
|
123
|
+
filespec = File.join(TMPDIR, "Die Hard - 1988-fanart.#{size}.0.jpg")
|
124
|
+
buf << filespec unless (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
|
125
|
+
end
|
126
|
+
puts buf.join("\n") unless buf.empty?
|
127
|
+
buf.empty?.should be_true
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should fetch fanart with unicode characters in the URL' do
|
131
|
+
buf = []
|
132
|
+
titles = {'While You Were Sleeping' => 'tt0114924',
|
133
|
+
'Sniper' => 'tt0108171',
|
134
|
+
'Leon The Professional' => 'tt0110413'
|
135
|
+
}
|
136
|
+
titles.each do |title, imdb_id|
|
137
|
+
FileUtils.touch(File.join(TMPDIR, "#{title}.dummy"))
|
138
|
+
media = Media.new(TMPDIR, "#{title}.dummy")
|
139
|
+
media.imdb_id = 'tt0095016'
|
140
|
+
controller = FanartController.new(media)
|
141
|
+
controller.send('fetch_fanart', imdb_id)
|
142
|
+
%w(mid original thumb).each do |size|
|
143
|
+
filespec = File.join(TMPDIR, "#{title}-fanart.#{size}.0.jpg")
|
144
|
+
buf << filespec unless (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
|
122
145
|
end
|
123
146
|
end
|
124
|
-
|
125
|
-
|
126
|
-
(File.exist?(link_filespec).should be_true) && (open(link_filespec).read.should == "#{dest_filespec}.thumb.0.jpg\n")
|
147
|
+
puts buf.join("\n") unless buf.empty?
|
148
|
+
buf.empty?.should be_true
|
127
149
|
end
|
128
150
|
|
129
151
|
def touch(filespec)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<results for="tt0095016" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query searchTerms="tt0095016"/>
|
4
|
+
<opensearch:totalResults>1</opensearch:totalResults>
|
5
|
+
<moviematches>
|
6
|
+
<movie>
|
7
|
+
<score>1.0</score>
|
8
|
+
<popularity>7</popularity>
|
9
|
+
<title>Die Hard</title>
|
10
|
+
<alternative_title>Die Hard 1</alternative_title>
|
11
|
+
<type>movie</type>
|
12
|
+
<id>562</id>
|
13
|
+
<imdb>tt0095016</imdb>
|
14
|
+
<url>http://www.themoviedb.org/movie/562</url>
|
15
|
+
<short_overview>New York cop John McClane gives terrorists a dose of their own medicine as they hold hostages in an LA office building.</short_overview>
|
16
|
+
<release>1988-07-15</release>
|
17
|
+
<poster size="original">http://www.themoviedb.org/image/posters/6997/Die_Hard.jpg</poster>
|
18
|
+
<poster size="mid">http://www.themoviedb.org/image/posters/6997/Die_Hard_mid.jpg</poster>
|
19
|
+
<poster size="cover">http://www.themoviedb.org/image/posters/6997/Die_Hard_cover.jpg</poster>
|
20
|
+
<poster size="thumb">http://www.themoviedb.org/image/posters/6997/Die_Hard_thumb.jpg</poster>
|
21
|
+
<backdrop size="original">http://www.themoviedb.org/image/backdrops/803/tt0095016.jpg</backdrop>
|
22
|
+
<backdrop size="mid">http://www.themoviedb.org/image/backdrops/803/tt0095016_poster.jpg</backdrop>
|
23
|
+
<backdrop size="thumb">http://www.themoviedb.org/image/backdrops/803/tt0095016_thumb.jpg</backdrop>
|
24
|
+
</movie>
|
25
|
+
</moviematches>
|
26
|
+
</results>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<results for="tt0108171" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query searchTerms="tt0108171"/>
|
4
|
+
<opensearch:totalResults>1</opensearch:totalResults>
|
5
|
+
<moviematches>
|
6
|
+
<movie>
|
7
|
+
<score>1.0</score>
|
8
|
+
<popularity>2</popularity>
|
9
|
+
<title>Sniper</title>
|
10
|
+
<alternative_title></alternative_title>
|
11
|
+
<type>movie</type>
|
12
|
+
<id>9545</id>
|
13
|
+
<imdb>tt0108171</imdb>
|
14
|
+
<url>http://www.themoviedb.org/movie/9545</url>
|
15
|
+
<short_overview>Tough guy Thomas Beckett is an US soldier working in the Panamanian jungle. His job is to seek out rebels and remove them using his sniper skills. Beckett is notorious for losing his partners on such missions. This time he's accompanied by crack marksman Richard Miller, who's more of an office-type.</short_overview>
|
16
|
+
<release>1993-01-29</release>
|
17
|
+
<poster size="original">http://www.themoviedb.org/image/posters/10581/Sniper_-_Poster_1__1993_.jpg</poster>
|
18
|
+
<poster size="mid">http://www.themoviedb.org/image/posters/10581/Sniper_-_Poster_1__1993__mid.jpg</poster>
|
19
|
+
<poster size="thumb">http://www.themoviedb.org/image/posters/10581/Sniper_-_Poster_1__1993__thumb.jpg</poster>
|
20
|
+
<poster size="cover">http://www.themoviedb.org/image/posters/10581/Sniper_-_Poster_1__1993__cover.jpg</poster>
|
21
|
+
<backdrop size="original">http://www.themoviedb.org/image/backdrops/13391/Sniper_1__Odstřelovač_.jpg</backdrop>
|
22
|
+
<backdrop size="thumb">http://www.themoviedb.org/image/backdrops/13391/Sniper_1__Odstřelovač__thumb.jpg</backdrop>
|
23
|
+
<backdrop size="mid">http://www.themoviedb.org/image/backdrops/13391/Sniper_1__Odstřelovač__poster.jpg</backdrop>
|
24
|
+
</movie>
|
25
|
+
</moviematches>
|
26
|
+
</results>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<results for="tt0110413" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query searchTerms="tt0110413"/>
|
4
|
+
<opensearch:totalResults>1</opensearch:totalResults>
|
5
|
+
<moviematches>
|
6
|
+
<movie>
|
7
|
+
<score>1.0</score>
|
8
|
+
<popularity>7</popularity>
|
9
|
+
<title>Léon</title>
|
10
|
+
<alternative_title>The Professional</alternative_title>
|
11
|
+
<type>movie</type>
|
12
|
+
<id>101</id>
|
13
|
+
<imdb>tt0110413</imdb>
|
14
|
+
<url>http://www.themoviedb.org/movie/101</url>
|
15
|
+
<short_overview>Leon/The Professional is a story of a lonely hit-man who saves a little girl, played by Natalie Portman in her first starring role, and thus having to give her a place to stay. It’s an intense and fragile story of their relationship and how they take care of one another.</short_overview>
|
16
|
+
<release>1994-11-18</release>
|
17
|
+
<poster size="original">http://www.themoviedb.org/image/posters/6357/Leon_-_The_Professional__Directors_Cut__-_Poster_3__1994_.jpg</poster>
|
18
|
+
<poster size="mid">http://www.themoviedb.org/image/posters/6357/Leon_-_The_Professional__Directors_Cut__-_Poster_3__1994__mid.jpg</poster>
|
19
|
+
<poster size="cover">http://www.themoviedb.org/image/posters/6357/Leon_-_The_Professional__Directors_Cut__-_Poster_3__1994__cover.jpg</poster>
|
20
|
+
<poster size="thumb">http://www.themoviedb.org/image/posters/6357/Leon_-_The_Professional__Directors_Cut__-_Poster_3__1994__thumb.jpg</poster>
|
21
|
+
<backdrop size="original">http://www.themoviedb.org/image/backdrops/8579/Léon-fanart.jpg</backdrop>
|
22
|
+
<backdrop size="mid">http://www.themoviedb.org/image/backdrops/8579/Léon-fanart_poster.jpg</backdrop>
|
23
|
+
<backdrop size="thumb">http://www.themoviedb.org/image/backdrops/8579/Léon-fanart_thumb.jpg</backdrop>
|
24
|
+
</movie>
|
25
|
+
</moviematches>
|
26
|
+
</results>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<results for="tt0114924" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query searchTerms="tt0114924"/>
|
4
|
+
<opensearch:totalResults>1</opensearch:totalResults>
|
5
|
+
<moviematches>
|
6
|
+
<movie>
|
7
|
+
<score>1.0</score>
|
8
|
+
<popularity>2</popularity>
|
9
|
+
<title>While you were Sleeping</title>
|
10
|
+
<alternative_title></alternative_title>
|
11
|
+
<type>movie</type>
|
12
|
+
<id>2064</id>
|
13
|
+
<imdb>tt0114924</imdb>
|
14
|
+
<url>http://www.themoviedb.org/movie/2064</url>
|
15
|
+
<short_overview>Guy saves a girl's life after an accident, then stays at her hospital bed, pretending to be her fianc´e, while she's in a coma.</short_overview>
|
16
|
+
<release>1995-06-27</release>
|
17
|
+
<poster size="original">http://www.themoviedb.org/image/posters/28202/While-You-Were-Sleeping-poster-edited.jpg</poster>
|
18
|
+
<poster size="mid">http://www.themoviedb.org/image/posters/28202/While-You-Were-Sleeping-poster-edited_mid.jpg</poster>
|
19
|
+
<poster size="thumb">http://www.themoviedb.org/image/posters/28202/While-You-Were-Sleeping-poster-edited_thumb.jpg</poster>
|
20
|
+
<poster size="cover">http://www.themoviedb.org/image/posters/28202/While-You-Were-Sleeping-poster-edited_cover.jpg</poster>
|
21
|
+
<backdrop size="original">http://www.themoviedb.org/image/backdrops/23357/Während_Du_schliefst.jpg</backdrop>
|
22
|
+
<backdrop size="mid">http://www.themoviedb.org/image/backdrops/23357/Während_Du_schliefst_poster.jpg</backdrop>
|
23
|
+
<backdrop size="thumb">http://www.themoviedb.org/image/backdrops/23357/Während_Du_schliefst_thumb.jpg</backdrop>
|
24
|
+
</movie>
|
25
|
+
</moviematches>
|
26
|
+
</results>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_poster.jpg
ADDED
Binary file
|
data/spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_thumb.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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.
|
4
|
+
version: 0.0.17
|
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-
|
12
|
+
date: 2009-04-18 00:00:00 -07:00
|
13
13
|
default_executable: dvdprofiler2xbmc
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.1.1
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: royw-tmdb
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.1.1
|
54
54
|
version:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: royw-dvdprofiler_collection
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.
|
63
|
+
version: 0.1.1
|
64
64
|
version:
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: log4r
|
@@ -149,6 +149,10 @@ files:
|
|
149
149
|
- spec/samples/The Egg and I.dummy
|
150
150
|
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0039349&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
151
151
|
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0060934&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
152
|
+
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0095016&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
153
|
+
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0108171&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
154
|
+
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0110413&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
155
|
+
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0114924&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
152
156
|
- spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0465234&api_key=7a2f6eb9b6aa01651000f0a9324db835
|
153
157
|
- spec/samples/www.imdb.com/find?q=%2Abatteries+not+included;s=tt
|
154
158
|
- spec/samples/www.imdb.com/find?q=About+a+Boy;s=tt
|
@@ -168,6 +172,18 @@ files:
|
|
168
172
|
- spec/samples/www.imdb.com/find?q=The+Egg+and+I;s=tt
|
169
173
|
- spec/samples/www.imdb.com/find?q=The+Man+from+Snowy+River;s=tt
|
170
174
|
- spec/samples/www.imdb.com/find?q=rooster+cogburn;s=tt
|
175
|
+
- spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4_.jpg
|
176
|
+
- spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4__poster.jpg
|
177
|
+
- spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4__thumb.jpg
|
178
|
+
- spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst.jpg
|
179
|
+
- spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_poster.jpg
|
180
|
+
- spec/samples/www.themoviedb.org/image/backdrops/23357/W%c3%a4hrend_Du_schliefst_thumb.jpg
|
181
|
+
- spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016.jpg
|
182
|
+
- spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016_poster.jpg
|
183
|
+
- spec/samples/www.themoviedb.org/image/backdrops/803/tt0095016_thumb.jpg
|
184
|
+
- spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart.jpg
|
185
|
+
- spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart_poster.jpg
|
186
|
+
- spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart_thumb.jpg
|
171
187
|
- spec/spec.opts
|
172
188
|
- spec/spec_helper.rb
|
173
189
|
- spec/xbmc_info_spec.rb
|