1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#include <QString>
#include <QtTest>
#include "../src/videofile.h"
#include "../src/systemutils.h"
#include "../src/utils.h"
class MovieFileTest : public QObject
{
Q_OBJECT
public:
MovieFileTest();
private Q_SLOTS:
void testPathParsing_data();
void testPathParsing();
// TODO figure out how I can use multiple test files in qt
void testCommandExists();
void testCommonSliceInStrings_data();
void testCommonSliceInStrings();
void qstringEcodingSize();
};
MovieFileTest::MovieFileTest()
{
}
void MovieFileTest::testPathParsing_data()
{
QTest::addColumn<QString>("path");
QTest::addColumn<QString>("releaseGroup");
QTest::addColumn<QString>("showName");
QTest::addColumn<QString>("episodeNumber");
QTest::addColumn<float>("numericEpisodeNumber");
QTest::addColumn<QString>("episodeName");
QTest::newRow("Number: simple number") <<
"/mnt/fields1/torrents/[Mazui]_Hyouka_[720p]/[Mazui]_Hyouka_-_02_[356D9C93].mkv" <<
"[Mazui]" <<
"Hyouka" <<
"02" <<
2.f <<
"";
QTest::newRow("Number: SeasonXEpisode") <<
"/mnt/fields2/torrents/When They Cry - Higurashi [Hi10]/Season1/Higurashi no Naku Koro ni 1x04.mkv" <<
"" <<
"Higurashi no Naku Koro ni" <<
"1x04" <<
4.f <<
"";
QTest::newRow("Number: versionedEpisode") <<
"/t/[Mazui]_Hyouka_[720p]/[Mazui]_Hyouka_-_13v2_[BE011245].mkv" <<
"[Mazui]" <<
"Hyouka" <<
"13v2" <<
13.f <<
"";
QTest::newRow("Number: decimalEpisode") <<
"/mnt/fields1/torrents/[Mazui]_Hyouka_[720p]/[Mazui]_Hyouka_-_11.5_[3C10E2F9].mkv" <<
"[Mazui]" <<
"Hyouka" <<
"11.5" <<
11.5f <<
"";
QTest::newRow("Number: 'Episode' prefix") <<
"/home/nehmulos/Downloads/Spice and Wolf Complete Series/Season 01/Spice and Wolf Episode 01.mkv" <<
"" <<
"Spice and Wolf" <<
"Episode 01" <<
1.f <<
"";
QTest::newRow("Number: Ep prefix") <<
"/home/nehmulos/Downloads/K-ON!_(2009)_[1080p,BluRay,x264]_-_THORA/K-ON!_Ep02_Instruments!_[1080p,BluRay,x264]_-_THORA.mkv" <<
"THORA" <<
"K-ON!" <<
"Ep02" <<
2.f <<
"Instruments!";
QTest::newRow("Number: 0 prefixes & dot spaces") <<
"/tmp/Legend.of.the.Galactic.Heroes.001.[x264.720p.10bit.AAC].mkv" <<
"" <<
"Legend of the Galactic Heroes" <<
"001" <<
1.f <<
"";
QTest::newRow("Number: ed is the end of the title (Elfen lied 03)") <<
"/tmp/Elfen lied 03.ogg" <<
"" <<
"Elfen lied" <<
"03" <<
3.f <<
"";
QTest::newRow("Name: after obvious Ep number") <<
"/home/nehmulos/Downloads/K-ON!_(2009)_[1080p,BluRay,x264]_-_THORA/K-ON!_Ep02_Instruments!_[1080p,BluRay,x264]_-_THORA.mkv" <<
"THORA" <<
"K-ON!" <<
"Ep02" <<
2.f <<
"Instruments!";
QTest::newRow("Name: Without Ep name") <<
"/t/[Coalgirls]_The_Melancholy_of_Haruhi_Suzumiya_(1280x720_Blu-Ray_FLAC)/Season I/[Coalgirls]_The_Melancholy_of_Haruhi_Suzumiya_-_Remote_Island_Syndrome_I_(1280x720_Blu-Ray_FLAC)_[10DBFB45].mkv" <<
"[Coalgirls]" <<
"The Melancholy of Haruhi Suzumiya" <<
"" <<
VideoFile::UNKNOWN <<
"Remote Island Syndrome I";
QTest::newRow("Group: in front with [techtags] behind") <<
"/mnt/fields1/torrents/[DeadFish] Nisemonogatari - Batch [BD][720p][MP4][AAC]/[DeadFish] Nisemonogatari - 01 [BD][720p][AAC].mp4" <<
"[DeadFish]" <<
"Nisemonogatari" <<
"01" <<
1.f <<
"";
QTest::newRow("Group: at the end") <<
"/home/nehmulos/Downloads/K-ON!_(2009)_[1080p,BluRay,x264]_-_THORA/K-ON!_Ep02_Instruments!_[1080p,BluRay,x264]_-_THORA.mkv" <<
"THORA" <<
"K-ON!" <<
"Ep02" <<
2.f <<
"Instruments!";
QTest::newRow("Group: at the end with version behind") <<
"/home/nehmulos/Downloads/K-ON!_(2009)_[1080p,BluRay,x264]_-_THORA/K-ON!_ED_[1080p,BluRay,x264]_-_THORA v2.mkv" <<
"THORA" <<
"K-ON!" <<
"ED" <<
VideoFile::SPECIAL <<
"";
QTest::newRow("Group: no goup") <<
"/home/nehmulos/Downloads/Spice and Wolf Complete Series/Season 01/Spice and Wolf Episode 02.mkv" <<
""<<
"Spice and Wolf" <<
"Episode 02" <<
2.f <<
"";
QTest::newRow("Group: no group2") <<
"/mnt/fields2/torrents/When They Cry - Higurashi [Hi10]/Season1/Higurashi no Naku Koro ni 1x01.mkv" <<
"" <<
"Higurashi no Naku Koro ni" <<
"1x01" <<
1.f <<
"";
QTest::newRow("ShowName: [group] name - num [tech][tags].vid") <<
"/home/nehmulos/Downloads/[DeadFish] Bakemonogatari [BD][1080p][MP4][AAC]/[DeadFish] Bakemonogatari - 01 [BD][1080p][AAC].mp4" <<
"[DeadFish]" <<
"Bakemonogatari" <<
"01" <<
1.f <<
"";
QTest::newRow("ShowName: name Ep.num[tech][tags].vid") <<
"/home/nehmulos/Downloads/[SSP-Corp] Noir [Dual-Audio]/Noir_Ep.01[h.264-AAC][SSP-Corp][E5A84450].mkv" <<
"" <<
"Noir" <<
"Ep 01" <<
1.f <<
"";
QTest::newRow("ShowName: ed is the end of the title (Elfen lied 03)") <<
"/mnt/fields2/torrents/[Coalgirls]_Elfen_Lied_(1280x720_Blu-ray_FLAC)/[Coalgirls]_Elfen_Lied_01_(1280x720_Blu-ray_FLAC)_[5BC74BC6].mkv" <<
"[Coalgirls]" <<
"Elfen Lied" <<
"01" <<
1.f <<
"";
QTest::newRow("ShowName: Number in Show name") <<
"/mnt/[gg]_Kimi_ni_Todoke_2nd_Season_-_00_[BF735BC4].mkv" <<
"[gg]" <<
"Kimi ni Todoke 2nd Season" <<
"00" <<
0.f <<
"";
QTest::newRow("EpNum: Preview without num") <<
"/torrents/[Kaylith] Sakura Trick - PV [720p][4723E085].mkv" <<
"[Kaylith]" <<
"Sakura Trick" <<
"PV" <<
VideoFile::SPECIAL <<
"";
QTest::newRow("EpNum: Preview with num") <<
"/torrents/[Kaylith] Sakura Trick - PV2(v0) (C85 Version) [360p][6A4B418C].mkv" <<
"[Kaylith]" <<
"Sakura Trick" <<
"PV2" << // TODO also check for v0
VideoFile::SPECIAL <<
"";
QTest::newRow("EpNum: Special with num") <<
"/[Asenshi] Jinrui wa Suitai Shimashita - Special 01 [BD 720p AAC] [FF698165].mkv" <<
"[Asenshi]" <<
"Jinrui wa Suitai Shimashita Special" <<
"Special 01" <<
1.f <<
"";
QTest::newRow("EpNum: Special plural with num and weird doki dashes") <<
"/Jinrui wa Suitai Shimashita (2012) [Doki][1280x720 Hi10P BD FLAC]/[Doki] Jinrui wa Suitai Shimashita - Specials - 01 (1280x720 Hi10P BD FLAC) [E08C5B5A].mkv" <<
"[Doki]" <<
"Jinrui wa Suitai Shimashita Specials" <<
"Specials - 01" <<
1.f <<
"";
QTest::newRow("EpNum: no space before dash") <<
"/torrents/[&]Tesagure!-1 [720p] [137E33FB].mkv" <<
"[&]" <<
"Tesagure!" <<
"-1" <<
1.f <<
"";
QTest::newRow("EpNum: Roman Number in title") <<
"/torrents/[Final8]Hellsing Ultimate I-X + Dawn I-III (BD 10-bit 1920x1080 x264 FLAC 5.1)/[Final8]Hellsing Ultimate IV (BD 10-bit 1920x1080 x264 FLAC 5.1)[1F6EAC2A].mkv" <<
"[Final8]" <<
"Hellsing Ultimate" <<
"4" <<
4.f <<
"";
QTest::newRow("EpNum: Roman Number in title won't overwrite existing epNum") <<
"/torrents/[KiteSeekers-Wasurenai] Tantei Opera Milky Holmes II - 01-12 [1280x720 H264 OGG]/[KiteSeekers-Wasurenai] Tantei Opera Milky Holmes II - 01 [1280x720 H264 OGG] [45B5EDD5].mkv" <<
"[KiteSeekers-Wasurenai]" <<
"Tantei Opera Milky Holmes II" <<
"01" <<
1.f <<
"";
QTest::newRow("ShowName: Play All file") <<
"tmp/[Coalgirls]_Toradora_Play_All_No_OPED_Style_1_(1280x720_Blu-ray_FLAC)_[051337D2].mkv" <<
"[Coalgirls]" <<
"Toradora" <<
"Play All No OPED Style 1" <<
VideoFile::SPECIAL <<
"";
QTest::newRow("ShowName: Play All file no extra names, written in one word") <<
"/mnt/fields2/torrents/[Coalgirls]_Nekomonogatari_(1920x1080_Blu-ray_FLAC)/[Coalgirls]_Nekomonogatari_Playall_(1920x1080_Blu-ray_FLAC)_[3DAE1544].mkv" <<
"[Coalgirls]" <<
"Nekomonogatari" <<
"Playall" <<
VideoFile::SPECIAL <<
"";
QTest::newRow("ShowName: Number in Show name") <<
"/tmp/Evangelion_1.0_You_Are_[Not]_Alone_(1080p)_[@Home]" <<
"" << // TODO take [@Home]
"Evangelion" <<
"1" <<
1.f <<
""; // TODO take You Are [Not] Alone
QTest::newRow("ShowName: Showname is ED, real name in Parent Directory") <<
"/[Kuroi Raws] Higashi no Eden (BD 1920x1080 H264 AC-3 5.1ch)/[Kuroi Raws] ED (BD 1920x1080 H264 AC-3 5.1ch) [533BC43C].mkv" <<
"[Kuroi Raws]" <<
"Higashi no Eden" <<
"ED" <<
VideoFile::SPECIAL <<
"";
QTest::newRow("ShowName: show name in Parent Directory") <<
"/[Kuroi Raws] Higashi no Eden (BD 1920x1080 H264 AC-3 5.1ch)/[Kuroi Raws] Episode 01 (BD 1920x1080 H264 AC-3 5.1ch) [533BC43C].mkv" <<
"[Kuroi Raws]" <<
"Higashi no Eden" <<
"Episode 01" <<
1.f <<
"";
// prown to error: Neon Genesis EvangelionDirectors Cut
QTest::newRow("ShowName: don't append Episodename to show name when number is removed") <<
"/mnt/fields1/torrents/Neon Genesis Evangelion/Neon Genesis Evangelion TV/Directors Cut/ Neon Genesis Evangelion 21 Directors Cut (R2DVD x264 720x480 AC3) .mkv" <<
"" <<
"Neon Genesis Evangelion" <<
"21" <<
21.f <<
"Directors Cut";
QTest::newRow("ShowName: contains word starting with EX (an episode start sign)") <<
"/mnt/fields2/torrents/[Coalgirls]_Serial_Experiments_Lain_(1520x1080_Blu-Ray_FLAC)/[Coalgirls]_Serial_Experiments_Lain_01_(1520x1080_Blu-Ray_FLAC)_[573CDDD6].mkv" <<
"[Coalgirls]" <<
"Serial Experiments Lain" <<
"01" <<
1.f <<
"";
QTest::newRow("Number: numbered OVA") <<
"/mnt/fields2/[Commie] Teekyuu 2 [BD 720p AAC]/[Commie] Teekyuu - OVA 1 [BD 720p AAC] [58F19BF2].mkv" <<
"[Commie]" <<
"Teekyuu OVA" <<
"OVA 1" <<
1.f <<
"";
QTest::newRow("Number: letter after OP/ED") <<
"/mnt/fields2/[Coalgirls]_Monogatari_Series_Second_Season_(1920x1080_Blu-ray_FLAC)/Arc 01 Nekomonogatari Shiro/[Coalgirls]_Nekomonogatari_Shiro_OPa_(1920x1080_Blu-ray_FLAC)_[D306F77E].mkv" <<
"[Coalgirls]" <<
"Nekomonogatari Shiro" <<
"OPa" <<
VideoFile::SPECIAL <<
"";
// TODO
QTest::newRow("Number: Creditless OP/ED") <<
"/mnt/fields2/Plastic Nee-san/[grimf] Plastic Nee-san Creditless ED (BD720p).mkv" <<
"[grimf]" <<
"Plastic Nee-san" <<
"Creditless ED" <<
VideoFile::SPECIAL <<
"";
}
void MovieFileTest::testPathParsing() {
QFETCH(QString, path);
QFETCH(QString, releaseGroup);
QFETCH(QString, showName);
QFETCH(QString, episodeNumber);
QFETCH(float, numericEpisodeNumber);
QFETCH(QString, episodeName);
const VideoFile m(path);
QCOMPARE(m.releaseGroup, releaseGroup);
QCOMPARE(m.showName, showName);
QCOMPARE(m.episodeNumber, episodeNumber);
QCOMPARE(m.numericEpisodeNumber(), numericEpisodeNumber);
QCOMPARE(m.episodeName, episodeName);
}
void MovieFileTest::testCommandExists() {
QVERIFY(true == SystemUtils::commandExists("command"));
QVERIFY(false == SystemUtils::commandExists("alsdhadhaasghoaishknasflkhasdfkljkashf")); // let's hope nobody installed this
}
void MovieFileTest::testCommonSliceInStrings_data() {
QTest::addColumn<QStringList>("strings");
QTest::addColumn<QString>("commonSlice");
QTest::newRow("caseinsensitive, prefix and postfix") <<
(QStringList() << "Bakemonogatari" << "Nisemonogatari" << "Nekomonogatari black" << "Monogatari Series: Second Season") <<
"monogatari";
}
void MovieFileTest::testCommonSliceInStrings() {
QFETCH(QStringList, strings);
QFETCH(QString, commonSlice);
QCOMPARE(Utils::commonSliceInStrings(strings).toLower(), commonSlice.toLower());
}
void MovieFileTest::qstringEcodingSize() {
QVERIFY(QString("☆☆☆").toUtf8().size() != QString("☆☆☆").toLatin1().size());
QVERIFY(QString("☆☆☆").toUtf8().size() > 3);
QVERIFY(QString("☆☆☆").size() == 3);
QVERIFY(QString("☆☆☆").toLatin1().size() == 3);
}
QTEST_APPLESS_MAIN(MovieFileTest)
#include "tst_moviefiletest.moc"