예제 #1
0
 def search_again(self):
     _fields = {
         'type': self.media_type,
         'title': ucli.get_field('query', necessary=True)}
     if self.is_movie:
         _fields['year'] = ucli.get_field('year', default=self.CURRENT_YEAR)
     else:
         _fields['season'] = ucli.get_field('season', default='1')
         _fields['episode'] = 1
     return self.search(**_fields)
예제 #2
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]
예제 #3
0
    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