Пример #1
0
def main(_):
    # REVIEW josephz: This paradigm was copied from inference-hack.py
    # initialize_globals()

    sample_dir = "sample"
    # sample_names = ["new_test"]
    sample_names = ["rolling_in_the_deep"]
    post_processor = PostProcessor()
    post_processor.load_weights("weights.h5")
    # sample_names = ["perfect_features"]
    # sample_names = ["rolling_in_the_one_more_time"]
    for sample_name in sample_names:
        console.h1("Processing %s" % sample_name)
        console.time("total processing for " + sample_name)
        sample_path = sample_dir + "/" + sample_name

        style_path = sample_path + "/style.mp3"
        content_path = sample_path + "/content.mp3"
        stylized_img_path = sample_path + "/stylized.png"
        stylized_img_raw_path = sample_path + "/stylized_raw.png"
        stylized_audio_path = sample_path + "/stylized.mp3"
        stylized_audio_raw_path = sample_path + "/stylized_raw.mp3"

        # Read style audio to spectrograms.
        style_audio, style_sample_rate = conversion.file_to_audio(style_path)
        style_img, style_phase = conversion.audio_to_spectrogram(
            style_audio, fft_window_size=1536)

        # Read content audio to spectrograms.
        content_audio, content_sample_rate = conversion.file_to_audio(
            content_path)
        content_img, content_phase = conversion.audio_to_spectrogram(
            content_audio, fft_window_size=1536)
        stylized_img_raw, stylized_img = stylize(content_img, style_img,
                                                 content_phase, style_phase,
                                                 content_path, style_path,
                                                 post_processor)

        # Save raw stylized spectrogram and audio.
        stylized_audio_raw = conversion.amplitude_to_audio(
            stylized_img_raw,
            fft_window_size=1536,
            phase_iterations=15,
            phase=content_phase)
        conversion.image_to_file(stylized_img_raw, stylized_img_raw_path)
        conversion.audio_to_file(stylized_audio_raw, stylized_audio_raw_path)

        # Save post-processed stylized spectrogram and audio.
        stylized_audio = conversion.amplitude_to_audio(stylized_img,
                                                       fft_window_size=1536,
                                                       phase_iterations=15,
                                                       phase=content_phase)
        # np.save("stylized_img.npy", stylized_img)
        # np.save("content_phase.npy", content_phase)
        conversion.image_to_file(stylized_img, stylized_img_path)
        conversion.audio_to_file(stylized_audio, stylized_audio_path)

        console.timeEnd("total processing for " + sample_name)
        console.info("Finished processing %s; saved to %s" %
                     (sample_name, stylized_audio_path))
Пример #2
0
def processFile(inputfile, tagdata, stop_event, relativePath=None):
    
    # Gather tagdata
    if tagdata is False:
        return  # This means the user has elected to skip the file
    elif tagdata is None:
        tagmp4 = None  # No tag data specified but convert the file anyway
    elif tagdata[0] is 1:
        imdbid = tagdata[1]
        tagmp4 = tmdb_mp4(imdbid, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s" % (tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing movie")
    elif tagdata[0] is 2:
        tmdbid = tagdata[1]
        tagmp4 = tmdb_mp4(tmdbid, True, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s" % (tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing movie")
    elif tagdata[0] is 3:
        tvdbid = int(tagdata[1])
        season = int(tagdata[2])
        episode = int(tagdata[3])
        tagmp4 = Tvdb_mp4(tvdbid, season, episode, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s Season %02d Episode %02d - %s" % (tagmp4.show.encode(sys.stdout.encoding, errors='ignore'), int(tagmp4.season), int(tagmp4.episode), tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing TV episode")

    # Process
    if MkvtoMp4(settings, logger=log).validSource(inputfile):
        converter = MkvtoMp4(settings, logger=log)
        output = converter.process(inputfile, stop_event, True)
        if output:
            if tagmp4 is not None:
                try:
                    tagmp4.setHD(output['x'], output['y'])
                    tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail)
                except Exception as e:
                    print("There was an error tagging the file")
                    print(e)
            if settings.relocate_moov:
                converter.QTFS(output['output'])
            output_files = converter.replicate(output['output'], relativePath=relativePath)
            if settings.postprocess:
                post_processor = PostProcessor(output_files)
                if tagdata:
                    if tagdata[0] is 1:
                        post_processor.setMovie(tagdata[1])
                    elif tagdata[0] is 2:
                        post_processor.setMovie(tagdata[1])
                    elif tagdata[0] is 3:
                        post_processor.setTV(tagdata[1], tagdata[2], tagdata[3])
                post_processor.run_scripts()
            print("Conversion Successful. File: %s" % (output))
