serienrenamer 0.0.9 → 0.0.10

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.
data/bin/serienrenamer CHANGED
@@ -21,11 +21,11 @@ FileUtils.mkdir(CONFIG_DIR) unless File.directory?(CONFIG_DIR)
21
21
  ###
22
22
  # configuration
23
23
  STANDARD_CONFIG = {
24
- :default_directory => File.join(File.expand_path("~"), "Downloads"),
25
- :store_episode_info => false,
26
- :store_path => File.join(CONFIG_DIR, "information_storage.yml"),
27
- :byte_count_for_md5 => 2048,
28
- :illegal_words => %w{ ML },
24
+ :default_directory => File.join(File.expand_path("~"), "Downloads"),
25
+ :store_episode_info => false,
26
+ :store_path => File.join(CONFIG_DIR, "information_storage.yml"),
27
+ :byte_count_for_md5 => 2048,
28
+ :illegal_words => %w{ ML },
29
29
  }
30
30
 
31
31
  config = STANDARD_CONFIG.merge_with_serialized(CONFIG_FILE)
@@ -41,40 +41,40 @@ opts.separator("")
41
41
  opts.separator(" Options:")
42
42
 
43
43
  opts.on( "-p", "--plugin STRING", String,
44
- "use only this plugin") do |opt|
45
- options[:plugin] = opt
44
+ "use only this plugin") do |opt|
45
+ options[:plugin] = opt
46
46
  end
47
47
 
48
48
  opts.on( "-s", "--series STRING", String,
49
- "series name that will be set for all episodes") do |opt|
50
- options[:series] = opt
49
+ "series name that will be set for all episodes") do |opt|
50
+ options[:series] = opt
51
51
  end
52
52
 
53
- opts.on( "-S", "--[no-]season",
54
- "DIR contains episodes of one season of one series") do |opt|
55
- options[:is_single_season] = opt
53
+ opts.on( "-S", "--[no-]season",
54
+ "DIR contains episodes of one season of one series") do |opt|
55
+ options[:is_single_season] = opt
56
56
  end
57
57
 
58
- opts.on( "-i", "--[no-]ignore-filenamedata",
59
- "Always ask plugins for episode information") do |opt|
60
- options[:ignore_filenamedata] = opt
58
+ opts.on( "-i", "--[no-]ignore-filenamedata",
59
+ "Always ask plugins for episode information") do |opt|
60
+ options[:ignore_filenamedata] = opt
61
61
  end
62
62
 
63
- opts.on( "-a", "--[no-]all",
64
- "Process all files (including right formatted files)") do |opt|
65
- options[:process_all_files] = opt
63
+ opts.on( "-a", "--[no-]all",
64
+ "Process all files (including right formatted files)") do |opt|
65
+ options[:process_all_files] = opt
66
66
  end
67
67
 
68
68
  opts.on( "--showconfig", "Prints the current configuration.") do |opt|
69
- puts "loaded configuration options:"
70
- puts config.to_yaml
71
- exit(0)
69
+ puts "loaded configuration options:"
70
+ puts config.to_yaml
71
+ exit(0)
72
72
  end
73
73
 
74
74
  opts.on( "-v", "--version",
75
- "Prints the version number.") do |opt|
76
- puts Serienrenamer::VERSION
77
- exit(0)
75
+ "Prints the version number.") do |opt|
76
+ puts Serienrenamer::VERSION
77
+ exit(0)
78
78
  end
79
79
 
80
80
  opts.separator("")
@@ -88,7 +88,7 @@ rest = opts.permute(ARGV)
88
88
  ###
89
89
  # Load plugins #
90
90
  Dir[File.join(File.dirname(__FILE__),"../lib/plugin/*.rb")].each do |plugin|
91
- load plugin
91
+ load plugin
92
92
  end
93
93
  Serienrenamer::Pluginbase.registered_plugins.sort! {|x,y| y.priority <=> x.priority }
