Esempio n. 1
0
    def _search(self, mdb, query, filename, season_num, episode_num, auto=False):
        """ Search the movie using all available datasources and let the user
            select a result. Return the choosen datasource and produced movie dict.

        If auto is enabled, directly returns the first movie found.
        """
        choices = []
        for datasource, movie in mdb.search(query, season=season_num, episode=episode_num):
            if auto:
                return datasource, movie
            fmt = u'<b>{title}</b> - <b>{ep}</b> S{season:02d}E{episode:02d} [{datasource}]'
            choices.append(option((datasource, movie), fmt, title=movie['title'],
                                                            ep=movie['episode_title'],
                                                            season=movie['season'],
                                                            episode=movie['episode'],
                                                            datasource=datasource.name))

        if not choices:
            printer.p('No results to display for the file: {fn}', fn=filename)
            return None, None

        choices.append(option(('manual', None), 'Enter information manually'))
        choices.append(option(('abort', None), 'None of these'))
        printer.p('Please choose the relevant result for the file: {fn}', fn=filename, end='\n\n')
        return printer.choice(choices)
Esempio n. 2
0
    def _search(self, mdb, query, filename, year=None, auto=False):
        """ Search the movie using all available datasources and let the user
            select a result. Return the choosen datasource and produced movie dict.

        If auto is enabled, directly returns the first movie found.
        """
        choices = []
        for datasource, movie in mdb.search(query, year=year):
            if auto:
                return datasource, movie
            if movie.get('directors'):
                directors = ' by '
                if len(movie['directors']) > 1:
                    directors += '%s and %s' % (', '.join(movie['directors'][0:-1]),
                                                          movie['directors'][-1])
                else:
                    directors += movie['directors'][0]
            else:
                directors = ''
            fmt = u'<b>{title}</b> ({year}){directors} [{datasource}]'
            choices.append(option((datasource, movie), fmt, title=movie['title'],
                                                            year=movie.get('year', 'Unknown'),
                                                            directors=directors,
                                                            datasource=datasource.name))

        if not choices:
            printer.p('No results to display for the file: {fn}', fn=filename)
            return None, None

        choices.append(option(('manual', None), 'Enter information manually'))
        choices.append(option(('abort', None), 'None of these'))
        printer.p('Please choose the relevant movie for the file: {fn}', fn=filename, end='\n\n')
        return printer.choice(choices)