Пример #3
0
def processFile(inputfile, tagdata, converter, info=None, relativePath=None):
    # Process
    info = info if info else converter.isValidSource(inputfile)
    if not info:
        return

    # Gather tagdata
    if tagdata is False:
        return  # This means the user has elected to skip the file
    elif tagdata is None:
        tagmp4 = None  # No tag data specified but convert the file anyway
    elif tagdata[0] == 1:
        imdbid = tagdata[1]
        tagmp4 = tmdb_mp4(imdbid, language=settings.taglanguage, logger=log)
        safePrint("Processing %s" % (tagmp4.title))
    elif tagdata[0] == 2:
        tmdbid = tagdata[1]
        tagmp4 = tmdb_mp4(tmdbid, True, language=settings.taglanguage, logger=log)
        safePrint("Processing %s" % (tagmp4.title))
    elif tagdata[0] == 3:
        tvdbid = int(tagdata[1])
        season = int(tagdata[2])
        episode = int(tagdata[3])
        tagmp4 = Tvdb_mp4(tvdbid, season, episode, language=settings.taglanguage, logger=log, tmdbid=True)
        safePrint("Processing %s Season %02d Episode %02d - %s" % (tagmp4.show, int(tagmp4.season), int(tagmp4.episode), tagmp4.title))
    elif tagdata[0] == 4:
        tagNfoFile = tagdata[1]
        tree = tagdata[2]
        tagmp4 = home_mp4(tagNfoFile, tree, logger=log)
        safePrint("Processing %s" % (tagmp4.title))

    output = converter.process(inputfile, True)
    if output:
        if tagmp4 is not None and output['output_extension'] in valid_tagging_extensions:
            try:
                tagmp4.setHD(output['x'], output['y'])
                tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail)
            except Exception as e:
                log.exception("There was an error tagging the file")
                print("There was an error tagging the file")
                print(e)
        if settings.relocate_moov and output['output_extension'] in valid_tagging_extensions:
            converter.QTFS(output['output'])
        output_files = converter.replicate(output['output'], relativePath=relativePath)
        if settings.postprocess:
            post_processor = PostProcessor(output_files)
            if tagdata:
                if tagdata[0] == 1:
                    post_processor.setMovie(tagdata[1])
                elif tagdata[0] == 2:
                    post_processor.setMovie(tagdata[1])
                elif tagdata[0] == 3:
                    post_processor.setTV(tagdata[1], tagdata[2], tagdata[3])
            post_processor.run_scripts()
    else:
        log.error("File is not in the correct format")
Пример #4
0
 def test_render_only_recognized_url(self):
   url0 = "http://decoder0/path0"
   url1 = "http://decoder1/path1"
   decoder0_type = PostProcessor._type_for_decoder(self.decoder0)
   decoder1_type = PostProcessor._type_for_decoder(self.decoder1)
   data = [
       PostProcessor._make_data_element(decoder0_type, url0),
       PostProcessor._make_data_element(decoder1_type, url1)
   ]
   renderable_items = self.processor.renderable_items(data)
   self.assertEqual(2, len(renderable_items))
   self._assert_decoded_url_item(renderable_items[0], url0, self.decoder0)
   self._assert_decoded_url_item(renderable_items[1], url1, self.decoder1)
