Пример #1
0
    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})
Пример #2
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']
         })
Пример #3
0
def update(args, db):
    if args['TOPIC']:
        topic = db.get_topic(args['TOPIC'])
        ucli.info('Updating specified topic:', topic['title'])
        tracker = get_tracker_instance(topic['tracker'], db)
        tracker.update(topic)
    else:
        ucli.info(
            f"Updating {'all the' if args['all'] else 'scheduled'} topics")
        for tracker_name, topics in db.get_topics(args['all']):
            tracker = get_tracker_instance(tracker_name, db)
            for topic in topics:
                tracker.update(topic)
Пример #4
0
 def wrapper(args):
     try:
         db = DBManager()
         action(args, db)
     except TVShowsError as message:
         manager.event_log(message, log_level='exception')
     except TVShowsErrorInteractive as message:
         ucli.info(message)
     except KeyboardInterrupt:
         ucli.drop('Interrupted by user')
     finally:
         # Commit changes to DB even if exeption occured
         if db.has_changes:
             db.topics.commit()
Пример #5
0
 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')
Пример #6
0
 def get_metadata(self, filename):
     ucli.header(f'Processing:', filename, with_newline=True)
     if not filename.endswith(self.VIDEO_EXTENTIONS):
         return ucli.info('File hasn\'t recognised as a video file')
     return self.search(**dict(guessit(filename)))
Пример #7
0
def add(args, db):
    ucli.info('Adding the new topic to tracking')
    tracker = trackers.Tracker(None, db)
    topic = tracker.add(args)
    tracker = get_tracker_instance(topic['tracker'], db)
    tracker.update(topic)
Пример #8
0
def remove(args, db):
    topic = db.get_topic(args['TOPIC'])
    ucli.info('Remove specified topic:', topic['title'])
    db.has_changes = db.topics.delete(topic)