import json
import urllib
from readSettings import ReadSettings
from tvdb_mp4 import Tvdb_mp4
from mkvtomp4 import MkvtoMp4
from extensions import valid_output_extensions

settings = ReadSettings(os.path.dirname(sys.argv[0]), "tvdb_mp4.ini")

if len(sys.argv) > 4:
    path = str(sys.argv[1]).replace("\\","\\\\").replace("\\\\\\\\","\\\\")
    extension = os.path.splitext(path)[1][1:]
    tvdb_id = int(sys.argv[3])
    season = int(sys.argv[4])
    episode  = int(sys.argv[5])

    convert = MkvtoMp4(path, settings.ffmpeg, settings.ffprobe, settings.delete, settings.output_extension, settings.output_dir)
    if extension not in valid_output_extensions:
        path = convert.output
        try:
            refresh = json.load(urllib.urlopen(settings.getRefreshURL(tvdb_id)))
            for item in refresh:
                print refresh[item]
        except IOError:
            print "Couldn't refresh Sickbeard, check your tvdb_mp4.ini settings"
    tagmp4 = Tvdb_mp4(tvdb_id, season, episode)
    tagmp4.setHD(convert.width, convert.height)
    tagmp4.writeTags(path)
else:
    print "Not enough command line arguments present " + str(len(sys.argv))
    sys.exit()
                    tagmp4.setHD(output['x'], output['y'])
                    tagmp4.writeTags(output['output'], settings.artwork,
                                     settings.thumbnail)
                except:
                    log.error("Unable to tag file")

            # Copy to additional locations
            output_files = converter.replicate(output['output'])

            # run any post process scripts
            if settings.postprocess:
                post_processor = PostProcessor(output_files, log)
                post_processor.setTV(tvdb_id, season, episode)
                post_processor.run_scripts()

            try:
                refresh = json.load(
                    urllib.urlopen(settings.getRefreshURL(tvdb_id)))
                for item in refresh:
                    log.debug(refresh[item])
            except (IOError, ValueError):
                log.exception(
                    "Couldn't refresh Sickbeard, check your autoProcess.ini settings."
                )

            plex.refreshPlex(settings, 'show', log)

else:
    log.error("Not enough command line arguments present %s." % len(sys.argv))
    sys.exit()
Ejemplo n.º 3
0
                log.info("Tagging %s with ID %s season %s episode %s." % (inputfile, tvdb_id, season, episode))
                tagmp4 = Tvdb_mp4(tvdb_id, season, episode, original, language=settings.taglanguage)
                tagmp4.setHD(output['x'], output['y'])
                tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail)

            # QTFS
            if settings.relocate_moov:
                converter.QTFS(output['output'])

            # Copy to additional locations
            output_files = converter.replicate(output['output'])

            # run any post process scripts
            if settings.postprocess:
                post_processor = PostProcessor(output_files, log)
                post_processor.setTV(tvdb_id, season, episode)
                post_processor.run_scripts()

            try:
                refresh = json.load(urllib.urlopen(settings.getRefreshURL(tvdb_id)))
                for item in refresh:
                    log.debug(refresh[item])
            except (IOError, ValueError):
                log.exception("Couldn't refresh Sickbeard, check your autoProcess.ini settings.")

            plex.refreshPlex(settings, 'show', log)

else:
    log.error("Not enough command line arguments present %s." % len(sys.argv))
    sys.exit()
Ejemplo n.º 4
0
                             settings.thumbnail)

        #QTFS
        if settings.relocate_moov:
            converter.QTFS(output['output'])

        # Copy to additional locations
        output_files = converter.replicate(output['output'])

        # run any post process scripts
        if settings.postprocess:
            post_processor = PostProcessor(output_files, log)
            post_processor.setTV(tvdb_id, season, episode)
            post_processor.run_scripts()

        try:
            refresh = json.load(urllib.urlopen(
                settings.getRefreshURL(tvdb_id)))
            for item in refresh:
                log.debug(refresh[item])
        except (IOError, ValueError):
            log.exception(
                "Couldn't refresh Sickbeard, check your autoProcess.ini settings."
            )

        plex.refreshPlex(settings, 'show', log)

else:
    log.error("Not enough command line arguments present %s." % len(sys.argv))
    sys.exit()