Пример #5
0
def processFile(inputfile, tagdata, relativePath=None):
    # Gather tagdata
    if tagdata is False:
        return  # This means the user has elected to skip the file
    elif tagdata is None:
        tagmp4 = None  # No tag data specified but convert the file anyway
    elif tagdata[0] is 1:
        imdbid = tagdata[1]
        tagmp4 = tmdb_mp4(imdbid, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s" % (tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing movie")
    elif tagdata[0] is 2:
        tmdbid = tagdata[1]
        tagmp4 = tmdb_mp4(tmdbid, True, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s" % (tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing movie")
    elif tagdata[0] is 3:
        tvdbid = int(tagdata[1])
        season = int(tagdata[2])
        episode = int(tagdata[3])
        tagmp4 = Tvdb_mp4(tvdbid, season, episode, language=settings.taglanguage, logger=log)
        try:
            print("Processing %s Season %02d Episode %02d - %s" % (tagmp4.show.encode(sys.stdout.encoding, errors='ignore'), int(tagmp4.season), int(tagmp4.episode), tagmp4.title.encode(sys.stdout.encoding, errors='ignore')))
        except:
            print("Processing TV episode")

    # Process
    if MkvtoMp4(settings, logger=log).validSource(inputfile):
        converter = MkvtoMp4(settings, logger=log)
        output = converter.process(inputfile, True)
        if output:
            if tagmp4 is not None and output['output_extension'] in valid_tagging_extensions:
                try:
                    tagmp4.setHD(output['x'], output['y'])
                    tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail)
                except Exception as e:
                    print("There was an error tagging the file")
                    print(e)
            if settings.relocate_moov and output['output_extension'] in valid_tagging_extensions:
                converter.QTFS(output['output'])
            output_files = converter.replicate(output['output'], relativePath=relativePath)
            if settings.postprocess:
                post_processor = PostProcessor(output_files)
                if tagdata:
                    if tagdata[0] is 1:
                        post_processor.setMovie(tagdata[1])
                    elif tagdata[0] is 2:
                        post_processor.setMovie(tagdata[1])
                    elif tagdata[0] is 3:
                        post_processor.setTV(tagdata[1], tagdata[2], tagdata[3])
                post_processor.run_scripts()
Пример #6
0
  def test_render_only_text(self):
    data = [
        PostProcessor._make_data_element(PostProcessor._TEXT_TYPE, "text0"),
        PostProcessor._make_data_element(PostProcessor._TEXT_TYPE, "text1")
    ]
    renderable_items = self.processor.renderable_items(data)
    # One paragraph should be returned.
    self.assertEqual(1, len(renderable_items))
    renderable_item = renderable_items[0]
    self.assertEqual(paragraph_item._PARAGRAPH_ITEM_TYPE, renderable_item.get_renderer_name())

    # The unrecognized URLs should be its children.
    paragraph_child_items = renderable_item.item.child_items
    self.assertEqual(2, len(paragraph_child_items))
    self._assert_text_item(paragraph_child_items[0], "text0")
    self._assert_text_item(paragraph_child_items[1], "text1")
Пример #7
0
    def process(self,
                inputfile,
                tagmp4=None,
                relativePath=None,
                original=None,
                fileno=[1, 1]):
        output_files = []

        if self.converter.validSource(inputfile) == True:
            self.tagInfo(tagmp4)

            output = self.converter.process(inputfile=inputfile,
                                            reportProgress=True,
                                            original=original)
            if output:
                # TAG
                if tagmp4 is not None:
                    try:
                        tagmp4.setHD(output['x'], output['y'])
                        tagmp4.writeTags(output['output'],
                                         self.settings.artwork,
                                         self.settings.thumbnail)
                    except:
                        self.log.exception(
                            "There was an error tagging the file")

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

                # REPLICATE
                output['tag'] = tagmp4
                output_files = self.converter.replicate(
                    output, relativePath=relativePath)

                # FINALIZE
                if self.settings.postprocess:  #and fileno[0] == fileno[1]:
                    post_processor = PostProcessor(output_files)
                    if tagmp4 is not None:
                        if tagmp4.provider == "imdb" or tagmp4.provider == "tmdb":
                            post_processor.setMovie(tagmp4.providerid)
                        elif tagmp4.provider == "tvdb":
                            post_processor.setTV(tagmp4.providerid,
                                                 tagmp4.season, tagmp4.episode)
                    post_processor.run_scripts()

        return output_files
