-
Notifications
You must be signed in to change notification settings - Fork 278
/
auto_post_processor.py
60 lines (49 loc) · 1.96 KB
/
auto_post_processor.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
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
# coding=utf-8
# Author: Nic Wolfe <nic@wolfeden.ca>
#
# This file is part of Medusa.
#
# Medusa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Medusa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Medusa. If not, see <http://www.gnu.org/licenses/>.
"""Post Processor Module."""
from __future__ import unicode_literals
import logging
import os.path
from builtins import object
from medusa import app
logger = logging.getLogger(__name__)
class PostProcessor(object):
"""Post Processor Scheduler Action."""
def __init__(self):
"""Init method."""
self.amActive = False
def run(self, force=False):
"""Run the postprocessor.
:param force: Forces postprocessing run
:type force: bool
"""
from medusa import process_tv
self.amActive = True
try:
if not os.path.isdir(app.TV_DOWNLOAD_DIR):
logger.error(u"Automatic post-processing attempted but directory doesn't exist: {folder}",
folder=app.TV_DOWNLOAD_DIR)
return
if not (force or os.path.isabs(app.TV_DOWNLOAD_DIR)):
logger.error(u'Automatic post-processing attempted but directory is relative '
u'(and probably not what you really want to process): {folder}',
folder=app.TV_DOWNLOAD_DIR)
return
process_tv.ProcessResult(app.TV_DOWNLOAD_DIR, app.PROCESS_METHOD).process(force=force)
finally:
self.amActive = False