forked from clinton-hall/nzbToMedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nzbToMediaSceneExceptions.py
35 lines (25 loc) · 994 Bytes
/
nzbToMediaSceneExceptions.py
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
# System imports
import os
import logging
# Custom imports
from nzbToMediaUtil import iterate_media_files
Logger = logging.getLogger()
def process_all_exceptions(name, dirname):
for group, exception in __customgroups__.items():
if not (group in name or group in dirname):
continue
process_exception(exception, name, dirname)
def process_exception(exception, name, dirname):
for parentDir, filename in iterate_media_files(dirname):
exception(filename, parentDir)
def process_qoq(filename, dirname):
Logger.debug("Reversing the file name for a QoQ release %s", filename)
head, fileExtension = os.path.splitext(os.path.basename(filename))
newname = head[::-1]
newfile = newname + fileExtension
newfilePath = os.path.join(dirname, newfile)
os.rename(filename, newfilePath)
Logger.debug("New file name is %s", newfile)
# dict for custom groups
# we can add more to this list
__customgroups__ = {'Q o Q': process_qoq}