Пример #8
0
def processFile(inputfile, tagdata, converter, info=None, relativePath=None):
    # Process
    info = info or converter.isValidSource(inputfile)
    if not info:
        log.debug("Invalid file %s." % inputfile)
        return

    if tagdata.mediatype == MediaType.Movie:
        log.info("Processing %s" % (tagdata.title))
    elif tagdata.mediatype == MediaType.TV:
        log.info("Processing %s Season %02d Episode %02d - %s" %
                 (tagdata.showname, int(tagdata.season), int(
                     tagdata.episode), tagdata.title))

    output = converter.process(inputfile, True)
    if output:
        if tagdata:
            try:
                tagdata.setHD(output['x'], output['y'])
                tagdata.writeTags(output['output'], settings.artwork,
                                  settings.thumbnail)
            except:
                log.exception("There was an error tagging the file")
        if settings.relocate_moov:
            converter.QTFS(output['output'])
        output_files = converter.replicate(output['output'],
                                           relativePath=relativePath)
        if settings.postprocess:
            post_processor = PostProcessor(output_files)
            if tagdata:
                if tagdata.mediatype == MediaType.Movie:
                    post_processor.setMovie(tagdata.tmdbid)
                elif tagdata.mediatype == MediaType.TV:
                    post_processor.setTV(tagdata.tmdbid, tagdata.season,
                                         tagdata.episode)
            post_processor.run_scripts()
    else:
        log.error(
            "There was an error processing file %s, no output data received" %
            inputfile)
                    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)
                except:
                    log.error("Unable to tag file")

            # 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()
        # Tag with metadata
        if settings.tagfile:
            log.info("Tagging %s with ID %s season %s episode %s." %
                     (inputfile, tvdb_id, season, episode))
            try:
                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)
            except:
                log.error("Unable to tag file")

        # 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()

        plex.refreshPlex(settings, 'show', log)
Пример #11
0
#!/usr/bin/env python
import conversion
import console
import numpy as np
from post_processor import PostProcessor

post_processor = PostProcessor()
post_processor.load_weights("weights.h5")

stylized = conversion.file_to_image("sample/rolling_in_the_deep/stylized.png")
content_harmonics = conversion.file_to_image("sample/rolling_in_the_deep/content.mp3.harmonics.png")
content_sibilants = conversion.file_to_image("sample/rolling_in_the_deep/content.mp3.harmonics.png")

stylized = post_processor.predict_unstacked(amplitude=stylized, harmonics=content_harmonics, sibilants=content_sibilants)

conversion.image_to_file(stylized, "/Users/ollin/Desktop/boop.png")
Пример #12
0
 def setUp(self):
   unittest.TestCase.setUp(self)
   self.decoder0 = TestDecoder("decoder0", "http://decoder0")
   self.decoder1 = TestDecoder("decoder1", "http://decoder1")
   self.processor = PostProcessor([self.decoder0, self.decoder1])
Пример #13
0
                # Then set that episode to monitored
                log.debug("Sending PUT request with following payload:")
                log.debug(str(sonarrepinfo))

                url = protocol + host + ":" + port + webroot + "/api/episode/" + str(
                    sonarrepinfo['id'])
                r = requests.put(url, json=sonarrepinfo, headers=headers)
                success = r.json()

                log.debug("PUT request returned:")
                log.debug(str(success))
                log.info(
                    "Sonarr monitoring information updated for episode %s." %
                    success['title'])
            else:
                log.error(
                    "Your Sonarr API Key can not be blank. Update autoProcess.ini."
                )
        except:
            log.exception("Sonarr monitor status update failed.")

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

        plex.refreshPlex(settings, 'show', log)
sys.exit(0)
    if MkvtoMp4(settings).validSource(inputfile):
        log.info('File is valid')
        output = converter.process(inputfile, original=original)

        # Tag with metadata
        if settings.tagfile:
            log.info('Tagging file with IMDB ID %s', imdbid)
            tagmp4 = tmdb_mp4(imdbid, original=original, language=settings.taglanguage)
            tagmp4.setHD(output['x'], output['y'])
            tagmp4.writeTags(output['output'], settings.artwork)

        #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.setMovie(imdbid)
            post_processor.run_scripts()

    else:
        log.info('File %s is invalid, ignoring' % inputfile)
except:
    log.exception('File processing failed: %s' % inputfile)

