Exemplo n.º 1
0
    def _handle_missing_title(self, parser, file_path) -> tuple:
        file_name = os.path.basename(file_path)

        if self._ingest_depth(file_path) > 0:

            # append the top most parent folder as the title, i.e "show/season 01/s01e01.mkv" would become "show - s01e01.mkv"
            file_path_split = file_path.split(os.sep)

            # possible parent directories
            parent_titles = [
                # "show - season 01/s01e01.mkv" would define title as "show - season 01"
                os.path.basename(
                    os.sep.join(
                        file_path_split[:-(self._ingest_depth(file_path))])),
                # "show/season 01/s01e01.mkv" would define title as "show - s01e01.mkv"
                '{} - {}'.format(
                    os.path.basename(
                        os.sep.join(file_path_split[:-(
                            self._ingest_depth(file_path))])), file_name),
            ]
            for parent_title in parent_titles:
                parent_parser = TVParser(parent_title)
                # define the title and merge the parent and the file parser matches
                if parent_parser.match and parent_parser.match['title']:
                    title = parent_parser.match['title']
                    parser.match.update(parent_parser.match)
                    return title, parser.match
            else:  # for/else
                logging.warning(
                    '[NO_MATCH_TITLE] Could not match nested file "{}"'.format(
                        file_path))
                return False, False
        else:
            logging.warning(
                '[NO_MATCH_TITLE] Could not match file without title "{}"'.
                format(file_path))
            return False, False
 def test_tv(self):
     for name, title, season, episode in self.tv_single_episode_tests:
         parser = TVParser(name)
         self.assertTrue(parser.is_match(title, season, episode),
                         '{} ({})'.format(name, parser.match))
Exemplo n.º 3
0
 def handle(self, *args, **options):
     parser = TVParser(options['title'])
     print(parser.match)
Exemplo n.º 4
0
 def test_tv(self):
     for name, title, season in self.tv_season_tests:
         parser = TVParser(name)
         self.assertTrue(parser.is_match(title, season),
                         '{} ({})'.format(name, parser.match))
Exemplo n.º 5
0
 def _get_parser(self, title: str):
     return TVParser(title)
Exemplo n.º 6
0
 def _get_parser(self, file_name):
     return TVParser(file_name)