94
94
 
@@ -99,93 +99,95 @@ puts ""
99
99
  episode_directory = rest.pop || config[:default_directory]
100
100
 
101
101
  fail "'#{episode_directory}' does not exist or is not a directory" unless
102
- Dir.exists?(episode_directory)
102
+ Dir.exists?(episode_directory)
103
103
 
104
104
  Dir.chdir(episode_directory)
105
105
 
106
106
  ###
107
107
  # Iterate through all directory entries
108
108
  info_storage = Serienrenamer::InformationStore.new(
109
- config[:store_path], config[:byte_count_for_md5])
109
+ config[:store_path], config[:byte_count_for_md5])
110
110
 
111
111
  begin
112
112
 
113
- for entry in Dir.entries('.').sort do
113
+ for entry in Dir.entries('.').sort do
114
114
 
115
- next if entry.match(/^\./)
116
- next unless Serienrenamer::Episode.determine_video_file(entry)
115
+ next if entry.match(/^\./)
116
+ next unless Serienrenamer::Episode.determine_video_file(entry)
117
117
 
118
- # skip files that already have the right format
119
- unless options[:process_all_files]
120
- next if entry.match(/^S\d+E\d+.-.\w+.*\.\w+$/)
121
- end
118
+ # skip files that already have the right format
119
+ unless options[:process_all_files]
120
+ next if entry.match(/^S\d+E\d+.-.\w+.*\.\w+$/)
121
+ end
122
+
123
+ begin
124
+ epi = Serienrenamer::Episode.new(entry)
125
+ if options[:series]
126
+ epi.series = options[:series]
127
+ end
128
+ rescue => e
129
+ next
130
+ end
122
131
 