plex.refreshPlex(settings, 'movie', log)
Пример #15
0
class PostProcessorTest(unittest.TestCase):
  def setUp(self):
    unittest.TestCase.setUp(self)
    self.decoder0 = TestDecoder("decoder0", "http://decoder0")
    self.decoder1 = TestDecoder("decoder1", "http://decoder1")
    self.processor = PostProcessor([self.decoder0, self.decoder1])


  def _assert_element(self, element, expected_type, expected_value):
    self.assertEqual(expected_type, element["type"])
    self.assertEqual(expected_value, element["value"])

  def _assert_text_element(self, element, expected_text):
    self._assert_element(element, PostProcessor._TEXT_TYPE, expected_text)

  def _assert_unrecognized_url_element(self, element, expected_url):
    self._assert_element(element, PostProcessor._URL_TYPE, expected_url)

  def _assert_recognized_url_element(self, element, expected_url, expected_url_decoder):
    self.assertIn(expected_url_decoder.name(), element["type"])
    parsed_url = urlparse.urlparse(expected_url)
    expected_decoded_url = expected_url_decoder.decode_url(expected_url, parsed_url)
    self.assertEqual(expected_decoded_url, element["value"])


  def test_process_empty(self):
    processed_post = self.processor.process("")
    self.assertEqual(0, len(processed_post.data))
    self.assertEqual(0, len(processed_post.hash_tags))

    processed_post = self.processor.process("   ")
    self.assertEqual(0, len(processed_post.data))
    self.assertEqual(0, len(processed_post.hash_tags))

  def test_process_only_text(self):
    string = "text0 text1"
    processed_post = self.processor.process(string)
    self.assertEqual(1, len(processed_post.data))
    self._assert_text_element(processed_post.data[0], string)
    self.assertEqual(0, len(processed_post.hash_tags))

  def test_process_only_hash_tags(self):
    string = "#ht0 #ht1"
    processed_post = self.processor.process(string)
    self.assertSequenceEqual(["ht0", "ht1"], processed_post.hash_tags)
    self.assertEqual(0, len(processed_post.data))

  def test_process_only_unrecognized_urls(self):
    string = "http://url0 http://url1"
    processed_post = self.processor.process(string)
    self.assertEqual(2, len(processed_post.data))
    self._assert_unrecognized_url_element(processed_post.data[0], "http://url0")
    self._assert_unrecognized_url_element(processed_post.data[1], "http://url1")
    self.assertEqual(0, len(processed_post.hash_tags))

  def test_process_only_recognized_urls(self):
    url0 = "http://decoder0/path0"
    url1 = "http://decoder1/path1"
    string = "%s %s" % (url0, url1)
    processed_post = self.processor.process(string)
    self.assertEqual(2, len(processed_post.data))
    self._assert_recognized_url_element(processed_post.data[0], url0, self.decoder0)
    self._assert_recognized_url_element(processed_post.data[1], url1, self.decoder1)
    self.assertEqual(0, len(processed_post.hash_tags))


  def _assert_text_item(self, renderable_item, expected_text):
    self.assertEqual(RenderableItem.TEXT_TYPE, renderable_item.type)
    self.assertEqual(expected_text, renderable_item.item)

  def _assert_url_item(self, renderable_item, expected_url):
    self.assertEqual(RenderableItem.URL_TYPE, renderable_item.type)
    self.assertEqual(expected_url, renderable_item.item)

  def _assert_decoded_url_item(self, renderable_item, decoded_url, expected_decoder):
    expected_item = expected_decoder.item_for_rendering(decoded_url)
    self.assertEqual(expected_decoder.name(), renderable_item.get_renderer_name())
    self.assertEqual(expected_item, renderable_item.item)


  def test_render_empty(self):
    renderable_items = self.processor.renderable_items([])
    self.assertEqual(0, len(renderable_items))

  def test_render_only_text(self):
    data = [
        PostProcessor._make_data_element(PostProcessor._TEXT_TYPE, "text0"),
        PostProcessor._make_data_element(PostProcessor._TEXT_TYPE, "text1")
    ]
    renderable_items = self.processor.renderable_items(data)
    # One paragraph should be returned.
    self.assertEqual(1, len(renderable_items))
    renderable_item = renderable_items[0]
    self.assertEqual(paragraph_item._PARAGRAPH_ITEM_TYPE, renderable_item.get_renderer_name())

    # The unrecognized URLs should be its children.
    paragraph_child_items = renderable_item.item.child_items
    self.assertEqual(2, len(paragraph_child_items))
    self._assert_text_item(paragraph_child_items[0], "text0")
    self._assert_text_item(paragraph_child_items[1], "text1")

  def test_render_only_unrecognized_urls(self):
    data = [
        PostProcessor._make_data_element(PostProcessor._URL_TYPE, "http://url0"),
        PostProcessor._make_data_element(PostProcessor._URL_TYPE, "http://url1")
    ]
    renderable_items = self.processor.renderable_items(data)

    # One paragraph should be returned.
    self.assertEqual(1, len(renderable_items))
    renderable_item = renderable_items[0]
    self.assertEqual(paragraph_item._PARAGRAPH_ITEM_TYPE, renderable_item.get_renderer_name())

    # The unrecognized URLs should be its children.
    paragraph_child_items = renderable_item.item.child_items
    self.assertEqual(2, len(paragraph_child_items))
    self._assert_url_item(paragraph_child_items[0], "http://url0")
    self._assert_url_item(paragraph_child_items[1], "http://url1")

  def test_render_only_recognized_url(self):
    url0 = "http://decoder0/path0"
    url1 = "http://decoder1/path1"
    decoder0_type = PostProcessor._type_for_decoder(self.decoder0)
    decoder1_type = PostProcessor._type_for_decoder(self.decoder1)
    data = [
        PostProcessor._make_data_element(decoder0_type, url0),
        PostProcessor._make_data_element(decoder1_type, url1)
    ]
    renderable_items = self.processor.renderable_items(data)
    self.assertEqual(2, len(renderable_items))
    self._assert_decoded_url_item(renderable_items[0], url0, self.decoder0)
    self._assert_decoded_url_item(renderable_items[1], url1, self.decoder1)
