serienrenamer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/README.rdoc +8 -0
- data/lib/plugin/serienjunkies_org.rb +179 -0
- data/lib/serienrenamer.rb +1 -1
- data/lib/serienrenamer/episode.rb +1 -1
- data/test/test_episode.rb +179 -161
- data/test/test_helper.rb +56 -40
- data/test/test_information_store.rb +37 -34
- data/test/test_plugin_serienjunkies_de.rb +72 -69
- data/test/test_plugin_serienjunkies_feed.rb +68 -66
- data/test/test_plugin_textfile.rb +43 -37
- data/test/test_plugin_wikipedia.rb +159 -155
- data/test/test_serienjunkies_org.rb +84 -0
- metadata +5 -2
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -13,6 +13,7 @@ like "S01E01 - Episodename.avi"
|
|
13
13
|
* clean these information and bring that into a recommended format
|
14
14
|
* search for information in specific textfiles like "filename.txt"
|
15
15
|
* query the seriejunkies.org-feed for episode information
|
16
|
+
* query the serienjunkies.org Page for series specific data
|
16
17
|
* query the serienjunkies.de Page for series specific data
|
17
18
|
* query wikipedia for episode information
|
18
19
|
* repair broken german umlauts if the occur in the episode title
|
@@ -32,6 +33,13 @@ like "S01E01 - Episodename.avi"
|
|
32
33
|
|
33
34
|
* sudo gem install serienrenamer
|
34
35
|
|
36
|
+
== Development:
|
37
|
+
|
38
|
+
If you want to improve "serienrenamer" than checkout this repository and run
|
39
|
+
'bundle' to get the development dependencies (vcr, fakeweb) installed and than
|
40
|
+
run 'rake test' which could takes some time the at the first run. After that
|
41
|
+
it should be quick.
|
42
|
+
|
35
43
|
== LICENSE:
|
36
44
|
|
37
45
|
(General Public License)
|
@@ -0,0 +1,179 @@
|
|
1
|
+
#
|
2
|
+
# Class that extracts information about episodes
|
3
|
+
# from the serienjunkies.org-Page
|
4
|
+
#
|
5
|
+
require 'uri'
|
6
|
+
require 'mechanize'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
module Plugin
|
10
|
+
|
11
|
+
class SerienjunkiesOrg < Serienrenamer::Pluginbase
|
12
|
+
|
13
|
+
def self.plugin_name; "SerienjunkiesOrg" end
|
14
|
+
def self.plugin_url; "http://serienjunkies.org" end
|
15
|
+
def self.usable; true end
|
16
|
+
def self.priority; 10 end
|
17
|
+
|
18
|
+
# Public: tries to search for an appropriate episodename
|
19
|
+
#
|
20
|
+
# if this is the first call to this method, it builds up
|
21
|
+
# a hash with all series and existing episodes, which can
|
22
|
+
# be used by all future method calls
|
23
|
+
#
|
24
|
+
# episode - Serienrenamer::Episode instance which holds the information
|
25
|
+
#
|
26
|
+
# Returns an array of possible episodenames
|
27
|
+
def self.generate_episode_information(episode)
|
28
|
+
|
29
|
+
raise ArgumentError, "Serienrenamer::Episode instance needed" unless
|
30
|
+
episode.is_a?(Serienrenamer::Episode)
|
31
|
+
|
32
|
+
unless defined? @cached_data
|
33
|
+
@cached_data = Hash.new
|
34
|
+
end
|
35
|
+
|
36
|
+
if ! @cached_data.has_key?(episode.series)
|
37
|
+
|
38
|
+
if episode.series.match(/\w+/)
|
39
|
+
|
40
|
+
# determine link to series
|
41
|
+
seriespage_link = self.find_link_to_series_page(episode.series)
|
42
|
+
|
43
|
+
if seriespage_link
|
44
|
+
seriesdata = self.parse_seriespage(seriespage_link)
|
45
|
+
|
46
|
+
@cached_data[episode.series] = seriesdata
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
matched_episodes = []
|
52
|
+
|
53
|
+
# tries to find an episodename in cached_data
|
54
|
+
# otherwise returns empty array
|
55
|
+
begin
|
56
|
+
series = @cached_data[episode.series]
|
57
|
+
|
58
|
+
identifier = "%d_%d" % [ episode.season, episode.episode ]
|
59
|
+
episodename = series[identifier]
|
60
|
+
|
61
|
+
if episodename.match(/\w+/)
|
62
|
+
matched_episodes.push(episodename)
|
63
|
+
end
|
64
|
+
rescue
|
65
|
+
end
|
66
|
+
|
67
|
+
return matched_episodes
|
68
|
+
end
|
69
|
+
|
70
|
+
# Public: tries to find a link to the seriespage
|
71
|
+
#
|
72
|
+
# seriesname - the series name for which the page is searched
|
73
|
+
#
|
74
|
+
# Returns the link or nil
|
75
|
+
def self.find_link_to_series_page(seriesname)
|
76
|
+
raise ArgumentError, "seriesname expected" unless seriesname.match(/\w+/)
|
77
|
+
|
78
|
+
self.build_agent unless defined? @agent
|
79
|
+
|
80
|
+
url = URI.join(plugin_url, "?cat=0&l=%s" % seriesname[0].downcase )
|
81
|
+
|
82
|
+
pattern = seriesname.gsub(/\s/, ".*")
|
83
|
+
|
84
|
+
@agent.get(url).search("div#sidebar > ul > li > a").each do |series|
|
85
|
+
if series.text.match(/#{pattern}/i)
|
86
|
+
return URI.join( plugin_url, series[:href]).to_s
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
# Public: parses a series page and extracts the episode information
|
94
|
+
#
|
95
|
+
# page_url - the url to the seriespage
|
96
|
+
# german - if true it extracts only german data (Defaults to true)
|
97
|
+
#
|
98
|
+
# Returns a hash which contains the episode information or an empty
|
99
|
+
# hash if there aren't any episodes
|
100
|
+
def self.parse_seriespage(page_url, german=true, debug=false)
|
101
|
+
|
102
|
+
self.build_agent unless defined? @agent
|
103
|
+
|
104
|
+
series = {}
|
105
|
+
doc = @agent.get(page_url)
|
106
|
+
|
107
|
+
doc.search('div#sidebar > div#scb > div.bkname > a').each do |link|
|
108
|
+
if german
|
109
|
+
next unless link.content.match(/Staffel/i)
|
110
|
+
else
|
111
|
+
next unless link.content.match(/Season/i)
|
112
|
+
end
|
113
|
+
|
114
|
+
site = @agent.get(link[:href])
|
115
|
+
episodes = self.parse_season_subpage(site, german)
|
116
|
+
|
117
|
+
series.merge!(episodes)
|
118
|
+
end
|
119
|
+
|
120
|
+
puts series.to_yaml if debug
|
121
|
+
|
122
|
+
return series
|
123
|
+
end
|
124
|
+
|
125
|
+
# Public: extracts the episodes from one season
|
126
|
+
#
|
127
|
+
# page - Mechanize page object which holds the season
|
128
|
+
# german - extracts german or international episodes
|
129
|
+
#
|
130
|
+
# Returns a hash with all episodes (unique)
|
131
|
+
def self.parse_season_subpage(page, german=true)
|
132
|
+
|
133
|
+
episodes = {}
|
134
|
+
|
135
|
+
page.search('div.post > div.post-content strong:nth-child(1)').each do |e|
|
136
|
+
|
137
|
+
content = e.content
|
138
|
+
md = Serienrenamer::Episode.extract_episode_information(content)
|
139
|
+
next unless md
|
140
|
+
|
141
|
+
if german
|
142
|
+
next unless content.match(/German/i)
|
143
|
+
next if content.match(/Subbed/i)
|
144
|
+
else
|
145
|
+
next if content.match(/German/i)
|
146
|
+
end
|
147
|
+
|
148
|
+
episodename =
|
149
|
+
Serienrenamer::Episode.clean_episode_data(md[:episodename], true)
|
150
|
+
next unless episodename && episodename.match(/\w+/)
|
151
|
+
|
152
|
+
id = "%d_%d" % [ md[:season].to_i, md[:episode].to_i ]
|
153
|
+
|
154
|
+
next if episodes[id] && episodes[id].size > episodename.size
|
155
|
+
|
156
|
+
episodes[id] = episodename
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
return episodes
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
# Private: constructs a Mechanize instance and adds a fix that interprets
|
166
|
+
# every response as html
|
167
|
+
#
|
168
|
+
# Returns the agent
|
169
|
+
def self.build_agent
|
170
|
+
@agent = Mechanize.new do |a|
|
171
|
+
a.post_connect_hooks << lambda do |_,_,response,_|
|
172
|
+
if response.content_type.nil? || response.content_type.empty?
|
173
|
+
response.content_type = 'text/html'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
data/lib/serienrenamer.rb
CHANGED
@@ -32,7 +32,7 @@ module Serienrenamer
|
|
32
32
|
iNTERNAL CRoW MSE c0nFuSed UTOPiA scum EXPiRED BDRiP HDTV
|
33
33
|
iTunesHD 720p x264 h264 CRiSP euHD WEBRiP ZZGtv ARCHiV DD20
|
34
34
|
Prim3time Nfo Repack SiMPTY BLURAYRiP BluRay DELiCiOUS Synced
|
35
|
-
UNDELiCiOUS fBi CiD iTunesHDRip RedSeven OiNK idTV DL DD51
|
35
|
+
UNDELiCiOUS fBi CiD iTunesHDRip RedSeven OiNK idTV DL DD51 AC3
|
36
36
|
)
|
37
37
|
|
38
38
|
# Constructor for the Episode-Class, which takes an episode as
|
data/test/test_episode.rb
CHANGED
@@ -4,193 +4,208 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
class TestEpisode < Test::Unit::TestCase
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
+
}
|
18
|
+
|
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
|
+
}
|
25
|
+
|
26
|
+
@@invalid_directories = {
|
27
|
+
'tbbt' => 'BBTV.16/',
|
28
|
+
}
|
29
|
+
|
30
|
+
def setup
|
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
|
36
|
+
|
37
|
+
def teardown
|
38
|
+
TestHelper.clean
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_episode_name_detection
|
42
|
+
|
43
|
+
@@files.each { |name,file|
|
44
|
+
assert_equal(true,
|
45
|
+
Serienrenamer::Episode.contains_episode_information?(file))
|
46
|
+
|
47
|
+
assert_equal(false,
|
48
|
+
Serienrenamer::Episode.extract_episode_information(file).nil?)
|
17
49
|
}
|
18
50
|
|
19
|
-
@@directories
|
20
|
-
|
21
|
-
|
22
|
-
'chuck2' => 'chuck.2x12',
|
23
|
-
'ncis' => 'NCIS.S09E05.Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD',
|
24
|
-
}
|
51
|
+
@@directories.each { |name,dir|
|
52
|
+
assert_equal(true,
|
53
|
+
Serienrenamer::Episode.contains_episode_information?(dir))
|
25
54
|
|
26
|
-
|
27
|
-
|
55
|
+
assert_equal(false,
|
56
|
+
Serienrenamer::Episode.extract_episode_information(dir).nil?)
|
28
57
|
}
|
29
58
|
|
30
|
-
|
31
|
-
|
32
|
-
TestHelper.create_test_dirs(@@directories.values)
|
33
|
-
TestHelper.create_test_dirs(@@invalid_directories.values)
|
34
|
-
TestHelper.cwd
|
35
|
-
end
|
36
|
-
|
37
|
-
def teardown
|
38
|
-
TestHelper.clean
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_episode_name_detection
|
42
|
-
|
43
|
-
@@files.each { |name,file|
|
44
|
-
assert_equal(true,
|
45
|
-
Serienrenamer::Episode.contains_episode_information?(file))
|
46
|
-
|
47
|
-
assert_equal(false,
|
48
|
-
Serienrenamer::Episode.extract_episode_information(file).nil?)
|
49
|
-
}
|
50
|
-
|
51
|
-
@@directories.each { |name,dir|
|
52
|
-
assert_equal(true,
|
53
|
-
Serienrenamer::Episode.contains_episode_information?(dir))
|
54
|
-
|
55
|
-
assert_equal(false,
|
56
|
-
Serienrenamer::Episode.extract_episode_information(dir).nil?)
|
57
|
-
}
|
59
|
+
assert_equal(false,
|
60
|
+
Serienrenamer::Episode.contains_episode_information?('video.flv'))
|
58
61
|
|
59
|
-
|
60
|
-
|
62
|
+
assert_equal(true,
|
63
|
+
Serienrenamer::Episode.extract_episode_information('video.flv').nil?)
|
64
|
+
end
|
61
65
|
|
62
|
-
|
63
|
-
|
66
|
+
def test_information_cleanup
|
67
|
+
VCR.use_cassette("episode_#{method_name}") do
|
68
|
+
assert_equal("Im sicheren Hafen",
|
69
|
+
Serienrenamer::Episode.clean_episode_data(
|
70
|
+
".Im.sicheren.Hafen.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD",
|
71
|
+
true, true)
|
72
|
+
)
|
64
73
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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"))
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_repairing_umlauts
|
77
|
+
VCR.use_cassette("episode_#{method_name}") do
|
78
|
+
assert_equal("Duell",
|
79
|
+
Serienrenamer::Episode.repair_umlauts("Duell"))
|
80
|
+
assert_equal("für",
|
81
|
+
Serienrenamer::Episode.repair_umlauts("fuer"))
|
82
|
+
assert_equal("Änderung",
|
83
|
+
Serienrenamer::Episode.repair_umlauts("Aenderung"))
|
84
|
+
assert_equal("Zaubersprüche",
|
85
|
+
Serienrenamer::Episode.repair_umlauts("Zaubersprueche"))
|
86
|
+
assert_equal("Ungeheuerlich",
|
87
|
+
Serienrenamer::Episode.repair_umlauts("Ungeheuerlich"))
|
88
|
+
assert_equal("Frauen",
|
89
|
+
Serienrenamer::Episode.repair_umlauts("Frauen"))
|
90
|
+
assert_equal("Abführmittel",
|
91
|
+
Serienrenamer::Episode.repair_umlauts("Abfuehrmittel"))
|
92
|
+
assert_equal("tödlich",
|
93
|
+
Serienrenamer::Episode.repair_umlauts("toedlich"))
|
94
|
+
assert_equal("König",
|
95
|
+
Serienrenamer::Episode.repair_umlauts("Koenig"))
|
96
|
+
assert_equal("Öko",
|
97
|
+
Serienrenamer::Episode.repair_umlauts("Oeko"))
|
98
|
+
assert_equal("Männer",
|
99
|
+
Serienrenamer::Episode.repair_umlauts("Maenner"))
|
100
|
+
assert_equal("Draufgänger",
|
101
|
+
Serienrenamer::Episode.repair_umlauts("Draufgaenger"))
|
102
|
+
assert_equal("Unglücksvögel",
|
103
|
+
Serienrenamer::Episode.repair_umlauts("Ungluecksvoegel"))
|
104
|
+
assert_equal("Jäger",
|
105
|
+
Serienrenamer::Episode.repair_umlauts("Jaeger"))
|
106
|
+
assert_equal("Loyalität",
|
107
|
+
Serienrenamer::Episode.repair_umlauts("Loyalitaet"))
|
108
|
+
# both forms not existing
|
109
|
+
assert_equal("Moeback",
|
110
|
+
Serienrenamer::Episode.repair_umlauts("Moeback"))
|
108
111
|
end
|
112
|
+
end
|
109
113
|
|
110
|
-
|
114
|
+
def test_episode_information_extraction_from_file
|
111
115
|
|
112
|
-
|
116
|
+
VCR.use_cassette("episode_#{method_name}") do
|
117
|
+
assert_raise(ArgumentError) { Serienrenamer::Episode.new('video.flv')}
|
113
118
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
epi = Serienrenamer::Episode.new(@@files["chuckfull"])
|
120
|
+
assert_equal('Chuck',epi.series)
|
121
|
+
assert_equal(1, epi.season)
|
122
|
+
assert_equal(1, epi.episode)
|
123
|
+
assert_equal("Dies ist ein Test", epi.episodename)
|
124
|
+
assert_equal("S01E01 - Dies ist ein Test.avi", epi.to_s)
|
120
125
|
|
121
|
-
|
122
|
-
|
126
|
+
flpo = Serienrenamer::Episode.new(@@files["flpo"])
|
127
|
+
assert_equal("S04E04 - Getrübte Erinnerungen.avi", flpo.to_s)
|
123
128
|
|
124
|
-
|
125
|
-
|
126
|
-
|
129
|
+
csiny = Serienrenamer::Episode.new(@@files["csiny"])
|
130
|
+
csiny.episodename_needed=false
|
131
|
+
assert_equal("S07E20.avi", csiny.to_s)
|
127
132
|
|
128
|
-
|
129
|
-
|
133
|
+
legaltrash = Serienrenamer::Episode.new(@@files["legaltrash"])
|
134
|
+
assert_equal("S04E04 - Die German Erinnerungen.avi", legaltrash.to_s)
|
130
135
|
|
131
|
-
|
132
|
-
|
136
|
+
royal = Serienrenamer::Episode.new(@@files["royal"])
|
137
|
+
assert_equal("S02E10 - Beziehungsbeschwerden.avi", royal.to_s)
|
133
138
|
end
|
139
|
+
end
|
134
140
|
|
135
|
-
|
141
|
+
def test_episode_information_extraction_from_directory
|
136
142
|
|
137
|
-
|
138
|
-
|
143
|
+
VCR.use_cassette("episode_#{method_name}") do
|
144
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
145
|
+
assert_equal("S01E01 - Testepisode.avi", chuck.to_s)
|
139
146
|
|
140
|
-
|
141
|
-
|
147
|
+
chuck1 = Serienrenamer::Episode.new(@@directories["chuck1"])
|
148
|
+
assert_equal("S01E01 - First Episode.avi", chuck1.to_s)
|
142
149
|
|
143
|
-
|
144
|
-
|
150
|
+
ncis = Serienrenamer::Episode.new(@@directories["ncis"])
|
151
|
+
assert_equal("S09E05 - Im sicheren Hafen.avi", ncis.to_s)
|
145
152
|
|
146
|
-
|
147
|
-
|
148
|
-
|
153
|
+
chuck2 = Serienrenamer::Episode.new(@@directories["chuck2"])
|
154
|
+
chuck2.episodename_needed=false
|
155
|
+
assert_equal("S02E12.avi", chuck2.to_s)
|
149
156
|
end
|
157
|
+
end
|
150
158
|
|
151
|
-
|
159
|
+
def test_adding_episodename_afterwards
|
152
160
|
|
153
|
-
|
154
|
-
|
155
|
-
|
161
|
+
VCR.use_cassette("episode_#{method_name}") do
|
162
|
+
csiny = Serienrenamer::Episode.new(@@files["csiny"])
|
163
|
+
csiny.add_episode_information('Dies ist nachträglich eingefügt', false)
|
164
|
+
assert_equal("S07E20 - Dies ist nachträglich eingefügt.avi", csiny.to_s)
|
156
165
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
166
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
167
|
+
chuck.add_episode_information(
|
168
|
+
'Chuck.S01E01.First.Episode.GERMAN.DUBBED.DL.720p.HDTV.x264-euHD',
|
169
|
+
true)
|
161
170
|
assert_equal("S01E01 - First Episode.avi", chuck.to_s)
|
162
171
|
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_videofile_determination
|
175
|
+
@@files.each { |n,f|
|
176
|
+
assert_not_nil(Serienrenamer::Episode.determine_video_file(f))
|
177
|
+
}
|
163
178
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
179
|
+
@@directories.each { |n,d|
|
180
|
+
assert_not_nil(Serienrenamer::Episode.determine_video_file(d))
|
181
|
+
}
|
182
|
+
end
|
168
183
|
|
169
|
-
|
170
|
-
|
171
|
-
|
184
|
+
def test_episode_rename_file
|
185
|
+
VCR.use_cassette("episode_#{method_name}") do
|
186
|
+
epi = Serienrenamer::Episode.new(@@files["chuckfull"])
|
187
|
+
epi.rename
|
188
|
+
assert_equal(true, epi.success)
|
172
189
|
end
|
190
|
+
end
|
173
191
|
|
174
|
-
|
175
|
-
|
192
|
+
def test_episode_rename_from_directory
|
193
|
+
VCR.use_cassette("episode_#{method_name}") do
|
194
|
+
@@directories.each do |n,d|
|
195
|
+
epi = Serienrenamer::Episode.new(d)
|
176
196
|
epi.rename
|
177
197
|
assert_equal(true, epi.success)
|
198
|
+
end
|
178
199
|
end
|
200
|
+
end
|
179
201
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
epi.rename
|
184
|
-
assert_equal(true, epi.success)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_episode_where_dir_has_not_enough_info
|
189
|
-
d = @@invalid_directories["tbbt"]
|
202
|
+
def test_episode_where_dir_has_not_enough_info
|
203
|
+
VCR.use_cassette("episode_#{method_name}") do
|
204
|
+
d = @@invalid_directories["tbbt"]
|
190
205
|
|
191
|
-
|
192
|
-
|
193
|
-
|
206
|
+
filenametxt = File.new(File.join(d, "filename.txt"), "w")
|
207
|
+
filenametxt.write(
|
208
|
+
"The.Big.Bang.Theory.S05E16.Sheldon.Revival.HDTV.XviD-LOL")
|
194
209
|
filenametxt.close
|
195
210
|
|
196
211
|
tbbt = Serienrenamer::Episode.new(d)
|
@@ -199,20 +214,23 @@ class TestEpisode < Test::Unit::TestCase
|
|
199
214
|
tbbt.rename
|
200
215
|
assert_equal(true, tbbt.success)
|
201
216
|
end
|
217
|
+
end
|
202
218
|
|
203
|
-
|
204
|
-
|
219
|
+
def test_generate_episode_hash
|
220
|
+
VCR.use_cassette("episode_#{method_name}") do
|
221
|
+
chuck = Serienrenamer::Episode.new(@@directories["chuck"])
|
205
222
|
|
206
|
-
|
207
|
-
|
208
|
-
|
223
|
+
videofile = File.new(chuck.episodepath, "w")
|
224
|
+
videofile.write("Chuck.S01E01.Testepisode.German.Dubbed.BLURAYRiP")
|
225
|
+
videofile.close
|
209
226
|
|
210
|
-
|
211
|
-
|
212
|
-
|
227
|
+
assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
|
228
|
+
chuck.rename
|
229
|
+
assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
|
213
230
|
|
214
|
-
|
215
|
-
|
216
|
-
|
231
|
+
# explicit bytecount
|
232
|
+
assert_equal("78193bb6ffe829b49981b494ab243a82", chuck.md5sum(5))
|
233
|
+
assert_equal("0f2788bb1324330898fffddcafd2b8e1", chuck.md5sum(12))
|
217
234
|
end
|
235
|
+
end
|
218
236
|
end
|