Skip to content

Commit 6951cf4

Browse files
committed
Classifier improvements
1 parent b98f183 commit 6951cf4

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

internal/classifier/classifier.core.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ workflows:
1414
- if_else:
1515
condition:
1616
and:
17-
- "torrent.files.map(f, f.fileType == fileType.audio ? f.size : - f.size).sum() > 50*mb"
17+
- "torrent.files.map(f, f.extension in extensions.audio ? f.size : - f.size).sum() > 50*mb"
1818
- or:
1919
- "torrent.baseName.matches(keywords.audiobook)"
2020
- "torrent.files.filter(f, f.extension in extensions.audiobook).size() > 0"
@@ -40,19 +40,22 @@ workflows:
4040
- "torrent.files.map(f, f.extension in extensions.music ? f.size : - f.size).sum() > 0"
4141
- and:
4242
- "torrent.baseName.matches(keywords.music)"
43-
- "torrent.files.map(f, f.fileType == fileType.audio ? f.size : - f.size).sum() > 0"
43+
- "torrent.files.map(f, f.extension in extensions.audio ? f.size : - f.size).sum() > 0"
4444
if_action:
4545
set_content_type: music
4646
else_action: unmatched
4747
# match software:
4848
- if_else:
49-
condition: "torrent.files.map(f, f.fileType == fileType.software ? f.size : - f.size).sum() > 0"
49+
condition: "torrent.files.map(f, f.extension in extensions.software ? f.size : - f.size).sum() > 0"
5050
if_action:
5151
set_content_type: software
5252
else_action: unmatched
5353
# match xxx:
5454
- if_else:
55-
condition: "([torrent.baseName] + torrent.files.map(f, f.basePath)).join(' ').matches(keywords.xxx)"
55+
condition:
56+
and:
57+
- "torrent.files.map(f, (f.extension in extensions.video || f.extension in extensions.image) ? f.size : - f.size).sum() > 0"
58+
- "([torrent.baseName] + torrent.files.map(f, f.basePath)).join(' ').matches(keywords.xxx)"
5659
if_action:
5760
set_content_type: xxx
5861
else_action: unmatched
@@ -78,7 +81,7 @@ workflows:
7881
condition:
7982
or:
8083
- "result.contentType in [contentType.movie, contentType.tv_show]"
81-
- "torrent.files.map(f, f.fileType == fileType.video ? f.size : - f.size).sum() > 100*mb"
84+
- "torrent.files.map(f, f.extension in extensions.video ? f.size : - f.size).sum() > 100*mb"
8285
if_action:
8386
find_match:
8487
# parse video-related attributes from the torrent name;
@@ -105,6 +108,16 @@ workflows:
105108
- "flags.delete_xxx && result.contentType == contentType.xxx"
106109
if_action: delete
107110
extensions:
111+
audio:
112+
- mp3
113+
- wav
114+
- flac
115+
- aac
116+
- ogg
117+
- m4a
118+
- m4b
119+
- mid
120+
- dsf
108121
audiobook:
109122
- m4b
110123
comic:
@@ -128,6 +141,18 @@ extensions:
128141
- odt
129142
- pdf
130143
- rtf
144+
image:
145+
- jpg
146+
- jpeg
147+
- png
148+
- gif
149+
- bmp
150+
- svg
151+
- dds
152+
- psd
153+
- tif
154+
- tiff
155+
- ico
131156
music:
132157
- ape
133158
- dsf
@@ -149,6 +174,19 @@ extensions:
149174
- pkg
150175
- rpm
151176
- sh
177+
video:
178+
- mp4
179+
- mkv
180+
- avi
181+
- iso
182+
- mov
183+
- wmv
184+
- flv
185+
- m4v
186+
- mpg
187+
- mpeg
188+
- ts
189+
- vob
152190
keywords:
153191
audiobook:
154192
- audiobooks?

internal/model/file_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ var extensionToFileTypeMap = map[string]FileType{
109109
"m4v": FileTypeVideo,
110110
"mpg": FileTypeVideo,
111111
"mpeg": FileTypeVideo,
112+
"ts": FileTypeVideo,
112113
"vob": FileTypeVideo,
113114
}
114115

0 commit comments

Comments
 (0)