Пример #16
0
    def callscript(self, message = None, group = None):

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

        sys.path.append(path)
        try:
            from readSettings import ReadSettings
            from mkvtomp4 import MkvtoMp4
            from tmdb_mp4 import tmdb_mp4
            from autoprocess import plex
            from post_processor import PostProcessor
        except ImportError:
            log.error('Path to script folder appears to be invalid.')
            return False

        settings = ReadSettings(path, "autoProcess.ini")
        converter = MkvtoMp4(settings)

        try:
            imdbid = group['library']['identifier']
        except:
            imdbid = group['identifier']

        moviefile = group['renamed_files']
        original = group['files']['movie'][0]

        success = False

        for inputfile in moviefile:
            try:
                log.info('Processing file: %s', inputfile)
                if MkvtoMp4(settings).validSource(inputfile):
                    log.info('File is valid')
                    output = converter.process(inputfile, original=original)

                    # Tag with metadata
                    if settings.tagfile:
                        log.info('Tagging file with IMDB ID %s', imdbid)
                        tagmp4 = tmdb_mp4(imdbid, original=original, language=settings.taglanguage)
                        tagmp4.setHD(output['x'], output['y'])
                        tagmp4.writeTags(output['output'], settings.artwork)

                    #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.setMovie(imdbid)
                        post_processor.run_scripts()

                    success = True
                else:
                    log.info('File is invalid')
            except:
                log.error('File processing failed: %s', (traceback.format_exc()))

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

        return success
Пример #17
0
@version: 
@Author: Aoru Xue
@Date: 2019-09-02 21:08:56
@LastEditors: Aoru Xue
@LastEditTime: 2019-09-04 19:22:18
'''
import torch
import torchvision
#from vgg_ssd import build_ssd_model
from TinySSD import TinySSD
from torchvision import transforms
#from transforms import *
from PIL import Image
from viz import draw_bounding_boxes
from post_processor import PostProcessor
post_process = PostProcessor()
transform = transforms.Compose([
    transforms.Resize((512, 512)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
# predict_transform = Compose([
#             Resize(300),
#             SubtractMeans([123, 117, 104]),
#             ToTensor()
#         ])
import numpy as np


def center_form_to_corner_form(locations):
    return np.concatenate([