sindex 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/sindex +58 -5
- data/lib/sindex/series_index.rb +65 -0
- data/lib/sindex/version.rb +1 -1
- data/sindex.gemspec +2 -3
- metadata +16 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 552391a571ac690c5883cad63976f6d31e96ae41
|
4
|
+
data.tar.gz: 8f91d85665809cd30d74bcd99cdd555e170181a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 07a5e6a260d79bb1ea5f85cca815f8c65fdc95d9485c337137218631f3dfad2e837d16ee3177ee261e142542db40acc8ab733be0e304de21a7abb465634fb231
|
7
|
+
data.tar.gz: dedc4575e054849f9f426ccc68dbacf03497532d0a128f251e47db7663caa5096eb92e1976119c664e8ce7a802420198562a9f9d522f066effa0c462c61a1f90
|
data/bin/sindex
CHANGED
@@ -6,7 +6,6 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
6
6
|
|
7
7
|
require 'sindex'
|
8
8
|
require 'serienrenamer'
|
9
|
-
require 'serienmover'
|
10
9
|
require 'fileutils'
|
11
10
|
require 'hashconfig'
|
12
11
|
require 'optparse'
|
@@ -58,6 +57,13 @@ OptionParser.new do |opts|
|
|
58
57
|
config[:index_file] = opt
|
59
58
|
end
|
60
59
|
|
60
|
+
opts.on( "-n", "--new-series STRING", String,
|
61
|
+
"Add a new series to the index. It creates an episode S01E00 for you.") do |opt|
|
62
|
+
|
63
|
+
options[:new_series] ||= []
|
64
|
+
options[:new_series] << opt
|
65
|
+
end
|
66
|
+
|
61
67
|
opts.on( "-b", "--buildindex STRING", String,
|
62
68
|
"Build an index by reading the series/episodes from the supplied directory") do |opt|
|
63
69
|
|
@@ -99,6 +105,7 @@ class Cmdline
|
|
99
105
|
@processed_episodes = {}
|
100
106
|
end
|
101
107
|
|
108
|
+
|
102
109
|
def build_up_index
|
103
110
|
@series_index = Sindex::SeriesIndex.new
|
104
111
|
@series_index.build_up_index_from_directory(
|
@@ -107,6 +114,26 @@ class Cmdline
|
|
107
114
|
@series_index.dump_index_to_file(@config[:index_file])
|
108
115
|
end
|
109
116
|
|
117
|
+
|
118
|
+
def add_new_series
|
119
|
+
call_pre_processing_hook
|
120
|
+
|
121
|
+
@series_index = Sindex::SeriesIndex.new(index_file: @config[:index_file])
|
122
|
+
changed = false
|
123
|
+
|
124
|
+
@options[:new_series].each do |series|
|
125
|
+
next unless series =~ /\w+/
|
126
|
+
next if @series_index.is_series_in_index?(series)
|
127
|
+
|
128
|
+
puts "Creating new index entry for '%s' with S01E00 episode" % [series]
|
129
|
+
@series_index.add_new_series_to_index(series)
|
130
|
+
changed = true
|
131
|
+
end
|
132
|
+
|
133
|
+
write_new_index_if_wanted if changed
|
134
|
+
end
|
135
|
+
|
136
|
+
|
110
137
|
def mark_as_watched
|
111
138
|
call_pre_processing_hook
|
112
139
|
|
@@ -158,7 +185,11 @@ class Cmdline
|
|
158
185
|
added_episodes=true
|
159
186
|
end
|
160
187
|
|
161
|
-
|
188
|
+
write_new_index_if_wanted if added_episodes
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
def write_new_index_if_wanted
|
162
193
|
|
163
194
|
if agree("\nShould I write the new index? ", true)
|
164
195
|
@series_index.dump_index_to_file(@config[:index_file])
|
@@ -167,7 +198,7 @@ class Cmdline
|
|
167
198
|
# Post process all the episodes with a different hook
|
168
199
|
if @config[:episode_hook] and @config[:episode_hook].match(/\w+/)
|
169
200
|
@processed_episodes.each do |filename,series|
|
170
|
-
puts "Calling
|
201
|
+
puts "Calling Episode Hook for '#{filename}'"
|
171
202
|
cmd = '%s "%s" "%s"' % [ @config[:episode_hook], filename, series ]
|
172
203
|
system(cmd) or fail("Episode-Hook failed")
|
173
204
|
end
|
@@ -193,6 +224,7 @@ class Cmdline
|
|
193
224
|
end
|
194
225
|
end
|
195
226
|
|
227
|
+
|
196
228
|
def call_post_processing_hook
|
197
229
|
# calling the post-processing hook to allow a git commit/push or something
|
198
230
|
# else in a Script
|
@@ -201,6 +233,7 @@ class Cmdline
|
|
201
233
|
end
|
202
234
|
end
|
203
235
|
|
236
|
+
|
204
237
|
def determine_episode_language(seriesname, filename)
|
205
238
|
series = @series_index.series_data[seriesname]
|
206
239
|
|
@@ -224,14 +257,28 @@ class Cmdline
|
|
224
257
|
end
|
225
258
|
end
|
226
259
|
|
260
|
+
|
227
261
|
def determine_series_name_for_episode(filename)
|
228
262
|
sum = md5sum(filename)
|
229
263
|
if not @info_store.episode_hash[sum].nil?
|
230
264
|
series_pattern = @info_store.episode_hash[sum]
|
231
265
|
puts "<< from infostore: #{series_pattern}"
|
232
266
|
|
233
|
-
|
234
|
-
|
267
|
+
# try to find an exact match otherwise a fuzzy matching approach
|
268
|
+
fuzzy = false
|
269
|
+
matching_series = []
|
270
|
+
|
271
|
+
loop do
|
272
|
+
matching_series = @series_index.series_data.keys.select do |seriesname|
|
273
|
+
Sindex::SeriesIndex.does_the_series_match?(seriesname, series_pattern, fuzzy)
|
274
|
+
end
|
275
|
+
|
276
|
+
if matching_series.empty? and not fuzzy
|
277
|
+
fuzzy = true
|
278
|
+
redo
|
279
|
+
end
|
280
|
+
|
281
|
+
break
|
235
282
|
end
|
236
283
|
|
237
284
|
series = nil
|
@@ -259,6 +306,7 @@ class Cmdline
|
|
259
306
|
end
|
260
307
|
end
|
261
308
|
|
309
|
+
|
262
310
|
# Private: Generates a md5sum for the number of bytes for the supplied file
|
263
311
|
#
|
264
312
|
# Returns filename
|
@@ -278,8 +326,13 @@ end
|
|
278
326
|
|
279
327
|
cmd = Cmdline.new(config, options)
|
280
328
|
begin
|
329
|
+
|
281
330
|
if options[:build_index_from_dir]
|
282
331
|
cmd.build_up_index
|
332
|
+
|
333
|
+
elsif options[:new_series]
|
334
|
+
cmd.add_new_series
|
335
|
+
|
283
336
|
else
|
284
337
|
cmd.mark_as_watched
|
285
338
|
end
|
data/lib/sindex/series_index.rb
CHANGED
@@ -111,6 +111,7 @@ module Sindex
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
|
114
115
|
# Public: checks if the seriesname in the supplied data is in the
|
115
116
|
# index or an alias to a series
|
116
117
|
#
|
@@ -127,6 +128,7 @@ module Sindex
|
|
127
128
|
! series_name_in_index(episode_text).nil?
|
128
129
|
end
|
129
130
|
|
131
|
+
|
130
132
|
# Public: Adds episode to index
|
131
133
|
#
|
132
134
|
# :series_name
|
@@ -141,6 +143,18 @@ module Sindex
|
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
146
|
+
|
147
|
+
# Public: Adds a new series to the index with an S01E00 episode
|
148
|
+
def add_new_series_to_index(series_name)
|
149
|
+
raise ArgumentError, "series (#{ series_name }) is already in index" if
|
150
|
+
is_series_in_index?(series_name)
|
151
|
+
|
152
|
+
series = Sindex::Series.new
|
153
|
+
series.add_episode("S01E00 - some really cool episode name.mkv")
|
154
|
+
|
155
|
+
@series_data[series_name] = series
|
156
|
+
end
|
157
|
+
|
144
158
|
class << self
|
145
159
|
|
146
160
|
# Public: tries to extract the seriesname from supplied data
|
@@ -167,6 +181,57 @@ module Sindex
|
|
167
181
|
nil
|
168
182
|
end
|
169
183
|
|
184
|
+
|
185
|
+
# Public: tries to match the suppplied seriesname pattern
|
186
|
+
# agains the series
|
187
|
+
#
|
188
|
+
# seriesname - the seriesname that comes from the index
|
189
|
+
# series_pattern - the series_name that has to be checked
|
190
|
+
# agains the seriesname
|
191
|
+
# fuzzy - does a fuzzy match against the series
|
192
|
+
#
|
193
|
+
# Returns true if it matches otherwise false
|
194
|
+
def does_the_series_match?(seriesname, series_pattern, fuzzy=false)
|
195
|
+
|
196
|
+
if seriesname.match(/#{series_pattern}/i)
|
197
|
+
# if pattern matches the series directly
|
198
|
+
return true
|
199
|
+
|
200
|
+
elsif fuzzy
|
201
|
+
# start with a pattern that includes all words from
|
202
|
+
# series_pattern and if this does not match, it cuts
|
203
|
+
# off the first word and tries to match again
|
204
|
+
#
|
205
|
+
# if the pattern contains one word and if this
|
206
|
+
# still not match, the last word is splitted
|
207
|
+
# characterwise, so that:
|
208
|
+
# crmi ==> Criminal Minds
|
209
|
+
name_words = series_pattern.split(/ /)
|
210
|
+
word_splitted = false
|
211
|
+
|
212
|
+
while ! name_words.empty?
|
213
|
+
|
214
|
+
pattern = name_words.join('.*')
|
215
|
+
return true if seriesname.match(/#{pattern}/i)
|
216
|
+
|
217
|
+
# split characterwise if last word does not match
|
218
|
+
if name_words.length == 1 && ! word_splitted
|
219
|
+
name_words = pattern.split(//)
|
220
|
+
word_splitted = true
|
221
|
+
next
|
222
|
+
end
|
223
|
+
|
224
|
+
# if last word was splitted and does not match than break
|
225
|
+
# and return empty resultset
|
226
|
+
break if word_splitted
|
227
|
+
|
228
|
+
name_words.delete_at(0)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
false
|
233
|
+
end
|
234
|
+
|
170
235
|
end
|
171
236
|
|
172
237
|
private
|
data/lib/sindex/version.rb
CHANGED
data/sindex.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = "sindex"
|
8
8
|
gem.version = Sindex::VERSION
|
9
9
|
gem.authors = ["Philipp Böhm"]
|
10
|
-
gem.email = ["philipp
|
10
|
+
gem.email = ["philipp@pboehm.org"]
|
11
11
|
gem.description = %q{Tool and library that manages the episodes you have seen in different tv series}
|
12
12
|
gem.summary = %q{Series-Index that manages your watched episodes}
|
13
13
|
gem.homepage = "https://github.com/pboehm/sindex"
|
@@ -20,6 +20,5 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_runtime_dependency(%q<nokogiri>, [">= 1.5"])
|
21
21
|
gem.add_runtime_dependency(%q<hashconfig>, [">= 0.0.1"])
|
22
22
|
gem.add_runtime_dependency(%q<serienrenamer>, [">= 0.0.16"])
|
23
|
-
gem.add_runtime_dependency(%q<
|
24
|
-
gem.add_runtime_dependency(%q<highline>, ["= 1.6.13"])
|
23
|
+
gem.add_runtime_dependency(%q<highline>, ["~> 1.6.13"])
|
25
24
|
end
|
metadata
CHANGED
@@ -1,100 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sindex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Philipp Böhm
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.5'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.5'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: hashconfig
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.0.1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.0.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: serienrenamer
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.0.16
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.0.16
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: serienmover
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.0.1
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.0.1
|
78
55
|
- !ruby/object:Gem::Dependency
|
79
56
|
name: highline
|
80
57
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
58
|
requirements:
|
83
|
-
- -
|
59
|
+
- - ~>
|
84
60
|
- !ruby/object:Gem::Version
|
85
61
|
version: 1.6.13
|
86
62
|
type: :runtime
|
87
63
|
prerelease: false
|
88
64
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
65
|
requirements:
|
91
|
-
- -
|
66
|
+
- - ~>
|
92
67
|
- !ruby/object:Gem::Version
|
93
68
|
version: 1.6.13
|
94
69
|
description: Tool and library that manages the episodes you have seen in different
|
95
70
|
tv series
|
96
71
|
email:
|
97
|
-
- philipp
|
72
|
+
- philipp@pboehm.org
|
98
73
|
executables:
|
99
74
|
- sindex
|
100
75
|
extensions: []
|
@@ -121,33 +96,26 @@ files:
|
|
121
96
|
- test/test_testdata.rb
|
122
97
|
homepage: https://github.com/pboehm/sindex
|
123
98
|
licenses: []
|
99
|
+
metadata: {}
|
124
100
|
post_install_message:
|
125
101
|
rdoc_options: []
|
126
102
|
require_paths:
|
127
103
|
- lib
|
128
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
105
|
requirements:
|
131
|
-
- -
|
106
|
+
- - '>='
|
132
107
|
- !ruby/object:Gem::Version
|
133
108
|
version: '0'
|
134
|
-
segments:
|
135
|
-
- 0
|
136
|
-
hash: 942148595
|
137
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
110
|
requirements:
|
140
|
-
- -
|
111
|
+
- - '>='
|
141
112
|
- !ruby/object:Gem::Version
|
142
113
|
version: '0'
|
143
|
-
segments:
|
144
|
-
- 0
|
145
|
-
hash: 942148595
|
146
114
|
requirements: []
|
147
115
|
rubyforge_project:
|
148
|
-
rubygems_version:
|
116
|
+
rubygems_version: 2.0.3
|
149
117
|
signing_key:
|
150
|
-
specification_version:
|
118
|
+
specification_version: 4
|
151
119
|
summary: Series-Index that manages your watched episodes
|
152
120
|
test_files:
|
153
121
|
- test/seriesindex_example.xml
|