import os
import re
import sys
import shutil
from autoprocess import autoProcessTV, autoProcessTVSR, sonarr, radarr
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor


def getHost(host='localhost', port=8080, ssl=False):
    protocol = "https://" if ssl else "http://"
    return protocol + host + ":" + str(port) + "/"


log = getLogger("qBittorrentPostProcess")

log.info("qBittorrent post processing started.")

if len(sys.argv) != 7:
    log.error(
        "Not enough command line parameters present, are you launching this from qBittorrent?"
    )
    log.error(
        "#Args: %L %T %R %F %N %I Category, Tracker, RootPath, ContentPath , TorrentName, InfoHash"
    )
    log.error("Length was %s" % str(len(sys.argv)))
    log.error(str(sys.argv[1:]))
    sys.exit(1)

try:
Example #2
0
                output[newpath] = filepath
                log.info("Copying %s to %s." % (filepath, newpath))
    return output


def restoreSubs(subs, log):
    for k in subs:
        try:
            os.rename(k, subs[k])
            log.info("Restoring %s to %s." % (k, subs[k]))
        except:
            os.remove(k)
            log.exception("Unable to restore %s, deleting." % (k))


log = getLogger("RadarrPostProcess")

log.info("Radarr extra script post processing started.")

if os.environ.get('radarr_eventtype') == "Test":
    sys.exit(0)

settings = ReadSettings()

log.debug(os.environ)

try:
    inputfile = os.environ.get('radarr_moviefile_path')
    original = os.environ.get('radarr_moviefile_scenename')
    imdbid = os.environ.get('radarr_movie_imdbid')
    tmdbid = os.environ.get('radarr_movie_tmdbid')
Example #3
0
#!/usr/bin/env python3

import os
import sys
from autoprocess import autoProcessTV, autoProcessTVSR, sonarr, radarr
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor

log = getLogger("SABPostProcess")

log.info("SAB post processing started.")

if len(sys.argv) < 8:
    log.error("Not enough command line parameters specified. Is this being called from SAB?")
    sys.exit(1)

# SABnzbd argv:
# 1 The final directory of the job (full path)
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2


def progressOutput(timecode, debug):
    print("%d%%" % timecode)

Example #4
0
        if len(split) > 1:
            path_mapping[split[0].strip()] = split[1].strip()

sys.path.insert(0, MP4folder)
try:
    from resources.readsettings import ReadSettings
    from resources.mediaprocessor import MediaProcessor
    from resources.log import getLogger
    from autoprocess import autoProcessMovie, autoProcessTV, autoProcessTVSR, sonarr, radarr
except ImportError:
    print("[ERROR] Wrong path to sickbeard_mp4_automator: " + os.environ['NZBPO_MP4_FOLDER'])
    print("[ERROR] %s" % traceback.print_exc())
    sys.exit(1)

# Setup Logging
log = getLogger("NZBGetPostProcess", MP4folder)

# Determine if conversion will take place
shouldConvert = (os.environ['NZBPO_SHOULDCONVERT'].lower() in ("yes", "true", "t", "1"))


def progressOutput(timecode, debug):
    log.info(timecode)
    log.debug(debug)


if 'NZBOP_SCRIPTDIR' in os.environ and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
    log.info("Script triggered from NZBGet (11.0 or later).")

    path = os.environ['NZBPP_DIRECTORY']  # Path to NZB directory
    nzb = os.environ['NZBPP_NZBFILENAME']  # Original NZB name
Example #5
0
import logging
import tmdbsimple as tmdb
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor
from resources.metadata import Metadata, MediaType
from resources.postprocess import PostProcessor
from resources.extensions import tmdb_api_key
from converter.avcodecs import audio_codec_list, video_codec_list, subtitle_codec_list, attachment_codec_list

if sys.version[0] == "3":
    raw_input = input

os.environ["REGEX_DISABLED"] = "1"  # Fixes Toilal/rebulk#20

log = getLogger("MANUAL")

logging.getLogger("subliminal").setLevel(logging.CRITICAL)
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("enzyme").setLevel(logging.WARNING)
logging.getLogger("qtfaststart").setLevel(logging.CRITICAL)

log.info("Manual processor started.")

settings = None