123
- begin
124
- epi = Serienrenamer::Episode.new(entry)
125
- if options[:series]
126
- epi.series = options[:series]
127
- end
128
- rescue => e
129
- next
132
+ puts "<<< #{entry}"
133
+
134
+ # if episodename is empty than query plugins
135
+ if epi.episodename.match(/\w+/).nil? || options[:ignore_filenamedata]
136
+
137
+ Serienrenamer::Pluginbase.registered_plugins.each do |plugin|
138
+ # skip plugins that are not feasable
139
+ next unless plugin.usable
140
+ next unless plugin.respond_to?(:generate_episode_information)
141
+ if options[:plugin]
142
+ next unless plugin.plugin_name.match(/#{options[:plugin]}/i)
130
143
  end
131
144
 
132
- puts "<<< #{entry}"
133
-
134
- # if episodename is empty than query plugins
135
- if epi.episodename.match(/\w+/).nil? || options[:ignore_filenamedata]
136
-
137
- Serienrenamer::Pluginbase.registered_plugins.each do |plugin|
138
- # skip plugins that are not feasable
139
- next unless plugin.usable
140
- next unless plugin.respond_to?(:generate_episode_information)
141
- if options[:plugin]
142
- next unless plugin.plugin_name.match(/#{options[:plugin]}/i)
143
- end
144
-
145
- # configure cleanup
146
- clean_data, extract_seriesname = false, false
147
- case plugin.plugin_name
148
- when "Textfile"
149
- clean_data, extract_seriesname = true, true
150
- when "SerienjunkiesOrgFeed"
151
- clean_data = true
152
- end
153
-
154
- extract_seriesname = false if options[:series]
155
-
156
- # ask plugin for information
157
- epiname = plugin.generate_episode_information(epi)[0]
158
- next if epiname == nil
159
-
160
- puts "[#{plugin.plugin_name}] - #{epiname}"
161
-
162
- epi.add_episode_information(epiname, clean_data, extract_seriesname)
163
- next unless epi.episodename.match(/\w+/)
164
-
165
- break
166
- end
145
+ # configure cleanup
146
+ clean_data, extract_seriesname = false, false
147
+ case plugin.plugin_name
148
+ when "Textfile"
149
+ clean_data, extract_seriesname = true, true
150
+ when "SerienjunkiesOrgFeed"
151
+ clean_data = true
152
+ when "SerienjunkiesOrg"
153
+ clean_data = true
167
154
  end
168
155
 
169
- puts ">>> #{epi.to_s}"
170
-
171
- print "Filename okay ([jy]/n): "
172
- char = get_character
173
- print char.chr
156
+ extract_seriesname = false if options[:series]
174
157
 
175
- unless char.chr.match(/[jy\r]/i)
176
- puts "\nwill be skipped ...\n\n"
177
- next
178
- end
158
+ # ask plugin for information
159
+ epiname = plugin.generate_episode_information(epi)[0]
160
+ next if epiname == nil
179
161
 
180
- info_storage.store(epi) if config[:store_episode_info]
162
+ puts "[#{plugin.plugin_name}] - #{epiname}"
181
163
 
182
- puts "\n\n"
164
+ epi.add_episode_information(epiname, clean_data, extract_seriesname)
165
+ next unless epi.episodename.match(/\w+/)
183
166
 
184
- epi.rename()
167
+ break
168
+ end
185
169
  end
186
170
 
171
+ puts ">>> #{epi.to_s}"
172
+
173
+ print "Filename okay ([jy]/n): "
174
+ char = get_character
175
+ print char.chr
176
+
177
+ unless char.chr.match(/[jy\r]/i)
178
+ puts "\nwill be skipped ...\n\n"
179
+ next
180
+ end
181
+
182
+ info_storage.store(epi) if config[:store_episode_info]
183
+
184
+ puts "\n\n"
185
+
186
+ epi.rename()
187
+ end
188
+
187
189
  rescue Interrupt => e
188
- puts
190
+ puts
189
191
  ensure
190
- info_storage.write() if config[:store_episode_info]
192
+ info_storage.write() if config[:store_episode_info]
191
193
  end
@@ -12,7 +12,7 @@ module Plugin
12
12
  def self.plugin_name; "SerienjunkiesDe" end
13
13
  def self.plugin_url; "http://serienjunkies.de" end
14
14
  def self.usable; true end
15
- def self.priority; 4 end
15
+ def self.priority; 50 end
16
16
 
17
17
  # this method will be called from the main program
18
18
  # with an Serienrenamer::Episode instance as parameter
@@ -11,7 +11,7 @@ module Plugin
11
11
 
12
12
  def self.plugin_name; "SerienjunkiesOrgFeed" end
13
13
  def self.usable; true end
14
- def self.priority; 10 end
14
+ def self.priority; 80 end
15
15
 
16
16
  @feed_url = 'http://serienjunkies.org/xml/feeds/episoden.xml'
17
17
 
@@ -13,7 +13,7 @@ module Plugin
13
13
  def self.plugin_name; "SerienjunkiesOrg" end
14
14
  def self.plugin_url; "http://serienjunkies.org" end
15
15
  def self.usable; true end
16
- def self.priority; 10 end
16
+ def self.priority; 60 end
17
17
 
18
18
  # Public: tries to search for an appropriate episodename
19
19
  #
@@ -11,7 +11,7 @@ module Plugin
11
11
 
12
12
  def self.plugin_name; "Wikipedia" end
13
13
  def self.usable; true end
14
- def self.priority; 5 end
14
+ def self.priority; 30 end
15
15
 
16
16
  @@WIKIPEDIA_URL = 'http://de.wikipedia.org/w/api.php'
17
17
 
data/lib/serienrenamer.rb CHANGED
@@ -3,7 +3,7 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
 
5
5
  module Serienrenamer
6
- VERSION = '0.0.9'
6
+ VERSION = '0.0.10'
7
7
 
8
8
  require 'serienrenamer/episode.rb'
9
9
  require 'serienrenamer/information_store.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serienrenamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: