serienrenamer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +23 -0
- data/README.rdoc +52 -0
- data/Rakefile +27 -0
- data/bin/serienrenamer +155 -0
- data/lib/plugin/serienjunkies_de.rb +129 -0
- data/lib/plugin/serienjunkies_feed.rb +105 -0
- data/lib/plugin/textfile.rb +50 -0
- data/lib/plugin/wikipedia.rb +362 -0
- data/lib/plugin.rb +8 -0
- data/lib/serienrenamer/episode.rb +313 -0
- data/lib/serienrenamer.rb +28 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/serienrenamer.gemspec +52 -0
- data/test/serienjunkies_feed_sample.xml +14472 -0
- data/test/test_episode.rb +188 -0
- data/test/test_helper.rb +4 -0
- data/test/test_plugin_serienjunkies_de.rb +95 -0
- data/test/test_plugin_serienjunkies_feed.rb +75 -0
- data/test/test_plugin_textfile.rb +38 -0
- data/test/test_plugin_wikipedia.rb +178 -0
- metadata +161 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestEpisode < Test::Unit::TestCase
|
6
|
+
|
7
|
+
@@valid_filenames = {
|
8
|
+
'chuckfull' => 'test/testfiles/Chuck.S01E01.Dies.ist.ein.Test.German.Dubbed.BLURAYRiP.DELiCiOUS.WEBRiP.CiD.avi',
|
9
|
+
'chuck1' => 'test/testfiles/chuck.512.hdtv-lol.avi',
|
10
|
+
'chuck2' => 'test/testfiles/chuck.1212.hdtv-lol.avi',
|
11
|
+
'chuck3' => 'test/testfiles/chuck.5x12.hdtv-lol.avi',
|
12
|
+
'without'=> 'test/testfiles/5x12.avi',
|
13
|
+
'royal' => 'test/testfiles/Royal.Pains.S02E10.Beziehungsbeschwerden.GERMAN.DUBBED.DVDRiP.XviD-SOF.avi',
|
14
|
+
'flpo' => 'test/testfiles/Flashpoint.S04E04.Getruebte.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
15
|
+
'csiny' => 'test/testfiles/sof-csi.ny.s07e20.avi',
|
16
|
+
'legaltrash' =>'test/testfiles/flpo.404.Die.German.Erinnerungen.German.Dubbed.WEB-DL.XViD.avi',
|
17
|
+
}
|
18
|
+
|
19
|
+
@@valid_directories = {
|
20
|
+
'chuck' => 'test/testfiles/Chuck.S01E01.Testepisode.German.Dubbed.BLURAYRiP',
|
21
|
+
'chuck1' => 'test/testfiles/Chuck.101.First.Episode.German.Dubbed.BLURAYRiP',
|
22
|
+
'chuck2' => 'test/testfiles/chuck.2x12',
|
23
|
+
'ncis' => 'test/testfiles/NCIS.S09E05.Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD',
|
24
|
+
}
|
25
|
+
|
26
|
+
@@invalid_directories = {
|
27
|
+
'tbbt' => 'test/testfiles/BBTV.16/',
|
28
|
+
}
|
29
|
+
|
30
|
+
def setup
|
31
|
+
system('rm -r test/testfiles/*')
|
32
|
+
|
33
|
+
@@valid_filenames.each { |n,f|
|
34
|
+
FileUtils.touch f unless File.file?(f)
|
35
|
+
}
|
36
|
+
|
37
|
+
@@valid_directories.each { |n,d|
|
38
|
+
FileUtils.mkdir(d)
|
39
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
40
|
+
}
|
41
|
+
|
42
|
+
@@invalid_directories.each { |n,d|
|
43
|
+
FileUtils.mkdir(d)
|
44
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_episode_name_detection
|
49
|
+
|
50
|
+
@@valid_filenames.each { |name,file|
|
51
|
+
assert_equal(true,
|
52
|
+
Serienrenamer::Episode.contains_episode_information?(file))
|
53
|
+
|
54
|
+
assert_equal(false,
|
55
|
+
Serienrenamer::Episode.extract_episode_information(File.basename(file)).nil?)
|
56
|
+
}
|
57
|
+
|
58
|
+
@@valid_directories.each { |name,dir|
|
59
|
+
assert_equal(true,
|
60
|
+
Serienrenamer::Episode.contains_episode_information?(dir))
|
61
|
+
|
62
|
+
assert_equal(false,
|
63
|
+
Serienrenamer::Episode.extract_episode_information(File.basename(dir)).nil?)
|
64
|
+
}
|
65
|
+
|
66
|
+
assert_equal(false,
|
67
|
+
Serienrenamer::Episode.contains_episode_information?('video.flv'))
|
68
|
+
|
69
|
+
assert_equal(true,
|
70
|
+
Serienrenamer::Episode.extract_episode_information(File.basename('video.flv')).nil?)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_information_cleanup
|
74
|
+
assert_equal("Im sicheren Hafen", Serienrenamer::Episode.clean_episode_data(
|
75
|
+
".Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD", true, true
|
76
|
+
))
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_repairing_umlauts
|
81
|
+
assert_equal("Duell", Serienrenamer::Episode.repair_umlauts("Duell"))
|
82
|
+
assert_equal("für", Serienrenamer::Episode.repair_umlauts("fuer"))
|
83
|
+
assert_equal("Änderung", Serienrenamer::Episode.repair_umlauts("Aenderung"))
|
84
|
+
assert_equal("Zaubersprüche", Serienrenamer::Episode.repair_umlauts("Zaubersprueche"))
|
85
|
+
assert_equal("Ungeheuerlich", Serienrenamer::Episode.repair_umlauts("Ungeheuerlich"))
|
86
|
+
assert_equal("Frauen", Serienrenamer::Episode.repair_umlauts("Frauen"))
|
87
|
+
assert_equal("Abführmittel", Serienrenamer::Episode.repair_umlauts("Abfuehrmittel"))
|
88
|
+
assert_equal("tödlich", Serienrenamer::Episode.repair_umlauts("toedlich"))
|
89
|
+
assert_equal("König", Serienrenamer::Episode.repair_umlauts("Koenig"))
|
90
|
+
assert_equal("Öko", Serienrenamer::Episode.repair_umlauts("Oeko"))
|
91
|
+
assert_equal("Moeback", Serienrenamer::Episode.repair_umlauts("Moeback")) # both forms not existing
|
92
|
+
assert_equal("Männer", Serienrenamer::Episode.repair_umlauts("Maenner"))
|
93
|
+
assert_equal("Draufgänger", Serienrenamer::Episode.repair_umlauts("Draufgaenger"))
|
94
|
+
assert_equal("Unglücksvögel", Serienrenamer::Episode.repair_umlauts("Ungluecksvoegel"))
|
95
|
+
assert_equal("Jäger", Serienrenamer::Episode.repair_umlauts("Jaeger"))
|
96
|
+
assert_equal("Loyalität", Serienrenamer::Episode.repair_umlauts("Loyalitaet"))
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_episode_information_extraction_from_file
|
100
|
+
|
101
|
+
assert_raise(ArgumentError) { Serienrenamer::Episode.new('video.flv')}
|
102
|
+
|
103
|
+
epi = Serienrenamer::Episode.new(@@valid_filenames["chuckfull"])
|
104
|
+
assert_equal('Chuck',epi.series)
|
105
|
+
assert_equal(1, epi.season)
|
106
|
+
assert_equal(1, epi.episode)
|
107
|
+
assert_equal("Dies ist ein Test", epi.episodename)
|
108
|
+
assert_equal("S01E01 - Dies ist ein Test.avi", epi.to_s)
|
109
|
+
|
110
|
+
flpo = Serienrenamer::Episode.new(@@valid_filenames["flpo"])
|
111
|
+
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
112
|
+
|
113
|
+
csiny = Serienrenamer::Episode.new(@@valid_filenames["csiny"])
|
114
|
+
csiny.episodename_needed=false
|
115
|
+
assert_equal("S07E20.avi", csiny.to_s)
|
116
|
+
|
117
|
+
legaltrash = Serienrenamer::Episode.new(@@valid_filenames["legaltrash"])
|
118
|
+
assert_equal("S04E04 - Die German Erinnerungen.avi", legaltrash.to_s)
|
119
|
+
|
120
|
+
royal = Serienrenamer::Episode.new(@@valid_filenames["royal"])
|
121
|
+
assert_equal("S02E10 - Beziehungsbeschwerden.avi", royal.to_s)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_episode_information_extraction_from_directory
|
125
|
+
|
126
|
+
chuck = Serienrenamer::Episode.new(@@valid_directories["chuck"])
|
127
|
+
assert_equal("S01E01 - Testepisode.avi", chuck.to_s)
|
128
|
+
|
129
|
+
chuck1 = Serienrenamer::Episode.new(@@valid_directories["chuck1"])
|
130
|
+
assert_equal("S01E01 - First Episode.avi", chuck1.to_s)
|
131
|
+
|
132
|
+
ncis = Serienrenamer::Episode.new(@@valid_directories["ncis"])
|
133
|
+
assert_equal("S09E05 - Im sicheren Hafen.avi", ncis.to_s)
|
134
|
+
|
135
|
+
chuck2 = Serienrenamer::Episode.new(@@valid_directories["chuck2"])
|
136
|
+
chuck2.episodename_needed=false
|
137
|
+
assert_equal("S02E12.avi", chuck2.to_s)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_adding_episodename_afterwards
|
141
|
+
|
142
|
+
csiny = Serienrenamer::Episode.new(@@valid_filenames["csiny"])
|
143
|
+
csiny.add_episode_information('Dies ist nachträglich eingefügt', false)
|
144
|
+
assert_equal("S07E20 - Dies ist nachträglich eingefügt.avi", csiny.to_s)
|
145
|
+
|
146
|
+
chuck = Serienrenamer::Episode.new(@@valid_directories["chuck"])
|
147
|
+
chuck.add_episode_information('Chuck.S01E01.First.Episode.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD', true)
|
148
|
+
assert_equal("S01E01 - First Episode.avi", chuck.to_s)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_videofile_determination
|
152
|
+
@@valid_filenames.each { |n,f|
|
153
|
+
assert_not_nil(Serienrenamer::Episode.determine_video_file(f))
|
154
|
+
}
|
155
|
+
|
156
|
+
@@valid_directories.each { |n,d|
|
157
|
+
assert_not_nil(Serienrenamer::Episode.determine_video_file(d))
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_episode_rename_file
|
162
|
+
epi = Serienrenamer::Episode.new(@@valid_filenames["chuckfull"])
|
163
|
+
epi.rename('test/testfiles/')
|
164
|
+
assert_equal(true, epi.success)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_episode_rename_from_directory
|
168
|
+
@@valid_directories.each do |n,d|
|
169
|
+
epi = Serienrenamer::Episode.new(d)
|
170
|
+
epi.rename('test/testfiles/')
|
171
|
+
assert_equal(true, epi.success)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_episode_where_dir_has_not_enough_info
|
176
|
+
d = @@invalid_directories["tbbt"]
|
177
|
+
|
178
|
+
filenametxt = File.new(File.join(d, "filename.txt"), "w")
|
179
|
+
filenametxt.write("The.Big.Bang.Theory.S05E16.Sheldon.Revival.HDTV.XviD-LOL")
|
180
|
+
filenametxt.close
|
181
|
+
|
182
|
+
tbbt = Serienrenamer::Episode.new(d)
|
183
|
+
assert_equal("S05E16 - Sheldon Revival.avi", tbbt.to_s)
|
184
|
+
|
185
|
+
tbbt.rename('test/testfiles/')
|
186
|
+
assert_equal(true, tbbt.success)
|
187
|
+
end
|
188
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
|
4
|
+
class TestPluginSerienjunkiesDe < Test::Unit::TestCase
|
5
|
+
@@valid_filenames = {
|
6
|
+
'flpo' => 'test/testfiles/Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
7
|
+
'dani' => 'test/testfiles/Dr.Dani.Santino.S01E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'two' => 'test/testfiles/Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
9
|
+
'simp' => 'test/testfiles/Die.Simpsons.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
10
|
+
'sea' => 'test/testfiles/tcpa-seapatrol_s05e11.avi',
|
11
|
+
}
|
12
|
+
|
13
|
+
@@valid_directories = {
|
14
|
+
'chuck' => 'test/testfiles/Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
15
|
+
'chuck2' => 'test/testfiles/Chuck.S02E10.German.Dubbed.BLURAYRiP.WEB-DL',
|
16
|
+
}
|
17
|
+
|
18
|
+
def setup
|
19
|
+
system('rm -r test/testfiles/*')
|
20
|
+
|
21
|
+
@@valid_filenames.each { |n,f|
|
22
|
+
FileUtils.touch f unless File.file?(f)
|
23
|
+
}
|
24
|
+
|
25
|
+
@@valid_directories.each { |n,d|
|
26
|
+
FileUtils.mkdir(d)
|
27
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_seriespage_url_search
|
32
|
+
|
33
|
+
plugin = Plugin::SerienjunkiesDe
|
34
|
+
|
35
|
+
misfits = plugin.find_link_to_series_page("Misfits")
|
36
|
+
assert_equal("http://serienjunkies.de/misfits/", misfits)
|
37
|
+
|
38
|
+
thementalist = plugin.find_link_to_series_page("The Mentalist")
|
39
|
+
assert_equal("http://serienjunkies.de/the-mentalist/", thementalist)
|
40
|
+
|
41
|
+
ncis = plugin.find_link_to_series_page("NCIS")
|
42
|
+
assert_equal("http://serienjunkies.de/ncis/", ncis)
|
43
|
+
|
44
|
+
berger = plugin.find_link_to_series_page("The Hard Times Of RJ Berger")
|
45
|
+
assert_equal(nil, berger)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_parse_seriespage
|
50
|
+
|
51
|
+
plugin = Plugin::SerienjunkiesDe
|
52
|
+
|
53
|
+
seasons = plugin.parse_seriespage("http://www.serienjunkies.de/royal-pains/")
|
54
|
+
assert_match(/Auch.Reiche.sind.nur.Menschen/, seasons['S01E01'])
|
55
|
+
assert_match(/Krank.vor.Liebe/, seasons['S02E02'])
|
56
|
+
|
57
|
+
seasons = plugin.parse_seriespage("http://www.serienjunkies.de/flashpoint/")
|
58
|
+
assert_match(/Zu.viele.Verlierer/, seasons['S02E02'])
|
59
|
+
assert_match(/Der.Aufstand/, seasons['S02E16'])
|
60
|
+
|
61
|
+
seasons = plugin.parse_seriespage("http://www.serienjunkies.de/necessary-roughness/")
|
62
|
+
assert_match(/Touchdown/, seasons['S01E01'])
|
63
|
+
assert_match(/Extremsport/, seasons['S01E06'])
|
64
|
+
|
65
|
+
seasons = plugin.parse_seriespage("http://www.serienjunkies.de/Weeds/")
|
66
|
+
assert_match(/Das.Geld.im.Pool/, seasons['S03E02'])
|
67
|
+
assert_match(/Schlangennest/, seasons['S02E01'])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_episode_information_generation
|
71
|
+
|
72
|
+
plugin = Plugin::SerienjunkiesDe
|
73
|
+
|
74
|
+
flpo = Serienrenamer::Episode.new(@@valid_filenames['flpo'])
|
75
|
+
data = plugin.generate_episode_information(flpo)[0]
|
76
|
+
flpo.add_episode_information(data, true) if data
|
77
|
+
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
78
|
+
|
79
|
+
two = Serienrenamer::Episode.new(@@valid_filenames['two'])
|
80
|
+
data = plugin.generate_episode_information(two)[0]
|
81
|
+
two.add_episode_information(data, true) if data
|
82
|
+
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
83
|
+
|
84
|
+
chuck = Serienrenamer::Episode.new(@@valid_directories['chuck'])
|
85
|
+
data = plugin.generate_episode_information(chuck)[0]
|
86
|
+
chuck.add_episode_information(data, true) if data
|
87
|
+
assert_equal("S01E01 - Pilot.avi", chuck.to_s)
|
88
|
+
|
89
|
+
chuck2 = Serienrenamer::Episode.new(@@valid_directories['chuck2'])
|
90
|
+
data = plugin.generate_episode_information(chuck2)[0]
|
91
|
+
chuck2.add_episode_information(data, true) if data
|
92
|
+
assert_equal("S02E10 - Chuck gegen zehn Millionen.avi", chuck2.to_s)
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
|
4
|
+
class TestPluginSerienjunkiesFeed < Test::Unit::TestCase
|
5
|
+
@@valid_filenames = {
|
6
|
+
'chuck' => 'test/testfiles/chuck.312.hdtv-lol.avi',
|
7
|
+
'flpo' => 'test/testfiles/Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'csiny' => 'test/testfiles/sof-csi.ny.s07e21.avi',
|
9
|
+
'simps' => 'test/testfiles/simpsons.s22e16.avi',
|
10
|
+
'biglove'=> 'test/testfiles/idtv-big.love.s05e06.avi',
|
11
|
+
'crmi' => 'test/testfiles/crmi-s06e22.avi',
|
12
|
+
'two' => 'test/testfiles/Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
13
|
+
'sea' => 'test/testfiles/tcpa-seapatrol_s05e11.avi',
|
14
|
+
}
|
15
|
+
|
16
|
+
@@valid_directories = {
|
17
|
+
'chuck' => 'test/testfiles/Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
18
|
+
}
|
19
|
+
|
20
|
+
def setup
|
21
|
+
system('rm -r test/testfiles/*')
|
22
|
+
|
23
|
+
@@valid_filenames.each { |n,f|
|
24
|
+
FileUtils.touch f unless File.file?(f)
|
25
|
+
}
|
26
|
+
|
27
|
+
@@valid_directories.each { |n,d|
|
28
|
+
FileUtils.mkdir(d)
|
29
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# improve this so that the Plugin uses a local xml file
|
34
|
+
def test_information_extraction
|
35
|
+
|
36
|
+
feed = Plugin::SerienjunkiesOrgFeed
|
37
|
+
feed.feed_url = File.join( File.dirname(__FILE__), 'serienjunkies_feed_sample.xml')
|
38
|
+
|
39
|
+
simps = Serienrenamer::Episode.new(@@valid_filenames['simps'])
|
40
|
+
data = feed.generate_episode_information(simps)[0]
|
41
|
+
simps.add_episode_information(data, true)
|
42
|
+
assert_equal("S22E16 - Ein Sommernachtstrip.avi", simps.to_s)
|
43
|
+
|
44
|
+
flpo = Serienrenamer::Episode.new(@@valid_filenames['flpo'])
|
45
|
+
data = feed.generate_episode_information(flpo)[0]
|
46
|
+
flpo.add_episode_information(data, true)
|
47
|
+
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
48
|
+
|
49
|
+
big = Serienrenamer::Episode.new(@@valid_filenames['biglove'])
|
50
|
+
data = feed.generate_episode_information(big)[0]
|
51
|
+
big.add_episode_information(data, true)
|
52
|
+
assert_equal("S05E06 - Scheidung.avi", big.to_s)
|
53
|
+
|
54
|
+
crmi = Serienrenamer::Episode.new(@@valid_filenames['crmi'])
|
55
|
+
data = feed.generate_episode_information(crmi)[0]
|
56
|
+
crmi.add_episode_information(data, true)
|
57
|
+
assert_equal("S06E22 - Die Dunkelkammer Mörder.avi", crmi.to_s)
|
58
|
+
|
59
|
+
two = Serienrenamer::Episode.new(@@valid_filenames['two'])
|
60
|
+
data = feed.generate_episode_information(two)[0]
|
61
|
+
two.add_episode_information(data, true)
|
62
|
+
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
63
|
+
|
64
|
+
sea = Serienrenamer::Episode.new(@@valid_filenames['sea'])
|
65
|
+
data = feed.generate_episode_information(sea)[0]
|
66
|
+
sea.add_episode_information(data, true)
|
67
|
+
assert_equal("S05E11 - Der Morgen danach.avi", sea.to_s)
|
68
|
+
|
69
|
+
csiny = Serienrenamer::Episode.new(@@valid_filenames['csiny'])
|
70
|
+
data = feed.generate_episode_information(csiny)[0]
|
71
|
+
csiny.add_episode_information(data, true)
|
72
|
+
assert_equal("S07E21 - Kugelhagel.avi", csiny.to_s)
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
|
4
|
+
#
|
5
|
+
# test class for the TextfileEpisodeInfo plugin that
|
6
|
+
# searches for textfiles with suitable episode
|
7
|
+
# information
|
8
|
+
#
|
9
|
+
class TestPluginTextfile < Test::Unit::TestCase
|
10
|
+
@@valid_directories = {
|
11
|
+
'hmym' => 'test/testfiles/HMMG.705',
|
12
|
+
}
|
13
|
+
|
14
|
+
def setup
|
15
|
+
system('rm -r test/testfiles/*')
|
16
|
+
|
17
|
+
d = @@valid_directories["hmym"]
|
18
|
+
FileUtils.mkdir(d)
|
19
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
20
|
+
|
21
|
+
filenametxt = File.new(File.join(d, "filename.txt"), "w")
|
22
|
+
filenametxt.write("How.I.Met.Your.Mother.S07E05.Die.Exkursion.German.Dubbed.HDTV.XviD-ITG")
|
23
|
+
filenametxt.close
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_information_extraction
|
27
|
+
how = Serienrenamer::Episode.new(@@valid_directories['hmym'])
|
28
|
+
data = Plugin::Textfile.generate_episode_information(how)[0]
|
29
|
+
how.add_episode_information(data, true)
|
30
|
+
assert_equal("S07E05 - Die Exkursion.avi", how.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_information_extraction_with_directory_parameter
|
34
|
+
how = @@valid_directories['hmym']
|
35
|
+
data = Plugin::Textfile.generate_episode_information(how)[0]
|
36
|
+
assert_not_nil(data)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require 'media_wiki'
|
4
|
+
|
5
|
+
class TestPluginWikipedia < Test::Unit::TestCase
|
6
|
+
@@valid_filenames = {
|
7
|
+
'flpo' => 'test/testfiles/Flashpoint.S04E04.German.Dubbed.WEB-DL.XViD.avi',
|
8
|
+
'dani' => 'test/testfiles/Dr.Dani.Santino.S01E04.German.Dubbed.WEB-DL.XViD.avi',
|
9
|
+
'two' => 'test/testfiles/Two.and.a.half.Men.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
10
|
+
'simp' => 'test/testfiles/Die.Simpsons.S09E07.German.Dubbed.WS.WEB-DL.XviD-GDR.avi',
|
11
|
+
'sea' => 'test/testfiles/tcpa-seapatrol_s05e11.avi',
|
12
|
+
}
|
13
|
+
|
14
|
+
@@valid_directories = {
|
15
|
+
'chuck' => 'test/testfiles/Chuck.S01E01.German.Dubbed.BLURAYRiP.WEB-DL',
|
16
|
+
'chuck2' => 'test/testfiles/Chuck.S02E10.German.Dubbed.BLURAYRiP.WEB-DL',
|
17
|
+
}
|
18
|
+
|
19
|
+
def setup
|
20
|
+
system('rm -r test/testfiles/*')
|
21
|
+
|
22
|
+
@@valid_filenames.each { |n,f|
|
23
|
+
FileUtils.touch f unless File.file?(f)
|
24
|
+
}
|
25
|
+
|
26
|
+
@@valid_directories.each { |n,d|
|
27
|
+
FileUtils.mkdir(d)
|
28
|
+
FileUtils.touch(File.join(d, 'episode.avi'))
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_episode_list_page_data_extraction
|
33
|
+
wiki = MediaWiki::Gateway.new('http://de.wikipedia.org/w/api.php')
|
34
|
+
|
35
|
+
data = wiki.get("Liste der Episoden von Bones – Die Knochenjägerin")
|
36
|
+
seasons = Plugin::Wikipedia.parse_episodelist_page_data(data)
|
37
|
+
|
38
|
+
assert_equal("Die Frau im Teich", seasons[1][1])
|
39
|
+
assert_equal("Ein Verräter im Feuer", seasons[2][11])
|
40
|
+
assert_equal("Vom Vergehen und Werden", seasons[6][23])
|
41
|
+
|
42
|
+
data = wiki.get("Liste der Criminal-Minds-Episoden")
|
43
|
+
seasons = Plugin::Wikipedia.parse_episodelist_page_data(data)
|
44
|
+
|
45
|
+
assert_equal("Der Abgrund", seasons[1][1])
|
46
|
+
assert_equal("Rivalen", seasons[2][9])
|
47
|
+
assert_equal("Valhalla", seasons[6][17])
|
48
|
+
|
49
|
+
data = wiki.get("Liste der Dexter-Episoden")
|
50
|
+
seasons = Plugin::Wikipedia.parse_episodelist_page_data(data)
|
51
|
+
|
52
|
+
assert_equal("Rot wie Blut", seasons[1][10])
|
53
|
+
assert_equal("Hitzewelle", seasons[2][4])
|
54
|
+
assert_equal("Familienväter", seasons[4][6])
|
55
|
+
|
56
|
+
data = wiki.get("Liste der Simpsons-Episoden")
|
57
|
+
seasons = Plugin::Wikipedia.parse_episodelist_page_data(data, true)
|
58
|
+
|
59
|
+
assert_equal("Es weihnachtet schwer", seasons[1][1])
|
60
|
+
assert_equal("Bösartige Spiele", seasons[4][5])
|
61
|
+
assert_equal("Homer an der Uni", seasons[5][3])
|
62
|
+
assert_equal("Hochzeit auf Indisch", seasons[9][7])
|
63
|
+
assert_equal("G.I. Homer", seasons[18][5])
|
64
|
+
assert_equal("Die Farbe Gelb", seasons[21][13])
|
65
|
+
|
66
|
+
data = wiki.get("Liste der Misfits-Episoden")
|
67
|
+
seasons = Plugin::Wikipedia.parse_episodelist_page_data(data)
|
68
|
+
|
69
|
+
assert_equal("Das Gewitter", seasons[1][1])
|
70
|
+
assert_equal("Nathan wird Vater", seasons[2][7])
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_inpage_episode_list_page_data_extraction
|
74
|
+
wiki = MediaWiki::Gateway.new('http://de.wikipedia.org/w/api.php')
|
75
|
+
|
76
|
+
data = wiki.get("The Glades")
|
77
|
+
seasons = Plugin::Wikipedia.parse_inarticle_episodelist_page_data(data)
|
78
|
+
|
79
|
+
assert_equal("Reptilien im Paradies", seasons[1][1])
|
80
|
+
assert_equal("Doppelgänger", seasons[1][6])
|
81
|
+
assert_equal("Unruhiges Blut", seasons[1][9])
|
82
|
+
|
83
|
+
data = wiki.get("Royal Pains")
|
84
|
+
seasons = Plugin::Wikipedia.parse_inarticle_episodelist_page_data(data)
|
85
|
+
|
86
|
+
assert_equal("Auch Reiche sind nur Menschen", seasons[1][1])
|
87
|
+
assert_equal("Krank vor Liebe", seasons[2][2])
|
88
|
+
assert_equal("Mich trifft der Blitz", seasons[2][16])
|
89
|
+
|
90
|
+
data = wiki.get("Flashpoint – Das Spezialkommando")
|
91
|
+
seasons = Plugin::Wikipedia.parse_inarticle_episodelist_page_data(data, true)
|
92
|
+
|
93
|
+
assert_equal("Skorpion", seasons[1][1])
|
94
|
+
assert_equal("Die Festung", seasons[2][2])
|
95
|
+
assert_equal("Der Beschützer", seasons[2][16])
|
96
|
+
|
97
|
+
data = wiki.get("Dr. Dani Santino – Spiel des Lebens")
|
98
|
+
seasons = Plugin::Wikipedia.parse_inarticle_episodelist_page_data(data)
|
99
|
+
|
100
|
+
assert_equal("Touchdown", seasons[1][1])
|
101
|
+
assert_equal("Zickenkrieg", seasons[1][7])
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def test_episode_information_generation
|
106
|
+
|
107
|
+
flpo = Serienrenamer::Episode.new(@@valid_filenames['flpo'])
|
108
|
+
data = Plugin::Wikipedia.generate_episode_information(flpo)[0]
|
109
|
+
flpo.add_episode_information(data, false) if data
|
110
|
+
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
111
|
+
|
112
|
+
two = Serienrenamer::Episode.new(@@valid_filenames['two'])
|
113
|
+
data = Plugin::Wikipedia.generate_episode_information(two)[0]
|
114
|
+
two.add_episode_information(data, false) if data
|
115
|
+
assert_equal("S09E07 - Das Tagebuch.avi", two.to_s)
|
116
|
+
|
117
|
+
simp = Serienrenamer::Episode.new(@@valid_filenames['simp'])
|
118
|
+
data = Plugin::Wikipedia.generate_episode_information(simp)[0]
|
119
|
+
simp.add_episode_information(data, false) if data
|
120
|
+
assert_equal("S09E07 - Hochzeit auf Indisch.avi", simp.to_s)
|
121
|
+
|
122
|
+
chuck = Serienrenamer::Episode.new(@@valid_directories['chuck'])
|
123
|
+
data = Plugin::Wikipedia.generate_episode_information(chuck)[0]
|
124
|
+
chuck.add_episode_information(data, false) if data
|
125
|
+
assert_equal("S01E01 - Pilot.avi", chuck.to_s)
|
126
|
+
|
127
|
+
chuck2 = Serienrenamer::Episode.new(@@valid_directories['chuck2'])
|
128
|
+
data = Plugin::Wikipedia.generate_episode_information(chuck2)[0]
|
129
|
+
chuck2.add_episode_information(data, false) if data
|
130
|
+
assert_equal("S02E10 - Chuck gegen zehn Millionen.avi", chuck2.to_s)
|
131
|
+
|
132
|
+
dani = Serienrenamer::Episode.new(@@valid_filenames['dani'])
|
133
|
+
data = Plugin::Wikipedia.generate_episode_information(dani)[0]
|
134
|
+
dani.add_episode_information(data, false) if data
|
135
|
+
assert_equal("S01E04 - Gewohnheiten.avi", dani.to_s)
|
136
|
+
|
137
|
+
sea = Serienrenamer::Episode.new(@@valid_filenames['sea'])
|
138
|
+
data = Plugin::Wikipedia.generate_episode_information(sea)[0]
|
139
|
+
sea.add_episode_information(data, false) if data
|
140
|
+
assert_equal("S05E11 - Der Morgen danach.avi", sea.to_s)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_check_for_series_main_page
|
144
|
+
|
145
|
+
wiki = MediaWiki::Gateway.new('http://de.wikipedia.org/w/api.php')
|
146
|
+
|
147
|
+
assert_equal(false, Plugin::Wikipedia.is_series_main_page?(wiki.get("Bones")))
|
148
|
+
assert_equal(true, Plugin::Wikipedia.is_series_main_page?(wiki.get("Bones – Die Knochenjägerin")))
|
149
|
+
assert_equal(false, Plugin::Wikipedia.is_series_main_page?(wiki.get("Bones – Der Tod ist erst der Anfang")))
|
150
|
+
assert_equal(false, Plugin::Wikipedia.is_series_main_page?(wiki.get("Chuck")))
|
151
|
+
assert_equal(true, Plugin::Wikipedia.is_series_main_page?(wiki.get("Chuck (Fernsehserie)")))
|
152
|
+
assert_equal(false, Plugin::Wikipedia.is_series_main_page?(wiki.get("Chuck (Album)")))
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_check_for_disambiguation_page
|
157
|
+
|
158
|
+
wiki = MediaWiki::Gateway.new('http://de.wikipedia.org/w/api.php')
|
159
|
+
|
160
|
+
assert_equal(true, Plugin::Wikipedia.is_disambiguation_site?(wiki.get("Bones")))
|
161
|
+
assert_equal(false, Plugin::Wikipedia.is_disambiguation_site?(wiki.get("Bones – Die Knochenjägerin")))
|
162
|
+
assert_equal(true, Plugin::Wikipedia.is_disambiguation_site?(wiki.get("Chuck")))
|
163
|
+
assert_equal(false, Plugin::Wikipedia.is_disambiguation_site?(wiki.get("Chuck (Fernsehserie)")))
|
164
|
+
assert_equal(false, Plugin::Wikipedia.is_disambiguation_site?(wiki.get("Chuck (Album)")))
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_check_for_inarticle_episode_list
|
169
|
+
|
170
|
+
wiki = MediaWiki::Gateway.new('http://de.wikipedia.org/w/api.php')
|
171
|
+
|
172
|
+
assert_equal(false, Plugin::Wikipedia.contains_inarticle_episode_list?(wiki.get("Bones")))
|
173
|
+
assert_equal(true, Plugin::Wikipedia.contains_inarticle_episode_list?(wiki.get("The Glades")))
|
174
|
+
assert_equal(true, Plugin::Wikipedia.contains_inarticle_episode_list?(wiki.get("Royal Pains")))
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|