class MediaTypes(enum.Enum):
    @classmethod
    def descriptors(cls):
        return {
Example #6
0
import os
import re
import sys
import shutil
from autoprocess import autoProcessTV, autoProcessMovie, autoProcessTVSR, sonarr, radarr
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor

log = getLogger("uTorrentPostProcess")

log.info("uTorrent post processing started.")

# Args: %L %T %D %K %F %I Label, Tracker, Directory, single|multi, NameofFile(if single), InfoHash


def getHost(host='localhost', port=8080, ssl=False):
    protocol = "https://" if ssl else "http://"
    return protocol + host + ":" + str(port) + "/"


def _authToken(session=None, host=None, username=None, password=None):
    auth = None
    if not session:
        session = requests.Session()
    response = session.get(host + "gui/token.html", auth=(username, password), verify=False, timeout=30)
    if response.status_code == 200:
        auth = re.search("<div.*?>(\S+)<\/div>", response.text).group(1)
    else:
        log.error("Authentication Failed - Status Code " + response.status_code + ".")
Example #7
0
#!/usr/bin/env python3
import os
import sys
import json
import urllib
import struct
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.metadata import MediaType
from resources.mediaprocessor import MediaProcessor
from urllib import request

log = getLogger("SickbeardPostProcess")

log.info("Sickbeard extra script post processing started.")

try:
    settings = ReadSettings()

    if len(sys.argv) > 4:
        inputfile = sys.argv[1]
        original = sys.argv[2]
        tvdb_id = int(sys.argv[3])
        season = int(sys.argv[4])
        episode = int(sys.argv[5])

        log.debug("Input file: %s." % inputfile)
        log.debug("Original name: %s." % original)
        log.debug("TVDB ID: %s." % tvdb_id)
        log.debug("Season: %s episode: %s." % (season, episode))
Example #8
0
                output[newpath] = filepath
                log.info("Copying %s to %s." % (filepath, newpath))
    return output


def restoreSubs(subs, log):
    for k in subs:
        try:
            os.rename(k, subs[k])
            log.info("Restoring %s to %s." % (k, subs[k]))
        except:
            os.remove(k)
            log.exception("Unable to restore %s, deleting." % (k))


log = getLogger("SonarrPostProcess")

log.info("Sonarr extra script post processing started.")

if os.environ.get('sonarr_eventtype') == "Test":
    sys.exit(0)

settings = ReadSettings()

log.debug(os.environ)

try:
    inputfile = os.environ.get('sonarr_episodefile_path')
    original = os.environ.get('sonarr_episodefile_scenename')
    tvdb_id = int(os.environ.get('sonarr_series_tvdbid'))
    imdb_id = os.environ.get('sonarr_series_imdbid')
Example #9
0
#!/usr/bin/env python3

import os
import sys
import re
from autoprocess import autoProcessTV, autoProcessMovie, autoProcessTVSR, sonarr, radarr
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor
from resources.log import getLogger
from deluge_client import DelugeRPCClient
import shutil

log = getLogger("DelugePostProcess")

log.info("Deluge post processing started.")

try:
    settings = ReadSettings()
    categories = [settings.deluge['sb'], settings.deluge['cp'], settings.deluge['sonarr'], settings.deluge['radarr'], settings.deluge['sr'], settings.deluge['bypass']]
    remove = settings.deluge['remove']

    if len(sys.argv) < 4:
        log.error("Not enough command line parameters present, are you launching this from deluge?")
        sys.exit(1)

    path = str(sys.argv[3])
    torrent_name = str(sys.argv[2])
    torrent_id = str(sys.argv[1])
    delete_dir = None
    path_mapping = settings.deluge['path-mapping']
Example #10
0
#!/usr/bin/env python3

import sys
import os
import logging
from resources.log import getLogger
from resources.readsettings import ReadSettings
from resources.mediaprocessor import MediaProcessor
from resources.metadata import MediaType

log = getLogger("CouchPotatoPostProcess")

log.info('MP4 Automator - Post processing script initialized')

try:
    settings = ReadSettings()
    mp = MediaProcessor(settings)

    imdbid = sys.argv[1]
    inputfile = sys.argv[2]
    original = sys.argv[3]

    log.debug("IMDBID: %s." % imdbid)
    log.debug("Input file path: %s." % inputfile)
    log.debug("Original file name: %s." % original)

    success = mp.fullprocess(inputfile,
                             MediaType.Movie,
                             imdbid=imdbid,
                             original=original)
    log.info("Processor returned %s." % success)