royw-dvdprofiler2xbmc 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +19 -13
- data/dvdprofiler2xbmc.gemspec +5 -5
- data/lib/dvdprofiler2xbmc.rb +19 -2
- data/lib/dvdprofiler2xbmc/app.rb +1 -0
- data/lib/dvdprofiler2xbmc/app_config.rb +11 -5
- data/lib/dvdprofiler2xbmc/cli.rb +26 -24
- data/lib/dvdprofiler2xbmc/media.rb +1 -1
- data/lib/dvdprofiler2xbmc/nfo.rb +97 -73
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
* http://www.github.com/royw/dvdprofiler2xbmc
|
4
4
|
|
5
|
+
== STATUS
|
6
|
+
|
7
|
+
The initial goal of using DVD Profiler data when available along
|
8
|
+
with IMDB data otherwise is just about met. There is still some
|
9
|
+
performance issues mainly related to using the production or
|
10
|
+
released years to refine searches that have multiple title matches.
|
11
|
+
|
12
|
+
Near term plans include:
|
13
|
+
* supporting multiple file matching patterns
|
14
|
+
* supporting directory containers
|
15
|
+
* interfacing to TMDb, primarily for fanart.
|
16
|
+
|
5
17
|
== DESCRIPTION:
|
6
18
|
|
7
19
|
This script will attempt to match up media files from a set of directories
|
@@ -17,16 +29,13 @@ scraping.
|
|
17
29
|
|
18
30
|
== NOTES:
|
19
31
|
|
20
|
-
1)
|
21
|
-
using this script instead of a scraper.
|
22
|
-
|
23
|
-
2) Currently only supports file based media containers, not directory
|
32
|
+
1) Currently only supports file based media containers, not directory
|
24
33
|
based.
|
25
34
|
|
26
|
-
|
35
|
+
2) Media filename convention is to take the media's title from DVD Profiler,
|
27
36
|
replace any punctuation with a space character, then replace any multiple
|
28
|
-
spaces with a single space. Next remove any leading or trailing spaces.
|
29
|
-
Optionally can append " - YYYY" where YYYY is the movie's release year.
|
37
|
+
spaces with a single space. Next remove any leading or trailing spaces.
|
38
|
+
Optionally can append " - YYYY" where YYYY is the movie's release year.
|
30
39
|
Naturally the extension is the media's container type. Note, you should
|
31
40
|
not include in the title edition info like "Widescreen" or "Special Edition"
|
32
41
|
eventhough there are some mistakes in the DVD Profiler profiles that do
|
@@ -45,9 +54,6 @@ Features:
|
|
45
54
|
|
46
55
|
Problems:
|
47
56
|
|
48
|
-
* Always overwriting .nfo. Needs to only write if there has been a change.
|
49
|
-
* Loses any tags not directly supported. Needs to change from overwrite
|
50
|
-
to merge.
|
51
57
|
* IMDB ID scraping doesn't handle boxed sets or multiple movies per media
|
52
58
|
file. I don't see how to work around this exept to eliminate from media
|
53
59
|
library.
|
@@ -55,7 +61,6 @@ Problems:
|
|
55
61
|
is to prompt for required parameters on first run.
|
56
62
|
* Needs to support selectable/multiple regex based naming conventions
|
57
63
|
* Needs to support directory containers
|
58
|
-
* Does not support stacking
|
59
64
|
* .dvdprofiler2xbmcrc uses base 10 integers for permissions. Should be
|
60
65
|
either base 8 or symbolic.
|
61
66
|
|
@@ -64,10 +69,10 @@ Problems:
|
|
64
69
|
First check the version by running:
|
65
70
|
|
66
71
|
$ bin/dvdprofiler2xbmc -v
|
67
|
-
INFO dvdprofiler2xbmc: Dvdprofiler2xbmc 0.0.
|
72
|
+
INFO dvdprofiler2xbmc: Dvdprofiler2xbmc 0.0.4
|
68
73
|
INFO dvdprofiler2xbmc: saving: /home/royw/.dvdprofiler2xbmcrc
|
69
74
|
|
70
|
-
Notice that this generated a config file for you
|
75
|
+
Notice that this generated a config file for you
|
71
76
|
(/home/royw/.dvdprofiler2xbmcrc) in your home directory.
|
72
77
|
|
73
78
|
Now edit the config file. Be sure to change the following fields to match
|
@@ -122,6 +127,7 @@ To process your media, simply run:
|
|
122
127
|
|
123
128
|
* ruby 1.8.x
|
124
129
|
* rubygem
|
130
|
+
* my imdb fork on github (gem install )
|
125
131
|
|
126
132
|
== INSTALL:
|
127
133
|
|
data/dvdprofiler2xbmc.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{dvdprofiler2xbmc}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Roy Wright"]
|
9
|
-
s.date = %q{2009-03-
|
9
|
+
s.date = %q{2009-03-30}
|
10
10
|
s.default_executable = %q{dvdprofiler2xbmc}
|
11
11
|
s.description = %q{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. 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.}
|
12
12
|
s.email = ["roy@wright.org"]
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_runtime_dependency(%q<log4r>, [">= 1.0.5"])
|
35
35
|
s.add_runtime_dependency(%q<commandline>, [">= 0.7.10"])
|
36
36
|
s.add_runtime_dependency(%q<mash>, [">= 0.0.3"])
|
37
|
-
s.add_development_dependency(%q<newgem>, [">= 1.
|
37
|
+
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
|
38
38
|
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
39
39
|
else
|
40
40
|
s.add_dependency(%q<activesupport>, [">= 2.0.2"])
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_dependency(%q<log4r>, [">= 1.0.5"])
|
44
44
|
s.add_dependency(%q<commandline>, [">= 0.7.10"])
|
45
45
|
s.add_dependency(%q<mash>, [">= 0.0.3"])
|
46
|
-
s.add_dependency(%q<newgem>, [">= 1.
|
46
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
47
47
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
48
48
|
end
|
49
49
|
else
|
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.add_dependency(%q<log4r>, [">= 1.0.5"])
|
54
54
|
s.add_dependency(%q<commandline>, [">= 0.7.10"])
|
55
55
|
s.add_dependency(%q<mash>, [">= 0.0.3"])
|
56
|
-
s.add_dependency(%q<newgem>, [">= 1.
|
56
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
57
57
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
58
58
|
end
|
59
59
|
end
|
data/lib/dvdprofiler2xbmc.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
+
require 'rubygems'
|
5
|
+
require 'yaml'
|
6
|
+
require 'xmlsimple'
|
7
|
+
require 'ftools'
|
8
|
+
require 'imdb'
|
9
|
+
require 'mash'
|
10
|
+
require 'log4r'
|
11
|
+
|
12
|
+
require 'dvdprofiler2xbmc/app'
|
13
|
+
require 'dvdprofiler2xbmc/app_config'
|
14
|
+
require 'dvdprofiler2xbmc/collection'
|
15
|
+
require 'dvdprofiler2xbmc/extensions'
|
16
|
+
require 'dvdprofiler2xbmc/media'
|
17
|
+
require 'dvdprofiler2xbmc/media_files'
|
18
|
+
require 'dvdprofiler2xbmc/nfo'
|
19
|
+
require 'dvdprofiler2xbmc/imdb'
|
20
|
+
|
4
21
|
module Dvdprofiler2xbmc
|
5
|
-
VERSION = '0.0.
|
6
|
-
end
|
22
|
+
VERSION = '0.0.5'
|
23
|
+
end
|
data/lib/dvdprofiler2xbmc/app.rb
CHANGED
@@ -29,6 +29,7 @@ class DvdProfiler2Xbmc
|
|
29
29
|
|
30
30
|
# the application's main execution loop
|
31
31
|
def execute
|
32
|
+
AppConfig[:logger].info { "Processing directories: #{AppConfig[:directories].join(", ")}" }
|
32
33
|
collection_filepath = File.expand_path(AppConfig[:collection_filespec])
|
33
34
|
collection = Collection.new(collection_filepath)
|
34
35
|
|
@@ -22,10 +22,14 @@ module AppConfig
|
|
22
22
|
|
23
23
|
def self.save
|
24
24
|
begin
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
unless @config.blank?
|
26
|
+
File.delete(@yaml_filespec) if File.exist?(@yaml_filespec)
|
27
|
+
AppConfig[:logger].info { "saving: #{@yaml_filespec}" }
|
28
|
+
File.open(@yaml_filespec, "w") do |f|
|
29
|
+
cfg = @config
|
30
|
+
cfg.delete('logger')
|
31
|
+
YAML.dump(cfg, f)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
rescue Exception => e
|
31
35
|
AppConfig[:logger].error { "Error saving config file \"#{@yaml_filespec} - " + e.to_s + "\n" + e.backtrace.join("\n")}
|
@@ -35,7 +39,9 @@ module AppConfig
|
|
35
39
|
def self.load
|
36
40
|
begin
|
37
41
|
if File.exist?(@yaml_filespec)
|
38
|
-
|
42
|
+
cfg = YAML.load_file(@yaml_filespec)
|
43
|
+
cfg.delete('logger')
|
44
|
+
@config.merge! cfg
|
39
45
|
end
|
40
46
|
rescue Exception => e
|
41
47
|
AppConfig[:logger].error { "Error loading config file \"#{@yaml_filespec} - " + e.to_s }
|
data/lib/dvdprofiler2xbmc/cli.rb
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'yaml'
|
3
|
-
require 'xmlsimple'
|
4
|
-
require 'ftools'
|
5
|
-
require 'imdb'
|
6
|
-
require 'mash'
|
7
|
-
require 'log4r'
|
8
1
|
require 'commandline/optionparser'
|
9
2
|
include CommandLine
|
10
3
|
|
11
|
-
require 'dvdprofiler2xbmc/app'
|
12
|
-
require 'dvdprofiler2xbmc/app_config'
|
13
|
-
require 'dvdprofiler2xbmc/collection'
|
14
|
-
require 'dvdprofiler2xbmc/extensions'
|
15
|
-
require 'dvdprofiler2xbmc/media'
|
16
|
-
require 'dvdprofiler2xbmc/media_files'
|
17
|
-
require 'dvdprofiler2xbmc/nfo'
|
18
|
-
|
19
4
|
# Command Line interface for the Dvdprofiler2Xbmc application.
|
20
5
|
# All application output is via AppConfig[:logger] so we have
|
21
6
|
# to set up the logger here.
|
@@ -43,6 +28,7 @@ module Dvdprofiler2xbmc
|
|
43
28
|
# the config files are read if config[:logger_output] is set
|
44
29
|
logger = Log4r::Logger.new('dvdprofiler2xbmc')
|
45
30
|
logger.outputters = Log4r::StdoutOutputter.new(:console)
|
31
|
+
Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
|
46
32
|
logger.level = Log4r::DEBUG
|
47
33
|
|
48
34
|
begin
|
@@ -62,17 +48,22 @@ module Dvdprofiler2xbmc
|
|
62
48
|
|
63
49
|
reinitialize_logger(logger, od["--quiet"], od["--debug"])
|
64
50
|
AppConfig.load
|
65
|
-
AppConfig[:imdb_query] = !od["--no_imdb_query"]
|
66
51
|
AppConfig.save
|
52
|
+
AppConfig[:imdb_query] = !od["--no_imdb_query"]
|
53
|
+
AppConfig[:logfile] = od['--output'] if od['--output']
|
54
|
+
AppConfig[:logfile_level] = od['--output_level'] if od['--output_level']
|
67
55
|
reinitialize_logger(logger, od["--quiet"], od["--debug"])
|
68
56
|
|
69
57
|
AppConfig[:do_update] = !od["--reports"]
|
70
58
|
|
59
|
+
AppConfig[:logger].info { "logfile => #{AppConfig[:logfile].inspect}" } unless AppConfig[:logfile].nil?
|
60
|
+
AppConfig[:logger].info { "logfile_level => #{AppConfig[:logfile_level].inspect}" } unless AppConfig[:logfile_level].nil?
|
61
|
+
|
71
62
|
unless od["--help"] || od["--version"]
|
72
63
|
# create and execute class instance here
|
73
64
|
app = DvdProfiler2Xbmc.instance
|
74
65
|
app.execute
|
75
|
-
app.report.each {|line|
|
66
|
+
app.report.each {|line| AppConfig[:logger].info line}
|
76
67
|
end
|
77
68
|
rescue Exception => eMsg
|
78
69
|
logger.error {eMsg.to_s}
|
@@ -97,6 +88,18 @@ module Dvdprofiler2xbmc
|
|
97
88
|
options << Option.new(:flag, :names => %w(--quiet -q), :opt_description => 'Display error messages only')
|
98
89
|
options << Option.new(:flag, :names => %w(--debug -d), :opt_description => 'Display debug messages')
|
99
90
|
options << Option.new(:flag, :names => %w(--reports -r), :opt_description => 'Display reports only. Do not do any updates.')
|
91
|
+
options << Option.new(:names => %w(--output -o),
|
92
|
+
:argument_arity => [1,1],
|
93
|
+
:arg_description => 'logfile',
|
94
|
+
:opt_description => 'Write log messages to file. Default = no log file',
|
95
|
+
:opt_found => OptionParser::GET_ARGS
|
96
|
+
)
|
97
|
+
options << Option.new(:names => %w(--output_level -l),
|
98
|
+
:argument_arity => [1,1],
|
99
|
+
:arg_description => 'level',
|
100
|
+
:opt_description => 'Output logging level: DEBUG, INFO, WARN, ERROR. Default = INFO',
|
101
|
+
:opt_found => OptionParser::GET_ARGS
|
102
|
+
)
|
100
103
|
options
|
101
104
|
end
|
102
105
|
|
@@ -105,20 +108,19 @@ module Dvdprofiler2xbmc
|
|
105
108
|
# config:: is the application's config hash.
|
106
109
|
def self.reinitialize_logger(logger, quiet, debug)
|
107
110
|
# switch the logger to the one specified in the config files
|
108
|
-
unless AppConfig[:logfile].
|
111
|
+
unless AppConfig[:logfile].blank?
|
109
112
|
logfile_outputter = Log4r::RollingFileOutputter.new(:logfile, :filename => AppConfig[:logfile], :maxsize => 1000000 )
|
110
113
|
logger.add logfile_outputter
|
111
|
-
|
114
|
+
AppConfig[:logfile_level] ||= 'INFO'
|
112
115
|
Log4r::Outputter[:logfile].formatter = Log4r::PatternFormatter.new(:pattern => "[%l] %d :: %M")
|
113
|
-
|
114
|
-
|
115
|
-
logfile_outputter.level = level_map[AppConfig[:logfile_level]] || Log4r::INFO
|
116
|
-
end
|
116
|
+
level_map = {'DEBUG' => Log4r::DEBUG, 'INFO' => Log4r::INFO, 'WARN' => Log4r::WARN}
|
117
|
+
logfile_outputter.level = level_map[AppConfig[:logfile_level].upcase] || Log4r::INFO
|
117
118
|
end
|
118
119
|
Log4r::Outputter[:console].level = Log4r::INFO
|
119
120
|
Log4r::Outputter[:console].level = Log4r::WARN if quiet
|
120
121
|
Log4r::Outputter[:console].level = Log4r::DEBUG if debug
|
121
|
-
|
122
|
+
Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
|
123
|
+
# logger.trace = true
|
122
124
|
AppConfig[:logger] = logger
|
123
125
|
end
|
124
126
|
end
|
@@ -30,6 +30,7 @@ class Media
|
|
30
30
|
def update
|
31
31
|
load unless @loaded
|
32
32
|
@nfo.update
|
33
|
+
@nfo.save
|
33
34
|
update_thumbnail
|
34
35
|
end
|
35
36
|
|
@@ -81,7 +82,6 @@ class Media
|
|
81
82
|
else
|
82
83
|
copy_thumbnail(@nfo.isbn)
|
83
84
|
end
|
84
|
-
@nfo.save
|
85
85
|
end
|
86
86
|
|
87
87
|
# fetch the thumbnail from IMDB and save as path_to('tbn')
|
data/lib/dvdprofiler2xbmc/nfo.rb
CHANGED
@@ -12,24 +12,6 @@ class NFO
|
|
12
12
|
@movie = {}
|
13
13
|
end
|
14
14
|
|
15
|
-
# save as a .nfo file, creating a backup if the .nfo already exists
|
16
|
-
def save
|
17
|
-
begin
|
18
|
-
unless @movie.empty?
|
19
|
-
@movie['title'] = @media.title if @movie['title'].blank?
|
20
|
-
nfo_filespec = @media.path_to(:nfo_extension)
|
21
|
-
nfo_backup_filespec = @media.path_to(:nfo_backup_extension)
|
22
|
-
File.delete(nfo_backup_filespec) if File.exist?(nfo_backup_filespec)
|
23
|
-
File.rename(nfo_filespec, nfo_backup_filespec) if File.exist?(nfo_filespec)
|
24
|
-
File.open(nfo_filespec, "w") do |file|
|
25
|
-
file.puts(to_xml)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
rescue Exception => e
|
29
|
-
AppConfig[:logger].error { "Error saving nfo file - " + e.to_s + "\n" + e.backtrace.join("\n")}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
15
|
# load the .nfo file into the @movie hash
|
34
16
|
def load
|
35
17
|
nfo_filespec = @media.path_to(:nfo_extension)
|
@@ -37,6 +19,9 @@ class NFO
|
|
37
19
|
if File.exist?(nfo_filespec) && (File.size(nfo_filespec) > 1)
|
38
20
|
File.open(nfo_filespec) do |file|
|
39
21
|
@movie = XmlSimple.xml_in(file)
|
22
|
+
@original_movie = @movie.dup
|
23
|
+
self.isbn = @movie['isbn']
|
24
|
+
self.imdb_id = @movie['id']
|
40
25
|
end
|
41
26
|
end
|
42
27
|
rescue Exception => e
|
@@ -50,43 +35,92 @@ class NFO
|
|
50
35
|
def update
|
51
36
|
begin
|
52
37
|
load_from_collection
|
53
|
-
if AppConfig[:imdb_query] && imdb_id.blank?
|
38
|
+
if AppConfig[:imdb_query] && self.imdb_id.blank?
|
54
39
|
load_from_imdb
|
55
40
|
end
|
56
41
|
@movie.merge!(to_movie(@dvd_hash))
|
57
42
|
rescue Exception => e
|
58
|
-
AppConfig[:logger].error { "Error updating \"#{
|
43
|
+
AppConfig[:logger].error { "Error updating \"#{@media.path_to(:nfo_extension)}\" - " + e.to_s + "\n" + e.backtrace.join("\n") }
|
59
44
|
raise e
|
60
45
|
end
|
61
46
|
end
|
62
47
|
|
48
|
+
# save as a .nfo file, creating a backup if the .nfo already exists
|
49
|
+
def save
|
50
|
+
begin
|
51
|
+
unless @movie.empty?
|
52
|
+
@movie['title'] = @media.title if @movie['title'].blank?
|
53
|
+
nfo_filespec = @media.path_to(:nfo_extension)
|
54
|
+
if dirty? || !File.exist?(nfo_filespec)
|
55
|
+
new_filespec = nfo_filespec + '.new'
|
56
|
+
File.open(new_filespec, "w") do |file|
|
57
|
+
file.puts(to_xml)
|
58
|
+
end
|
59
|
+
nfo_backup_filespec = @media.path_to(:nfo_backup_extension)
|
60
|
+
File.delete(nfo_backup_filespec) if File.exist?(nfo_backup_filespec)
|
61
|
+
File.rename(nfo_filespec, nfo_backup_filespec) if File.exist?(nfo_filespec)
|
62
|
+
File.rename(new_filespec, nfo_filespec)
|
63
|
+
AppConfig[:logger].info { "updated #{nfo_filespec}"}
|
64
|
+
File.delete(new_filespec) if File.exist?(new_filespec)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
rescue Exception => e
|
68
|
+
AppConfig[:logger].error { "Error saving nfo file - " + e.to_s + "\n" + e.backtrace.join("\n")}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def dirty?
|
73
|
+
result = false
|
74
|
+
if @original_movie.nil?
|
75
|
+
result = true
|
76
|
+
else
|
77
|
+
@movie.each do |key, value|
|
78
|
+
if @original_movie[key].nil?
|
79
|
+
result = true
|
80
|
+
break
|
81
|
+
end
|
82
|
+
if @movie[key].to_s != @original_movie[key].to_s
|
83
|
+
result = true
|
84
|
+
break
|
85
|
+
end
|
86
|
+
end
|
87
|
+
unless result
|
88
|
+
diff_keys = @movie.keys.sort - @original_movie.keys.sort
|
89
|
+
unless diff_keys.empty?
|
90
|
+
result = true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
63
97
|
# return the ISBN or nil
|
64
98
|
def isbn
|
65
|
-
if @dvd_hash[:isbn].blank?
|
66
|
-
@dvd_hash[:isbn] = @movie['isbn']
|
99
|
+
if @dvd_hash[:isbn].blank? && !@movie['isbn'].blank?
|
100
|
+
@dvd_hash[:isbn] = [@movie['isbn']].flatten.uniq.compact.first.to_s
|
67
101
|
end
|
68
102
|
@dvd_hash[:isbn]
|
69
103
|
end
|
70
104
|
|
71
105
|
# set the ISBN
|
72
|
-
def isbn=(
|
73
|
-
@dvd_hash[:isbn] =
|
106
|
+
def isbn=(n)
|
107
|
+
@dvd_hash[:isbn] = n.to_s unless n.blank?
|
74
108
|
end
|
75
109
|
|
76
110
|
# return the IMDB ID or nil
|
77
111
|
def imdb_id
|
78
|
-
if @dvd_hash[:imdb_id].nil?
|
79
|
-
@dvd_hash[:imdb_id] = @movie['id']
|
112
|
+
if @dvd_hash[:imdb_id].nil? && !@movie['id'].blank?
|
113
|
+
@dvd_hash[:imdb_id] = @movie['id'].to_s
|
80
114
|
end
|
81
115
|
unless @dvd_hash[:imdb_id].nil?
|
82
116
|
# make sure is not an array
|
83
|
-
@dvd_hash[:imdb_id] = [@dvd_hash[:imdb_id]].flatten.uniq.compact.first
|
117
|
+
@dvd_hash[:imdb_id] = [@dvd_hash[:imdb_id].to_s].flatten.uniq.compact.first
|
84
118
|
end
|
85
119
|
end
|
86
120
|
|
87
121
|
# set the IMDB ID
|
88
122
|
def imdb_id=(id)
|
89
|
-
@dvd_hash[:imdb_id] = id
|
123
|
+
@dvd_hash[:imdb_id] = id.to_s unless id.blank?
|
90
124
|
end
|
91
125
|
|
92
126
|
protected
|
@@ -94,16 +128,18 @@ class NFO
|
|
94
128
|
# load @dvd_hash from the collection
|
95
129
|
def load_from_collection
|
96
130
|
# find ISBN for each title and assign to the media
|
97
|
-
if isbn.nil?
|
131
|
+
if self.isbn.nil?
|
98
132
|
title_pattern = Collection.title_pattern(@media.title)
|
133
|
+
AppConfig[:logger].debug { "Using Collection.title_pattern => \"#{title_pattern}\""}
|
99
134
|
unless @collection.title_isbn_hash[title_pattern].nil?
|
100
|
-
isbn = [@collection.title_isbn_hash[title_pattern]].flatten.uniq.compact.first
|
135
|
+
self.isbn = [@collection.title_isbn_hash[title_pattern]].flatten.uniq.compact.first
|
136
|
+
AppConfig[:logger].info { "ISBN => #{self.isbn}" }
|
101
137
|
end
|
102
138
|
end
|
103
139
|
|
104
140
|
# merge the meta-data from the collection to dvd_hash
|
105
|
-
unless isbn.
|
106
|
-
collection_hash = @collection.isbn_dvd_hash[isbn]
|
141
|
+
unless self.isbn.blank?
|
142
|
+
collection_hash = @collection.isbn_dvd_hash[self.isbn]
|
107
143
|
@dvd_hash.merge!(collection_hash) unless collection_hash.blank?
|
108
144
|
end
|
109
145
|
end
|
@@ -111,16 +147,39 @@ class NFO
|
|
111
147
|
# load data from IMDB.com and merge into the @dvd_hash
|
112
148
|
def load_from_imdb
|
113
149
|
unless File.exist?(@media.path_to(:no_imdb_extension))
|
114
|
-
|
115
|
-
|
116
|
-
|
150
|
+
# find imdb_id
|
151
|
+
imdb = Imdb.new
|
152
|
+
ident = imdb.first(get_imdb_titles, [@media.year.to_i], @dvd_hash[:productionyear], @dvd_hash[:released])
|
153
|
+
unless ident.blank?
|
154
|
+
self.imdb_id = ident
|
155
|
+
end
|
156
|
+
|
157
|
+
# if we have an imdb_id, then merge the imdb_movie to @dvd_hash
|
117
158
|
unless self.imdb_id.nil?
|
118
159
|
imdb_movie = ImdbMovie.new(self.imdb_id.gsub(/^tt/, ''))
|
119
|
-
|
160
|
+
begin
|
161
|
+
@dvd_hash.merge!(to_dvd_hash(imdb_movie))
|
162
|
+
rescue Exception => e
|
163
|
+
AppConfig[:logger].info { "imdb_movie.url => #{imdb_movie.url} "}
|
164
|
+
raise e
|
165
|
+
end
|
120
166
|
end
|
121
167
|
end
|
122
168
|
end
|
123
169
|
|
170
|
+
def get_imdb_titles
|
171
|
+
titles = []
|
172
|
+
unless @dvd_hash[:title].blank?
|
173
|
+
titles << @dvd_hash[:title]
|
174
|
+
titles << Collection.title_pattern(@dvd_hash[:title])
|
175
|
+
end
|
176
|
+
unless @media.title.blank?
|
177
|
+
titles << @media.title
|
178
|
+
titles << Collection.title_pattern(@media.title)
|
179
|
+
end
|
180
|
+
titles.uniq.compact
|
181
|
+
end
|
182
|
+
|
124
183
|
# convert the @movie hash into xml and return the xml as a String
|
125
184
|
def to_xml
|
126
185
|
xml = ''
|
@@ -133,41 +192,6 @@ class NFO
|
|
133
192
|
xml
|
134
193
|
end
|
135
194
|
|
136
|
-
# try to find the imdb id for the movie
|
137
|
-
def imdb_lookup(title, years)
|
138
|
-
id = nil
|
139
|
-
|
140
|
-
AppConfig[:logger].info { "Searching IMDB for \"#{title}\"" }
|
141
|
-
unless title.blank?
|
142
|
-
begin
|
143
|
-
imdb_search = ImdbSearch.new(title)
|
144
|
-
id = imdb_search.find_id(:years => years, :media_path => @media.media_path)
|
145
|
-
rescue Exception => e
|
146
|
-
AppConfig[:logger].error { "Error searching IMDB - " + e.to_s }
|
147
|
-
AppConfig[:logger].error { e.backtrace.join("\n") }
|
148
|
-
end
|
149
|
-
end
|
150
|
-
AppConfig[:logger].info { "IMDB id => #{id}" } unless id.nil?
|
151
|
-
id
|
152
|
-
end
|
153
|
-
|
154
|
-
# Different databases seem to mix up released versus production years.
|
155
|
-
# So we combine both into a Array of integer years.
|
156
|
-
def released_years(dvd_hash)
|
157
|
-
years = []
|
158
|
-
unless dvd_hash[:productionyear].blank?
|
159
|
-
years += dvd_hash[:productionyear].collect{|y| [y.to_i - 1, y.to_i, y.to_i + 1]}.flatten
|
160
|
-
end
|
161
|
-
unless dvd_hash[:released].blank?
|
162
|
-
years += dvd_hash[:released].collect do |date|
|
163
|
-
y = nil
|
164
|
-
y = $1.to_i if date =~ /(\d{4})\-/
|
165
|
-
y
|
166
|
-
end
|
167
|
-
end
|
168
|
-
years.flatten.uniq.compact.sort
|
169
|
-
end
|
170
|
-
|
171
195
|
# given a ImdbMovie instance, extract meta-data into and return a dvd_hash
|
172
196
|
def to_dvd_hash(imdb_movie)
|
173
197
|
dvd_hash = {}
|
@@ -191,8 +215,8 @@ class NFO
|
|
191
215
|
movie['title'] = dvd_hash[:title]
|
192
216
|
movie['mpaa'] = dvd_hash[:rating] unless dvd_hash[:rating].blank?
|
193
217
|
movie['year'] = dvd_hash[:productionyear] unless dvd_hash[:productionyear].blank?
|
194
|
-
movie['outline'] = dvd_hash[:
|
195
|
-
movie['plot'] = dvd_hash[:
|
218
|
+
movie['outline'] = dvd_hash[:plot] unless dvd_hash[:plot].blank?
|
219
|
+
movie['plot'] = dvd_hash[:overview] unless dvd_hash[:overview].blank?
|
196
220
|
movie['runtime'] = dvd_hash[:runningtime] unless dvd_hash[:runningtime].blank?
|
197
221
|
movie['actor'] = dvd_hash[:actors] unless dvd_hash[:actors].blank?
|
198
222
|
movie['isbn'] = dvd_hash[:isbn] unless dvd_hash[:isbn].blank?
|
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.5
|
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-03-
|
12
|
+
date: 2009-03-30 00:00:00 -07:00
|
13
13
|
default_executable: dvdprofiler2xbmc
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 1.
|
83
|
+
version: 1.3.0
|
84
84
|
version:
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: hoe
|