コード例 #1
0
    def add(self, args):
        _fields = {}

        if 'link' in args:
            try:
                args['title'] = self.TITLE_LINK_REGEX.search(
                    args['link']).group(1)
            except AttributeError:
                raise TVShowsTrackerError((
                    f"Couldn't find {self.TITLE_LINK_REGEX} pattern "
                    f"in {args['link']} string"))
        for field_name in ['topic URL', 'title', 'air', 'link']:
            if field_name == 'air':
                _candidates = ['daily', 'weekly']
                ucli.header('Air:')
                ucli.print_candidates(_candidates)
                _fields['air'] = ucli.parse_selection(_candidates)
                continue
            _field = ucli.get_field(
                field_name,
                prefill=args[field_name] if field_name in args else False,
                necessary=True)
            if field_name == 'topic URL':
                _fields['tracker'], _fields['id'] = self.URL_REGEX.search(
                    _field).groups()
                continue
            if field_name == 'link':
                _fields['link'] = manager.get_path(_field)
                continue
            _fields[field_name] = _field

        topic = self.db.topics.insert(**_fields)
        return self.db.topics[topic]
コード例 #2
0
ファイル: videonamer.py プロジェクト: justfdot/videonamer
    def search(self, **params):

        self.media_type = params['type']
        search_results = None

        try:
            search_results = ucli.gen_to_list(
                getattr(self, self.media_type)(**params))
            ucli.print_candidates(search_results)

        except MapiNotFoundException:
            ucli.info('Nothing found')
            ucli.print_options("[e]dit query, [m]anual, [s]kip, [q]uit")

        except MapiNetworkException:
            ucli.drop('Network error: couldn\'t retrieve data')

        else:
            ucli.print_options(
                "[RETURN] default, [e]dit query, [m]anual, [s]kip, [q]uit")

        finally:
            return ucli.parse_selection(
                search_results, {
                    'e': self.search_again,
                    'm': self.get_metadata_manual})
コード例 #3
0
 def track_tvshow(self):
     ucli.info('Would you like to track this TV Show?')
     ucli.print_options('[RETURN] to confirm or [s]kip this step')
     if ucli.parse_selection(None):
         from tvshows import tvshows
         tvshows.add({
             'link': self.linkpath,
             'title': self.metadata['title']
         })
コード例 #4
0
ファイル: videonamer.py プロジェクト: justfdot/videonamer
 def create_link(self, path_to_file, linkname):
     ucli.header('Linkname:', linkname)
     ucli.print_options('[RETURN] to confirm or [e]dit the linkname')
     linkname = ucli.parse_selection(
             [linkname], {
                 'e': (ucli.inline_prompt, 'New Linkname: ', linkname)})
     self.linkpath = os.path.join(self.LINKS_DIR, linkname)
     try:
         os.symlink(path_to_file, self.linkpath)
         ucli.header('Symlink:', self.linkpath)
         ucli.header('      ->', path_to_file)
         return True
     except FileExistsError:
         return ucli.info('File already exists. Skipping')
コード例 #5
0
ファイル: videonamer.py プロジェクト: justfdot/videonamer
    def get_metadata_manual(self):
        _candidates = ['movie', 'episode']
        if not self.is_movie:
            _candidates = _candidates[::-1]
        ucli.print_candidates(_candidates)
        ucli.print_options("[RETURN] default, [q]uit")
        self.media_type = ucli.parse_selection(_candidates)

        if self.is_movie:
            metadata = {
                'title': ucli.get_field('title', necessary=True)}
        else:
            metadata = {
                'series': ucli.get_field('title', necessary=True),
                'season': ucli.get_field('season', default='1')}

        metadata['year'] = ucli.get_field('year', default=self.CURRENT_YEAR)

        return metadata