serienrenamer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +3 -0
- data/bin/serienrenamer +27 -7
- data/lib/plugin/serienjunkies_feed.rb +1 -1
- data/lib/serienrenamer/episode.rb +12 -0
- data/lib/serienrenamer/information_store.rb +42 -0
- data/lib/serienrenamer.rb +30 -1
- data/test/test_episode.rb +101 -75
- data/test/test_hash.rb +54 -0
- data/test/test_helper.rb +57 -0
- data/test/test_information_store.rb +48 -0
- data/test/test_plugin_serienjunkies_de.rb +25 -25
- data/test/test_plugin_serienjunkies_feed.rb +43 -43
- data/test/test_plugin_textfile.rb +12 -12
- data/test/test_plugin_wikipedia.rb +22 -25
- metadata +21 -16
data/Manifest.txt
CHANGED
@@ -10,13 +10,16 @@ lib/plugin/textfile.rb
|
|
10
10
|
lib/plugin/wikipedia.rb
|
11
11
|
lib/serienrenamer.rb
|
12
12
|
lib/serienrenamer/episode.rb
|
13
|
+
lib/serienrenamer/information_store.rb
|
13
14
|
script/console
|
14
15
|
script/destroy
|
15
16
|
script/generate
|
16
17
|
serienrenamer.gemspec
|
17
18
|
test/serienjunkies_feed_sample.xml
|
18
19
|
test/test_episode.rb
|
20
|
+
test/test_hash.rb
|
19
21
|
test/test_helper.rb
|
22
|
+
test/test_information_store.rb
|
20
23
|
test/test_plugin_serienjunkies_de.rb
|
21
24
|
test/test_plugin_serienjunkies_feed.rb
|
22
25
|
test/test_plugin_textfile.rb
|
data/bin/serienrenamer
CHANGED
@@ -11,8 +11,24 @@ require 'fileutils'
|
|
11
11
|
require "highline/system_extensions"
|
12
12
|
include HighLine::SystemExtensions
|
13
13
|
|
14
|
+
# create program configuration dirs/files
|
15
|
+
CONFIG_DIR = File.join( File.expand_path("~"), ".serienrenamer" )
|
16
|
+
CONFIG_FILE = File.join( CONFIG_DIR, "config.yml" )
|
17
|
+
FileUtils.mkdir(CONFIG_DIR) unless File.directory?(CONFIG_DIR)
|
18
|
+
|
19
|
+
###
|
20
|
+
# configuration
|
21
|
+
STANDARD_CONFIG = {
|
22
|
+
:default_directory => File.join(File.expand_path("~"), "Downloads"),
|
23
|
+
:store_episode_info => false,
|
24
|
+
:store_path => File.join(CONFIG_DIR, "information_storage.yml"),
|
25
|
+
:illegal_words => %w{ ML },
|
26
|
+
}
|
27
|
+
|
28
|
+
config = STANDARD_CONFIG.merge_with_serialized(CONFIG_FILE)
|
29
|
+
|
14
30
|
###
|
15
|
-
#
|
31
|
+
# option definition and handling
|
16
32
|
options = {}
|
17
33
|
opts = OptionParser.new("Usage: #{$0} [OPTIONS] DIR")
|
18
34
|
opts.separator("")
|
@@ -60,9 +76,8 @@ opts.separator("")
|
|
60
76
|
|
61
77
|
rest = opts.permute(ARGV)
|
62
78
|
|
63
|
-
|
79
|
+
###
|
64
80
|
# Load plugins #
|
65
|
-
################
|
66
81
|
Dir[File.join(File.dirname(__FILE__),"../lib/plugin/*.rb")].each do |plugin|
|
67
82
|
load plugin
|
68
83
|
end
|
@@ -72,16 +87,17 @@ puts "Plugins loaded: #{Serienrenamer::Pluginbase.registered_plugins.inspect}"
|
|
72
87
|
puts ""
|
73
88
|
|
74
89
|
# change into DIR
|
75
|
-
episode_directory = rest.pop ||
|
90
|
+
episode_directory = rest.pop || config[:default_directory]
|
76
91
|
|
77
92
|
fail "'#{episode_directory}' does not exist or is not a directory" unless
|
78
93
|
Dir.exists?(episode_directory)
|
79
94
|
|
80
95
|
Dir.chdir(episode_directory)
|
81
96
|
|
82
|
-
|
83
|
-
# Iterate through all directory entries
|
84
|
-
|
97
|
+
###
|
98
|
+
# Iterate through all directory entries
|
99
|
+
info_storage = Serienrenamer::InformationStore.new(config[:store_path])
|
100
|
+
|
85
101
|
begin
|
86
102
|
|
87
103
|
for entry in Dir.entries('.').sort do
|
@@ -151,6 +167,8 @@ begin
|
|
151
167
|
next
|
152
168
|
end
|
153
169
|
|
170
|
+
info_storage.store(epi) if config[:store_episode_info]
|
171
|
+
|
154
172
|
puts "\n\n"
|
155
173
|
|
156
174
|
epi.rename()
|
@@ -158,4 +176,6 @@ begin
|
|
158
176
|
|
159
177
|
rescue Interrupt => e
|
160
178
|
puts
|
179
|
+
ensure
|
180
|
+
info_storage.write() if config[:store_episode_info]
|
161
181
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'find'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'wlapi'
|
5
|
+
require 'digest/md5'
|
5
6
|
|
6
7
|
module Serienrenamer
|
7
8
|
|
@@ -150,11 +151,22 @@ module Serienrenamer
|
|
150
151
|
end
|
151
152
|
|
152
153
|
@success = true
|
154
|
+
@episodepath = destination_file
|
153
155
|
rescue SystemCallError => e
|
154
156
|
puts "Rename failed: #{e}"
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|
160
|
+
# returns the md5sum of the episode_path so that it can
|
161
|
+
# be distinguished
|
162
|
+
def md5sum
|
163
|
+
if File.file?(@episodepath)
|
164
|
+
d = Digest::MD5.new
|
165
|
+
return d.hexdigest(open(@episodepath, 'rb').read)
|
166
|
+
end
|
167
|
+
return nil
|
168
|
+
end
|
169
|
+
|
158
170
|
##################
|
159
171
|
# static methods #
|
160
172
|
##################
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Serienrenamer
|
4
|
+
|
5
|
+
# this class holds a storage for episode information (seriesname)
|
6
|
+
# in form of a yaml file which can be used from other tools
|
7
|
+
class InformationStore
|
8
|
+
|
9
|
+
attr_reader :episode_hash
|
10
|
+
|
11
|
+
# this method will load an exisiting yaml file and tries to rebuild
|
12
|
+
# the used hash with episode data
|
13
|
+
def initialize(yaml_path)
|
14
|
+
@yaml_path = yaml_path
|
15
|
+
@episode_hash = {}
|
16
|
+
|
17
|
+
if File.file?(yaml_path)
|
18
|
+
@episode_hash = YAML.load(File.new(yaml_path, "rb").read)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# this method will store the information of the supplied episode
|
23
|
+
# instance to the file
|
24
|
+
def store(episode)
|
25
|
+
raise ArgumentError, "Episode instance needed" unless
|
26
|
+
episode.is_a? Serienrenamer::Episode
|
27
|
+
|
28
|
+
unless @episode_hash[episode.md5sum]
|
29
|
+
@episode_hash[episode.md5sum] = episode.series
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# this method will write the current hash of episodes to the
|
34
|
+
# yaml file
|
35
|
+
def write()
|
36
|
+
storage_file = File.new(@yaml_path, "w")
|
37
|
+
storage_file.write(@episode_hash.to_yaml)
|
38
|
+
storage_file.close
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/serienrenamer.rb
CHANGED
@@ -3,9 +3,10 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
3
3
|
|
4
4
|
|
5
5
|
module Serienrenamer
|
6
|
-
VERSION = '0.0.
|
6
|
+
VERSION = '0.0.4'
|
7
7
|
|
8
8
|
require 'serienrenamer/episode.rb'
|
9
|
+
require 'serienrenamer/information_store.rb'
|
9
10
|
|
10
11
|
class Pluginbase
|
11
12
|
|
@@ -25,4 +26,32 @@ module Serienrenamer
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
# reopening Hash class and added a persistence method
|
30
|
+
require 'yaml'
|
31
|
+
|
32
|
+
class ::Hash
|
33
|
+
|
34
|
+
# this method merges a YAML-serialized hash-instance
|
35
|
+
# with self. if the given File is not exisiting this will write
|
36
|
+
# a serialized version of self to this file.
|
37
|
+
#
|
38
|
+
# if the given yaml file does not contain a serialized hash than it
|
39
|
+
# merges with an empty hash that returns self unchanged.
|
40
|
+
#
|
41
|
+
# returns a new Hash merged with deserialized version from the file
|
42
|
+
def merge_with_serialized(yaml_file)
|
43
|
+
|
44
|
+
unless File.file? yaml_file
|
45
|
+
File.open(yaml_file, 'w') {|f| f.write(self.to_yaml) }
|
46
|
+
end
|
47
|
+
|
48
|
+
persistent_config = YAML.load(File.new(yaml_file, "rb").read)
|
49
|
+
persistent_config = Hash.new unless persistent_config.is_a? Hash
|
50
|
+
|
51
|
+
config = self.merge(persistent_config)
|
52
|
+
File.open(yaml_file, 'w') {|f| f.write(config.to_yaml) }
|
53
|
+
|
54
|
+
return config
|
55
|
+
end
|
56
|
+
end
|
28
57
|
end
|
data/test/test_episode.rb
CHANGED
@@ -4,170 +4,183 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
class TestEpisode < Test::Unit::TestCase
|
6
6
|
|
7
|
-
@@
|
8
|
-
'chuckfull' => '
|
9
|
-
'chuck1' => '
|
10
|
-
'chuck2' => '
|
11
|
-
'chuck3' => '
|
12
|
-
'without'=> '
|
13
|
-
'royal' => '
|
14
|
-
'flpo' => '
|
15
|
-
'csiny' => '
|
16
|
-
'legaltrash' =>'
|
7
|
+
@@files = {
|
8
|
+
'chuckfull' => 'Chuck.S01E01.Dies.ist.ein.Test.German.Dubbed.BLURAYRiP.DELiCiOUS.WEBRiP.CiD.avi',
|
9
|
+
'chuck1' => 'chuck.512.hdtv-lol.avi',
|
10
|
+
'chuck2' => 'chuck.1212.hdtv-lol.avi',
|
11
|
+
'chuck3' => 'chuck.5x12.hdtv-lol.avi',
|
12
|
+
'without'=> '5x12.avi',
|
13
|
+
'royal' => 'Royal.Pains.S02E10.Beziehungsbeschwerden.GERMAN.DUBBED.DVDRiP.XviD-SOF.avi',
|
14
|
+
'flpo' => 'Flashpoint.S04E04.Getruebte.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
15
|
+
'csiny' => 'sof-csi.ny.s07e20.avi',
|
16
|
+
'legaltrash' =>'flpo.404.Die.German.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
17
17
|
}
|
18
18
|
|
19
|
-
@@
|
20
|
-
'chuck' => '
|
21
|
-
'chuck1' => '
|
22
|
-
'chuck2' => '
|
23
|
-
'ncis' => '
|
19
|
+
@@directories = {
|
20
|
+
'chuck' => 'Chuck.S01E01.Testepisode.German.Dubbed.BLURAYRiP',
|
21
|
+
'chuck1' => 'Chuck.101.First.Episode.German.Dubbed.BLURAYRiP',
|
22
|
+
'chuck2' => 'chuck.2x12',
|
23
|
+
'ncis' => 'NCIS.S09E05.Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD',
|
24
24
|
}
|
25
25
|
|
26
26
|
@@invalid_directories = {
|
27
|
-
'tbbt' => '
|
27
|
+
'tbbt' => 'BBTV.16/',
|
28
28
|
}
|
29
29
|
|
30
30
|
def setup
|
31
|
-
|
32
|
-
|
33
|
-
@@
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@@valid_directories.each { |n,d|
|
38
|
-
FileUtils.mkdir(d)
|
39
|
-
FileUtils.touch(File.join(d, 'episode.avi'))
|
40
|
-
}
|
31
|
+
TestHelper.create_test_files(@@files.values)
|
32
|
+
TestHelper.create_test_dirs(@@directories.values)
|
33
|
+
TestHelper.create_test_dirs(@@invalid_directories.values)
|
34
|
+
TestHelper.cwd
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
FileUtils.touch(File.join(d, 'episode.avi'))
|
45
|
-
}
|
37
|
+
def teardown
|
38
|
+
TestHelper.clean
|
46
39
|
end
|
47
40
|
|
48
41
|
def test_episode_name_detection
|
49
42
|
|
50
|
-
@@
|
43
|
+
@@files.each { |name,file|
|
51
44
|
assert_equal(true,
|
52
45
|
Serienrenamer::Episode.contains_episode_information?(file))
|
53
46
|
|
54
47
|
assert_equal(false,
|
55
|
-
Serienrenamer::Episode.extract_episode_information(
|
48
|
+
Serienrenamer::Episode.extract_episode_information(file).nil?)
|
56
49
|
}
|
57
50
|
|
58
|
-
@@
|
51
|
+
@@directories.each { |name,dir|
|
59
52
|
assert_equal(true,
|
60
53
|
Serienrenamer::Episode.contains_episode_information?(dir))
|
61
54
|
|
62
55
|
assert_equal(false,
|
63
|
-
Serienrenamer::Episode.extract_episode_information(
|
56
|
+
Serienrenamer::Episode.extract_episode_information(dir).nil?)
|
64
57
|
}
|
65
58
|
|
66
59
|
assert_equal(false,
|
67
60
|
Serienrenamer::Episode.contains_episode_information?('video.flv'))
|
68
61
|
|
69
62
|
assert_equal(true,
|
70
|
-
Serienrenamer::Episode.extract_episode_information(
|
63
|
+
Serienrenamer::Episode.extract_episode_information('video.flv').nil?)
|
71
64
|
end
|
72
65
|
|
73
66
|
def test_information_cleanup
|
74
|
-
assert_equal("Im sicheren Hafen",
|
75
|
-
|
76
|
-
|
77
|
-
|
67
|
+
assert_equal("Im sicheren Hafen",
|
68
|
+
Serienrenamer::Episode.clean_episode_data(
|
69
|
+
".Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD",
|
70
|
+
true, true)
|
71
|
+
)
|
78
72
|
end
|
79
73
|
|
80
74
|
def test_repairing_umlauts
|
81
|
-
assert_equal("Duell",
|
82
|
-
|
83
|
-
assert_equal("
|
84
|
-
|
85
|
-
assert_equal("
|
86
|
-
|
87
|
-
assert_equal("
|
88
|
-
|
89
|
-
assert_equal("
|
90
|
-
|
91
|
-
assert_equal("
|
92
|
-
|
93
|
-
assert_equal("
|
94
|
-
|
95
|
-
assert_equal("
|
96
|
-
|
75
|
+
assert_equal("Duell",
|
76
|
+
Serienrenamer::Episode.repair_umlauts("Duell"))
|
77
|
+
assert_equal("für",
|
78
|
+
Serienrenamer::Episode.repair_umlauts("fuer"))
|
79
|
+
assert_equal("Änderung",
|
80
|
+
Serienrenamer::Episode.repair_umlauts("Aenderung"))
|
81
|
+
assert_equal("Zaubersprüche",
|
82
|
+
Serienrenamer::Episode.repair_umlauts("Zaubersprueche"))
|
83
|
+
assert_equal("Ungeheuerlich",
|
84
|
+
Serienrenamer::Episode.repair_umlauts("Ungeheuerlich"))
|
85
|
+
assert_equal("Frauen",
|
86
|
+
Serienrenamer::Episode.repair_umlauts("Frauen"))
|
87
|
+
assert_equal("Abführmittel",
|
88
|
+
Serienrenamer::Episode.repair_umlauts("Abfuehrmittel"))
|
89
|
+
assert_equal("tödlich",
|
90
|
+
Serienrenamer::Episode.repair_umlauts("toedlich"))
|
91
|
+
assert_equal("König",
|
92
|
+
Serienrenamer::Episode.repair_umlauts("Koenig"))
|
93
|
+
assert_equal("Öko",
|
94
|
+
Serienrenamer::Episode.repair_umlauts("Oeko"))
|
95
|
+
assert_equal("Männer",
|
96
|
+
Serienrenamer::Episode.repair_umlauts("Maenner"))
|
97
|
+
assert_equal("Draufgänger",
|
98
|
+
Serienrenamer::Episode.repair_umlauts("Draufgaenger"))
|
99
|
+
assert_equal("Unglücksvögel",
|
100
|
+
Serienrenamer::Episode.repair_umlauts("Ungluecksvoegel"))
|
101
|
+
assert_equal("Jäger",
|
102
|
+
Serienrenamer::Episode.repair_umlauts("Jaeger"))
|
103
|
+
assert_equal("Loyalität",
|
104
|
+
Serienrenamer::Episode.repair_umlauts("Loyalitaet"))
|
105
|
+
# both forms not existing
|
106
|
+
assert_equal("Moeback",
|
107
|
+
Serienrenamer::Episode.repair_umlauts("Moeback"))
|
97
108
|
end
|
98
109
|
|
99
110
|
def test_episode_information_extraction_from_file
|
100
111
|
|
101
112
|
assert_raise(ArgumentError) { Serienrenamer::Episode.new('video.flv')}
|
102
113
|
|
103
|
-
epi = Serienrenamer::Episode.new(@@
|
114
|
+
epi = Serienrenamer::Episode.new(@@files["chuckfull"])
|
104
115
|
assert_equal('Chuck',epi.series)
|
105
116
|
assert_equal(1, epi.season)
|
106
117
|
assert_equal(1, epi.episode)
|
107
118
|
assert_equal("Dies ist ein Test", epi.episodename)
|
108
119
|
assert_equal("S01E01 - Dies ist ein Test.avi", epi.to_s)
|
109
120
|
|
110
|
-
flpo = Serienrenamer::Episode.new(@@
|
121
|
+
flpo = Serienrenamer::Episode.new(@@files["flpo"])
|
111
122
|
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
112
123
|
|
113
|
-
csiny = Serienrenamer::Episode.new(@@
|
124
|
+
csiny = Serienrenamer::Episode.new(@@files["csiny"])
|
114
125
|
csiny.episodename_needed=false
|
115
126
|
assert_equal("S07E20.avi", csiny.to_s)
|
116
127
|
|
117
|
-
legaltrash = Serienrenamer::Episode.new(@@
|
128
|
+
legaltrash = Serienrenamer::Episode.new(@@files["legaltrash"])
|
118
129
|
assert_equal("S04E04 - Die German Erinnerungen.avi", legaltrash.to_s)
|
119
130
|
|
120
|
-
royal = Serienrenamer::Episode.new(@@
|
131
|
+
royal = Serienrenamer::Episode.new(@@files["royal"])
|
121
132
|
assert_equal("S02E10 - Beziehungsbeschwerden.avi", royal.to_s)
|
122
133
|
end
|
123
134
|
|
124
135
|
def test_episode_information_extraction_from_directory
|
125
136
|
|
126
|
-
chuck = Serienrenamer::Episode.new(@@
|
137
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
127
138
|
assert_equal("S01E01 - Testepisode.avi", chuck.to_s)
|
128
139
|
|
129
|
-
chuck1 = Serienrenamer::Episode.new(@@
|
140
|
+
chuck1 = Serienrenamer::Episode.new(@@directories["chuck1"])
|
130
141
|
assert_equal("S01E01 - First Episode.avi", chuck1.to_s)
|
131
142
|
|
132
|
-
ncis = Serienrenamer::Episode.new(@@
|
143
|
+
ncis = Serienrenamer::Episode.new(@@directories["ncis"])
|
133
144
|
assert_equal("S09E05 - Im sicheren Hafen.avi", ncis.to_s)
|
134
145
|
|
135
|
-
chuck2 = Serienrenamer::Episode.new(@@
|
146
|
+
chuck2 = Serienrenamer::Episode.new(@@directories["chuck2"])
|
136
147
|
chuck2.episodename_needed=false
|
137
148
|
assert_equal("S02E12.avi", chuck2.to_s)
|
138
149
|
end
|
139
150
|
|
140
151
|
def test_adding_episodename_afterwards
|
141
152
|
|
142
|
-
csiny = Serienrenamer::Episode.new(@@
|
153
|
+
csiny = Serienrenamer::Episode.new(@@files["csiny"])
|
143
154
|
csiny.add_episode_information('Dies ist nachträglich eingefügt', false)
|
144
155
|
assert_equal("S07E20 - Dies ist nachträglich eingefügt.avi", csiny.to_s)
|
145
156
|
|
146
|
-
chuck = Serienrenamer::Episode.new(@@
|
147
|
-
chuck.add_episode_information(
|
157
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
158
|
+
chuck.add_episode_information(
|
159
|
+
'Chuck.S01E01.First.Episode.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD',
|
160
|
+
true)
|
148
161
|
assert_equal("S01E01 - First Episode.avi", chuck.to_s)
|
149
162
|
end
|
150
163
|
|
151
164
|
def test_videofile_determination
|
152
|
-
@@
|
165
|
+
@@files.each { |n,f|
|
153
166
|
assert_not_nil(Serienrenamer::Episode.determine_video_file(f))
|
154
167
|
}
|
155
168
|
|
156
|
-
@@
|
169
|
+
@@directories.each { |n,d|
|
157
170
|
assert_not_nil(Serienrenamer::Episode.determine_video_file(d))
|
158
171
|
}
|
159
172
|
end
|
160
173
|
|
161
174
|
def test_episode_rename_file
|
162
|
-
epi = Serienrenamer::Episode.new(@@
|
163
|
-
epi.rename
|
175
|
+
epi = Serienrenamer::Episode.new(@@files["chuckfull"])
|
176
|
+
epi.rename
|
164
177
|
assert_equal(true, epi.success)
|
165
178
|
end
|
166
179
|
|
167
180
|
def test_episode_rename_from_directory
|
168
|
-
@@
|
181
|
+
@@directories.each do |n,d|
|
169
182
|
epi = Serienrenamer::Episode.new(d)
|
170
|
-
epi.rename
|
183
|
+
epi.rename
|
171
184
|
assert_equal(true, epi.success)
|
172
185
|
end
|
173
186
|
end
|
@@ -176,13 +189,26 @@ class TestEpisode < Test::Unit::TestCase
|
|
176
189
|
d = @@invalid_directories["tbbt"]
|
177
190
|
|
178
191
|
filenametxt = File.new(File.join(d, "filename.txt"), "w")
|
179
|
-
filenametxt.write(
|
192
|
+
filenametxt.write(
|
193
|
+
"The.Big.Bang.Theory.S05E16.Sheldon.Revival.HDTV.XviD-LOL")
|
180
194
|
filenametxt.close
|
181
195
|
|
182
196
|
tbbt = Serienrenamer::Episode.new(d)
|
183
197
|
assert_equal("S05E16 - Sheldon Revival.avi", tbbt.to_s)
|
184
198
|
|
185
|
-
tbbt.rename
|
199
|
+
tbbt.rename
|
186
200
|
assert_equal(true, tbbt.success)
|
187
201
|
end
|
202
|
+
|
203
|
+
def test_generate_episode_hash
|
204
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
205
|
+
|
206
|
+
videofile = File.new(chuck.episodepath, "w")
|
207
|
+
videofile.write("Chuck.S01E01.Testepisode.German.Dubbed.BLURAYRiP")
|
208
|
+
videofile.close
|
209
|
+
|
210
|
+
assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
|
211
|
+
chuck.rename
|
212
|
+
assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
|
213
|
+
end
|
188
214
|
end
|
data/test/test_hash.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
# test class for the merge_with_serialized option of the Hash class
|
6
|
+
# which is added to the class of the standard library
|
7
|
+
class TestHash < Test::Unit::TestCase
|
8
|
+
|
9
|
+
@@TEST_DATA = {
|
10
|
+
:first => "first parameter",
|
11
|
+
:second => "second parameter",
|
12
|
+
:third => "third parameter"
|
13
|
+
}
|
14
|
+
|
15
|
+
@@TEST_CONFIG_FILE =
|
16
|
+
File.join(TestHelper::TESTFILE_DIRECTORY, "config.yml")
|
17
|
+
@@TEST_EMPTY_CONFIG_FILE =
|
18
|
+
File.join(TestHelper::TESTFILE_DIRECTORY, "empty.yml")
|
19
|
+
@@TEST_INVALID_CONFIG_FILE =
|
20
|
+
File.join(TestHelper::TESTFILE_DIRECTORY, "invalid.yml")
|
21
|
+
@@TEST_NOT_EXISTING =
|
22
|
+
File.join(TestHelper::TESTFILE_DIRECTORY, "not_exisiting.yml")
|
23
|
+
|
24
|
+
def setup
|
25
|
+
TestHelper.create_test_files([])
|
26
|
+
@modified = @@TEST_DATA.merge({:third => "modified third parameter"})
|
27
|
+
|
28
|
+
File.open(@@TEST_CONFIG_FILE, 'w') {|f| f.write(@modified.to_yaml) }
|
29
|
+
File.open(@@TEST_EMPTY_CONFIG_FILE, 'w') {|f| f.write(Hash.new.to_yaml) }
|
30
|
+
File.open(@@TEST_EMPTY_CONFIG_FILE, 'w') {|f| f.write("invalid") }
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def teardown
|
35
|
+
TestHelper.clean
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_merge_valid_yaml_file
|
39
|
+
merged = @@TEST_DATA.merge_with_serialized(@@TEST_CONFIG_FILE)
|
40
|
+
assert_equal("modified third parameter", merged[:third])
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_merge_invalid_empty_and_not_exisiting_yaml_file
|
44
|
+
merged = @@TEST_DATA.merge_with_serialized(@@TEST_EMPTY_CONFIG_FILE)
|
45
|
+
assert_equal("third parameter", merged[:third])
|
46
|
+
|
47
|
+
merged = @@TEST_DATA.merge_with_serialized(@@TEST_INVALID_CONFIG_FILE)
|
48
|
+
assert_equal("third parameter", merged[:third])
|
49
|
+
|
50
|
+
merged = @@TEST_DATA.merge_with_serialized(@@TEST_NOT_EXISTING)
|
51
|
+
assert_equal("third parameter", merged[:third])
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,3 +2,60 @@ require 'stringio'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require File.dirname(__FILE__) + '/../lib/serienrenamer'
|
4
4
|
require File.dirname(__FILE__) + '/../lib/plugin'
|
5
|
+
|
6
|
+
class TestHelper
|
7
|
+
|
8
|
+
TESTFILE_DIRECTORY = File.join(File.dirname(__FILE__), 'testfiles')
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# create the supplied Files in the testfiles directory
|
13
|
+
def create_test_files(files)
|
14
|
+
_create_testfile_directory
|
15
|
+
|
16
|
+
files.each do |f|
|
17
|
+
FileUtils.touch File.join(TESTFILE_DIRECTORY, f)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# create supplied directories with an sample video file
|
22
|
+
def create_test_dirs(directories)
|
23
|
+
_create_testfile_directory
|
24
|
+
|
25
|
+
directories.each do |d|
|
26
|
+
dir = File.join(TESTFILE_DIRECTORY, d)
|
27
|
+
|
28
|
+
FileUtils.mkdir(dir) unless File.directory?(dir)
|
29
|
+
FileUtils.touch(File.join(dir, 'episode.avi'))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# write file with episode Text
|
34
|
+
def write_episode_textfile(dir, title, filename="filename.txt")
|
35
|
+
dirpath = File.join(TESTFILE_DIRECTORY, dir)
|
36
|
+
|
37
|
+
create_test_dirs([ dir ]) unless File.directory?(dirpath)
|
38
|
+
|
39
|
+
filenametxt = File.new(File.join(dirpath, "filename.txt"), "w")
|
40
|
+
filenametxt.write(title)
|
41
|
+
filenametxt.close
|
42
|
+
end
|
43
|
+
|
44
|
+
# change the working directory to TESTFILE_DIRECTORY
|
45
|
+
def cwd
|
46
|
+
Dir.chdir(TESTFILE_DIRECTORY)
|
47
|
+
end
|
48
|
+
|
49
|
+
# remove testfile directory
|
50
|
+
def clean
|
51
|
+
if File.directory?(TESTFILE_DIRECTORY)
|
52
|
+
system("rm -rf #{TESTFILE_DIRECTORY}")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def _create_testfile_directory
|
57
|
+
FileUtils.mkdir(TESTFILE_DIRECTORY) unless
|
58
|
+
File.directory?(TESTFILE_DIRECTORY)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestInformationStore < Test::Unit::TestCase
|
6
|
+
|
7
|
+
@@files = {
|
8
|
+
'chuckfull' => 'Chuck.S01E01.Dies.ist.ein.Test.German.Dubbed.BLURAYRiP.DELiCiOUS.WEBRiP.CiD.avi',
|
9
|
+
'royal' => 'Royal.Pains.S02E10.Beziehungsbeschwerden.GERMAN.DUBBED.DVDRiP.XviD-SOF.avi',
|
10
|
+
'flpo' => 'Flashpoint.S04E04.Getruebte.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
11
|
+
'legaltrash' =>'flpo.404.Die.German.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
12
|
+
}
|
13
|
+
|
14
|
+
def setup
|
15
|
+
TestHelper.create_test_files(@@files.values)
|
16
|
+
TestHelper.cwd
|
17
|
+
|
18
|
+
@episodes = Hash.new
|
19
|
+
storage = Serienrenamer::InformationStore.new("storage.yml")
|
20
|
+
|
21
|
+
@@files.each do |key, value|
|
22
|
+
filenametxt = File.new(value, "w")
|
23
|
+
filenametxt.write(value)
|
24
|
+
filenametxt.close
|
25
|
+
|
26
|
+
episode = Serienrenamer::Episode.new(value)
|
27
|
+
episode.rename
|
28
|
+
@episodes[key] = episode
|
29
|
+
storage.store(episode)
|
30
|
+
end
|
31
|
+
storage.write
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def teardown
|
36
|
+
TestHelper.clean
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_information_storage
|
40
|
+
|
41
|
+
storage = Serienrenamer::InformationStore.new("storage.yml")
|
42
|
+
|
43
|
+
@episodes.each do |key, episode|
|
44
|
+
assert_equal(storage.episode_hash[episode.md5sum], episode.series)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -2,30 +2,27 @@
|
|
2
2
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
3
|
|
4
4
|
class TestPluginSerienjunkiesDe < Test::Unit::TestCase
|
5
|
-
@@
|
6
|
-
'flpo' => '
|
7
|
-
'dani' => '
|
8
|
-
'two' => '
|
9
|
-
'simp' => '
|
10
|
-
'sea' => '
|
5
|
+
@@files = {
|
6
|
+
'flpo' => 'Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
7
|
+
'dani' => 'Dr.Dani.Santino.S01E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'two' => 'Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
9
|
+
'simp' => 'Die.Simpsons.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
10
|
+
'sea' => 'tcpa-seapatrol_s05e11.avi',
|
11
11
|
}
|
12
12
|
|
13
|
-
@@
|
14
|
-
'chuck' => '
|
15
|
-
'chuck2' => '
|
13
|
+
@@directories = {
|
14
|
+
'chuck' => 'Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
15
|
+
'chuck2' => 'Chuck.S02E10.German.Dubbed.BLURAYRiP.WEB-DL',
|
16
16
|
}
|
17
17
|
|
18
18
|
def setup
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
19
|
+
TestHelper.create_test_files(@@files.values)
|
20
|
+
TestHelper.create_test_dirs(@@directories.values)
|
21
|
+
TestHelper.cwd
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
FileUtils.touch(File.join(d, 'episode.avi'))
|
28
|
-
}
|
24
|
+
def teardown
|
25
|
+
TestHelper.clean
|
29
26
|
end
|
30
27
|
|
31
28
|
def test_seriespage_url_search
|
@@ -50,15 +47,18 @@ class TestPluginSerienjunkiesDe < Test::Unit::TestCase
|
|
50
47
|
|
51
48
|
plugin = Plugin::SerienjunkiesDe
|
52
49
|
|
53
|
-
seasons = plugin.parse_seriespage(
|
50
|
+
seasons = plugin.parse_seriespage(
|
51
|
+
"http://www.serienjunkies.de/royal-pains/")
|
54
52
|
assert_match(/Auch.Reiche.sind.nur.Menschen/, seasons['S01E01'])
|
55
53
|
assert_match(/Krank.vor.Liebe/, seasons['S02E02'])
|
56
54
|
|
57
|
-
seasons = plugin.parse_seriespage(
|
55
|
+
seasons = plugin.parse_seriespage(
|
56
|
+
"http://www.serienjunkies.de/flashpoint/")
|
58
57
|
assert_match(/Zu.viele.Verlierer/, seasons['S02E02'])
|
59
58
|
assert_match(/Der.Aufstand/, seasons['S02E16'])
|
60
59
|
|
61
|
-
seasons = plugin.parse_seriespage(
|
60
|
+
seasons = plugin.parse_seriespage(
|
61
|
+
"http://www.serienjunkies.de/necessary-roughness/")
|
62
62
|
assert_match(/Touchdown/, seasons['S01E01'])
|
63
63
|
assert_match(/Extremsport/, seasons['S01E06'])
|
64
64
|
|
@@ -71,22 +71,22 @@ class TestPluginSerienjunkiesDe < Test::Unit::TestCase
|
|
71
71
|
|
72
72
|
plugin = Plugin::SerienjunkiesDe
|
73
73
|
|
74
|
-
flpo = Serienrenamer::Episode.new(@@
|
74
|
+
flpo = Serienrenamer::Episode.new(@@files['flpo'])
|
75
75
|
data = plugin.generate_episode_information(flpo)[0]
|
76
76
|
flpo.add_episode_information(data, true) if data
|
77
77
|
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
78
78
|
|
79
|
-
two = Serienrenamer::Episode.new(@@
|
79
|
+
two = Serienrenamer::Episode.new(@@files['two'])
|
80
80
|
data = plugin.generate_episode_information(two)[0]
|
81
81
|
two.add_episode_information(data, true) if data
|
82
82
|
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
83
83
|
|
84
|
-
chuck = Serienrenamer::Episode.new(@@
|
84
|
+
chuck = Serienrenamer::Episode.new(@@directories['chuck'])
|
85
85
|
data = plugin.generate_episode_information(chuck)[0]
|
86
86
|
chuck.add_episode_information(data, true) if data
|
87
87
|
assert_equal("S01E01 - Pilot.avi", chuck.to_s)
|
88
88
|
|
89
|
-
chuck2 = Serienrenamer::Episode.new(@@
|
89
|
+
chuck2 = Serienrenamer::Episode.new(@@directories['chuck2'])
|
90
90
|
data = plugin.generate_episode_information(chuck2)[0]
|
91
91
|
chuck2.add_episode_information(data, true) if data
|
92
92
|
assert_equal("S02E10 - Chuck gegen zehn Millionen.avi", chuck2.to_s)
|
@@ -2,85 +2,85 @@
|
|
2
2
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
3
|
|
4
4
|
class TestPluginSerienjunkiesFeed < Test::Unit::TestCase
|
5
|
-
@@
|
6
|
-
'chuck'
|
7
|
-
'flpo' => '
|
8
|
-
'csiny' => '
|
9
|
-
'simps' => '
|
10
|
-
'biglove'=> '
|
11
|
-
'crmi' => '
|
12
|
-
'two' => '
|
13
|
-
'sea' => '
|
14
|
-
'shlock' => '
|
15
|
-
'unit' => '
|
5
|
+
@@files = {
|
6
|
+
'chuck' => 'chuck.312.hdtv-lol.avi',
|
7
|
+
'flpo' => 'Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'csiny' => 'sof-csi.ny.s07e21.avi',
|
9
|
+
'simps' => 'simpsons.s22e16.avi',
|
10
|
+
'biglove'=> 'idtv-big.love.s05e06.avi',
|
11
|
+
'crmi' => 'crmi-s06e22.avi',
|
12
|
+
'two' => 'Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
13
|
+
'sea' => 'tcpa-seapatrol_s05e11.avi',
|
14
|
+
'shlock' => 'Sherlock.s02e01.avi',
|
15
|
+
'unit' => 'The.Unit.s01e17.avi',
|
16
16
|
}
|
17
17
|
|
18
|
-
@@
|
19
|
-
'chuck' => '
|
18
|
+
@@directories = {
|
19
|
+
'chuck' => 'Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
20
20
|
}
|
21
21
|
|
22
22
|
def setup
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
unless defined? @feed
|
24
|
+
@feed = Plugin::SerienjunkiesOrgFeed
|
25
|
+
@feed.feed_url = File.join( File.dirname(__FILE__),
|
26
|
+
'serienjunkies_feed_sample.xml')
|
27
|
+
end
|
28
|
+
|
29
|
+
TestHelper.create_test_files(@@files.values)
|
30
|
+
TestHelper.create_test_dirs(@@directories.values)
|
31
|
+
TestHelper.cwd
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
FileUtils.touch(File.join(d, 'episode.avi'))
|
32
|
-
}
|
34
|
+
def teardown
|
35
|
+
TestHelper.clean
|
33
36
|
end
|
34
37
|
|
35
38
|
# improve this so that the Plugin uses a local xml file
|
36
39
|
def test_information_extraction
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
simps = Serienrenamer::Episode.new(@@valid_filenames['simps'])
|
42
|
-
data = feed.generate_episode_information(simps)[0]
|
41
|
+
simps = Serienrenamer::Episode.new(@@files['simps'])
|
42
|
+
data = @feed.generate_episode_information(simps)[0]
|
43
43
|
simps.add_episode_information(data, true)
|
44
44
|
assert_equal("S22E16 - Ein Sommernachtstrip.avi", simps.to_s)
|
45
45
|
|
46
|
-
flpo = Serienrenamer::Episode.new(@@
|
47
|
-
data = feed.generate_episode_information(flpo)[0]
|
46
|
+
flpo = Serienrenamer::Episode.new(@@files['flpo'])
|
47
|
+
data = @feed.generate_episode_information(flpo)[0]
|
48
48
|
flpo.add_episode_information(data, true)
|
49
49
|
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
50
50
|
|
51
|
-
big = Serienrenamer::Episode.new(@@
|
52
|
-
data = feed.generate_episode_information(big)[0]
|
51
|
+
big = Serienrenamer::Episode.new(@@files['biglove'])
|
52
|
+
data = @feed.generate_episode_information(big)[0]
|
53
53
|
big.add_episode_information(data, true)
|
54
54
|
assert_equal("S05E06 - Scheidung.avi", big.to_s)
|
55
55
|
|
56
|
-
crmi = Serienrenamer::Episode.new(@@
|
57
|
-
data = feed.generate_episode_information(crmi)[0]
|
56
|
+
crmi = Serienrenamer::Episode.new(@@files['crmi'])
|
57
|
+
data = @feed.generate_episode_information(crmi)[0]
|
58
58
|
crmi.add_episode_information(data, true)
|
59
59
|
assert_equal("S06E22 - Die Dunkelkammer Mörder.avi", crmi.to_s)
|
60
60
|
|
61
|
-
two = Serienrenamer::Episode.new(@@
|
62
|
-
data = feed.generate_episode_information(two)[0]
|
61
|
+
two = Serienrenamer::Episode.new(@@files['two'])
|
62
|
+
data = @feed.generate_episode_information(two)[0]
|
63
63
|
two.add_episode_information(data, true)
|
64
64
|
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
65
65
|
|
66
|
-
sea = Serienrenamer::Episode.new(@@
|
67
|
-
data = feed.generate_episode_information(sea)[0]
|
66
|
+
sea = Serienrenamer::Episode.new(@@files['sea'])
|
67
|
+
data = @feed.generate_episode_information(sea)[0]
|
68
68
|
sea.add_episode_information(data, true)
|
69
69
|
assert_equal("S05E11 - Der Morgen danach.avi", sea.to_s)
|
70
70
|
|
71
|
-
csiny = Serienrenamer::Episode.new(@@
|
72
|
-
data = feed.generate_episode_information(csiny)[0]
|
71
|
+
csiny = Serienrenamer::Episode.new(@@files['csiny'])
|
72
|
+
data = @feed.generate_episode_information(csiny)[0]
|
73
73
|
csiny.add_episode_information(data, true)
|
74
74
|
assert_equal("S07E21 - Kugelhagel.avi", csiny.to_s)
|
75
75
|
|
76
76
|
# the following episodes are not exisiting in the feed
|
77
77
|
# so it should returns nil
|
78
|
-
sherlock = Serienrenamer::Episode.new(@@
|
79
|
-
data = feed.generate_episode_information(sherlock)[0]
|
78
|
+
sherlock = Serienrenamer::Episode.new(@@files['shlock'])
|
79
|
+
data = @feed.generate_episode_information(sherlock)[0]
|
80
80
|
assert_nil(data)
|
81
81
|
|
82
|
-
theunit = Serienrenamer::Episode.new(@@
|
83
|
-
data = feed.generate_episode_information(theunit)[0]
|
82
|
+
theunit = Serienrenamer::Episode.new(@@files['unit'])
|
83
|
+
data = @feed.generate_episode_information(theunit)[0]
|
84
84
|
assert_nil(data)
|
85
85
|
end
|
86
86
|
end
|
@@ -7,31 +7,31 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
7
7
|
# information
|
8
8
|
#
|
9
9
|
class TestPluginTextfile < Test::Unit::TestCase
|
10
|
-
@@
|
11
|
-
'hmym' => '
|
10
|
+
@@directories = {
|
11
|
+
'hmym' => 'HMMG.705',
|
12
12
|
}
|
13
13
|
|
14
14
|
def setup
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
TestHelper.write_episode_textfile(
|
16
|
+
@@directories["hmym"],
|
17
|
+
"How.I.Met.Your.Mother.S07E05.Die.Exkursion.German.Dubbed.HDTV.XviD-ITG"
|
18
|
+
)
|
19
|
+
TestHelper.cwd
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
filenametxt.close
|
22
|
+
def teardown
|
23
|
+
TestHelper.clean
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_information_extraction
|
27
|
-
how = Serienrenamer::Episode.new(@@
|
27
|
+
how = Serienrenamer::Episode.new(@@directories['hmym'])
|
28
28
|
data = Plugin::Textfile.generate_episode_information(how)[0]
|
29
29
|
how.add_episode_information(data, true)
|
30
30
|
assert_equal("S07E05 - Die Exkursion.avi", how.to_s)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_information_extraction_with_directory_parameter
|
34
|
-
how = @@
|
34
|
+
how = @@directories['hmym']
|
35
35
|
data = Plugin::Textfile.generate_episode_information(how)[0]
|
36
36
|
assert_not_nil(data)
|
37
37
|
end
|
@@ -3,30 +3,27 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
require 'media_wiki'
|
4
4
|
|
5
5
|
class TestPluginWikipedia < Test::Unit::TestCase
|
6
|
-
@@
|
7
|
-
'flpo'
|
8
|
-
'dani'
|
9
|
-
'two'
|
10
|
-
'simp'
|
11
|
-
'sea'
|
6
|
+
@@files = {
|
7
|
+
'flpo' => 'Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'dani' => 'Dr.Dani.Santino.S01E04.German.Dubbed.WEB-DL.XViD.avi',
|
9
|
+
'two' => 'Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
10
|
+
'simp' => 'Die.Simpsons.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
11
|
+
'sea' => 'tcpa-seapatrol_s05e11.avi',
|
12
12
|
}
|
13
13
|
|
14
|
-
@@
|
15
|
-
'chuck' => '
|
16
|
-
'chuck2' => '
|
14
|
+
@@directories = {
|
15
|
+
'chuck' => 'Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
16
|
+
'chuck2' => 'Chuck.S02E10.German.Dubbed.BLURAYRiP.WEB-DL',
|
17
17
|
}
|
18
18
|
|
19
19
|
def setup
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
20
|
+
TestHelper.create_test_files(@@files.values)
|
21
|
+
TestHelper.create_test_dirs(@@directories.values)
|
22
|
+
TestHelper.cwd
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
FileUtils.touch(File.join(d, 'episode.avi'))
|
29
|
-
}
|
25
|
+
def teardown
|
26
|
+
TestHelper.clean
|
30
27
|
end
|
31
28
|
|
32
29
|
def test_episode_list_page_data_extraction
|
@@ -120,37 +117,37 @@ class TestPluginWikipedia < Test::Unit::TestCase
|
|
120
117
|
|
121
118
|
def test_episode_information_generation
|
122
119
|
|
123
|
-
flpo = Serienrenamer::Episode.new(@@
|
120
|
+
flpo = Serienrenamer::Episode.new(@@files['flpo'])
|
124
121
|
data = Plugin::Wikipedia.generate_episode_information(flpo)[0]
|
125
122
|
flpo.add_episode_information(data, false) if data
|
126
123
|
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
127
124
|
|
128
|
-
two = Serienrenamer::Episode.new(@@
|
125
|
+
two = Serienrenamer::Episode.new(@@files['two'])
|
129
126
|
data = Plugin::Wikipedia.generate_episode_information(two)[0]
|
130
127
|
two.add_episode_information(data, false) if data
|
131
128
|
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
132
129
|
|
133
|
-
simp = Serienrenamer::Episode.new(@@
|
130
|
+
simp = Serienrenamer::Episode.new(@@files['simp'])
|
134
131
|
data = Plugin::Wikipedia.generate_episode_information(simp)[0]
|
135
132
|
simp.add_episode_information(data, false) if data
|
136
133
|
assert_equal("S09E07 - Hochzeit auf Indisch.avi", simp.to_s)
|
137
134
|
|
138
|
-
chuck = Serienrenamer::Episode.new(@@
|
135
|
+
chuck = Serienrenamer::Episode.new(@@directories['chuck'])
|
139
136
|
data = Plugin::Wikipedia.generate_episode_information(chuck)[0]
|
140
137
|
chuck.add_episode_information(data, false) if data
|
141
138
|
assert_equal("S01E01 - Pilot.avi", chuck.to_s)
|
142
139
|
|
143
|
-
chuck2 = Serienrenamer::Episode.new(@@
|
140
|
+
chuck2 = Serienrenamer::Episode.new(@@directories['chuck2'])
|
144
141
|
data = Plugin::Wikipedia.generate_episode_information(chuck2)[0]
|
145
142
|
chuck2.add_episode_information(data, false) if data
|
146
143
|
assert_equal("S02E10 - Chuck gegen zehn Millionen.avi", chuck2.to_s)
|
147
144
|
|
148
|
-
dani = Serienrenamer::Episode.new(@@
|
145
|
+
dani = Serienrenamer::Episode.new(@@files['dani'])
|
149
146
|
data = Plugin::Wikipedia.generate_episode_information(dani)[0]
|
150
147
|
dani.add_episode_information(data, false) if data
|
151
148
|
assert_equal("S01E04 - Gewohnheiten.avi", dani.to_s)
|
152
149
|
|
153
|
-
sea = Serienrenamer::Episode.new(@@
|
150
|
+
sea = Serienrenamer::Episode.new(@@files['sea'])
|
154
151
|
data = Plugin::Wikipedia.generate_episode_information(sea)[0]
|
155
152
|
sea.add_episode_information(data, false) if data
|
156
153
|
assert_equal("S05E11 - Der Morgen danach.avi", sea.to_s)
|
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.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: wlapi
|
16
|
-
requirement: &
|
16
|
+
requirement: &26451300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *26451300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mediawiki-gateway
|
27
|
-
requirement: &
|
27
|
+
requirement: &26450420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *26450420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mechanize
|
38
|
-
requirement: &
|
38
|
+
requirement: &26484760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *26484760
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: highline
|
49
|
-
requirement: &
|
49
|
+
requirement: &26483520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.11
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *26483520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &26482500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.10'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *26482500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: newgem
|
71
|
-
requirement: &
|
71
|
+
requirement: &26481160 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.5.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *26481160
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: hoe
|
82
|
-
requirement: &
|
82
|
+
requirement: &26479520 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '2.15'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *26479520
|
91
91
|
description: ! 'Ruby Script that brings your series into an appropriate format
|
92
92
|
|
93
93
|
like "S01E01 - Episodename.avi"'
|
@@ -113,13 +113,16 @@ files:
|
|
113
113
|
- lib/plugin/wikipedia.rb
|
114
114
|
- lib/serienrenamer.rb
|
115
115
|
- lib/serienrenamer/episode.rb
|
116
|
+
- lib/serienrenamer/information_store.rb
|
116
117
|
- script/console
|
117
118
|
- script/destroy
|
118
119
|
- script/generate
|
119
120
|
- serienrenamer.gemspec
|
120
121
|
- test/serienjunkies_feed_sample.xml
|
121
122
|
- test/test_episode.rb
|
123
|
+
- test/test_hash.rb
|
122
124
|
- test/test_helper.rb
|
125
|
+
- test/test_information_store.rb
|
123
126
|
- test/test_plugin_serienjunkies_de.rb
|
124
127
|
- test/test_plugin_serienjunkies_feed.rb
|
125
128
|
- test/test_plugin_textfile.rb
|
@@ -154,8 +157,10 @@ summary: Ruby Script that brings your series into an appropriate format like "S0
|
|
154
157
|
- Episodename.avi"
|
155
158
|
test_files:
|
156
159
|
- test/test_plugin_serienjunkies_de.rb
|
160
|
+
- test/test_information_store.rb
|
157
161
|
- test/test_plugin_wikipedia.rb
|
158
162
|
- test/test_plugin_serienjunkies_feed.rb
|
159
163
|
- test/test_plugin_textfile.rb
|
160
164
|
- test/test_helper.rb
|
161
165
|
- test/test_episode.rb
|
166
|
+
- test/test_hash.rb
|