serienmover 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,26 @@ to rename these files.
8
8
 
9
9
  $ gem install serienmover
10
10
 
11
+ That installs an executable named `serienmover` that is used to
12
+ process the files.
13
+
14
+ ## Features
15
+
16
+ * searches for a possible target in your series directories
17
+ * can read a Yaml file from `serienrenamer` which holds the series names
18
+ from the renamed files, indexed by md5sum
19
+ * creates a new season directory if episode is the first of a new season
20
+ by detecting the pattern from former seasons
21
+ * has some metrics to find mostly the right target
22
+ * can process the series automatic by file
23
+
11
24
  ## Usage
12
25
 
13
- TODO: Write usage instructions here
26
+ $ serienmover
27
+
28
+ ## Configuration
29
+
30
+ You can change the behaviour of `serienmover` with commandline arguments
31
+ (`serienmover --help` for an overview) or by editing the config file
32
+ under `~/.serienmover/config.yml`.
14
33
 
data/bin/serienmover CHANGED
@@ -21,12 +21,14 @@ 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
- :series_directories => [],
26
- :read_episode_info => false,
27
- :store_path => '',
28
- :byte_count_for_md5 => 2048,
29
- :collective_directory => '',
24
+ :default_directory => File.join(File.expand_path("~"), "Downloads"),
25
+ :series_directories => [],
26
+ :read_episode_info => false,
27
+ :store_path => '',
28
+ :byte_count_for_md5 => 2048,
29
+ :collective_directory => '',
30
+ :auto_process_list => false,
31
+ :auto_process_list_file => File.join(CONFIG_DIR, "autoprocess.yml")
30
32
  }
31
33
 
32
34
  config = STANDARD_CONFIG.merge_with_serialized(CONFIG_FILE)
@@ -59,6 +61,11 @@ OptionParser.new do |opts|
59
61
  config[:read_episode_info] = false
60
62
  end
61
63
 
64
+ opts.on( "-n", "--[no]-autoprocess",
65
+ "use a file to select between copying and moving") do |opt|
66
+ config[:auto_process_list] = opt
67
+ end
68
+
62
69
  opts.on( "-v", "--version",
63
70
  "Outputs the version number.") do |opt|
64
71
  puts Serienmover::VERSION
@@ -86,6 +93,16 @@ Dir.chdir(episode_directory)
86
93
  # instantiate the series_store
87
94
  store = Serienmover::SeriesStore.new(config[:series_directories])
88
95
 
96
+ ###
97
+ # build up and load autoprocess list
98
+ autoprocess_list = {}
99
+
100
+ if config[:auto_process_list] && config[:auto_process_list] == true
101
+ exisiting_series = Hash[store.series_list.map{ |s| [s, "n"] }]
102
+ autoprocess_list =
103
+ exisiting_series.merge_with_serialized(config[:auto_process_list_file])
104
+ end
105
+
89
106
  ###
90
107
  # instantiate information store
91
108
  info_store = Serienrenamer::InformationStore.new(
@@ -147,18 +164,28 @@ Dir.new('.').to_a.sort.each do |file|
147
164
  puts ">> '%s'" % selected_target
148
165
  episode.target = selected_target
149
166
 
167
+ # get the choice from the autoprocess
168
+ choice = autoprocess_list[episode.target.series]
169
+ copy = nil
170
+ copy = true if choice && choice.match(/[ck]/i)
171
+ copy = false if choice && choice.match(/[vm]/i)
172
+
150
173
  ###
151
174
  # ask for the action (copy/move)
152
175
  print "What should be done ( [c]opy (*) , [m]ove ): "
153
- char = get_character
154
- print char.chr unless char.chr.match(/\r/)
176
+ char = nil
155
177
 
156
- unless char.chr.match(/[kcmv\r]/i)
157
- puts "\nwill be skipped ...\n\n"
158
- next
178
+ if copy.nil?
179
+ char = get_character
180
+ print char.chr unless char.chr.match(/\r/)
181
+
182
+ unless char.chr.match(/[kcmv\r]/i)
183
+ puts "\nwill be skipped ...\n\n"
184
+ next
185
+ end
159
186
  end
160
187
 
161
- if char.chr.match(/[kc\r]/i)
188
+ if copy == true || char && char.chr.match(/[kc\r]/i)
162
189
  episode.set_action(copy: true)
163
190
  print " ... copy"
164
191
  else
@@ -147,6 +147,13 @@ module Serienmover
147
147
  File.join(target.targetdir, episode.to_s)
148
148
  end
149
149
 
150
+ # Public: list of all series in the store
151
+ #
152
+ # Returns an array of all exisiting series
153
+ def series_list
154
+ @series_data.keys
155
+ end
156
+
150
157
  class << self
151
158
 
152
159
  # Public: tries to match the suppplied seriesname pattern
@@ -1,3 +1,3 @@
1
1
  module Serienmover
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -107,4 +107,11 @@ describe Serienmover::SeriesStore do
107
107
  less_results = @store.find_suitable_target(episode)
108
108
  less_results.size.should be 1
109
109
  end
110
+
111
+ it "should return a list with all seriesnames" do
112
+ series = @store.series_list()
113
+
114
+ series.is_a?(Array).should be_true
115
+ series.include?("Criminal Minds").should be_true
116
+ end
110
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serienmover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-08 00:00:00.000000000 Z
12
+ date: 2012-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: serienrenamer