Ejemplo n.º 1
0
    def populate(self):
        # adds all the contents for lists

        # list adds
        self.window.series_yes_list.addItems(db.get_all('Series'))
        self.window.director_yes_list.addItems(db.get_all('Directors'))
        self.window.studio_yes_list.addItems(db.get_all('Studios'))
        self.window.language_yes_list.addItems(db.get_all('Languages'))
        self.window.media_type_yes_list.addItems(db.get_all('MediaTypes'))
        self.window.country_yes_list.addItems(db.get_all('Countries'))
        self.window.genres_yes_list.addItems(db.get_all('Genres'))
        self.window.tags_yes_list.addItems(db.get_all('Tags'))
        self.window.actors_yes_list.addItems(db.get_all('Actors'))

        # sorting
        self.window.media_type_yes_list.setSortingEnabled(True)
        self.window.media_type_no_list.setSortingEnabled(True)
        self.window.country_yes_list.setSortingEnabled(True)
        self.window.country_no_list.setSortingEnabled(True)
        self.window.series_yes_list.setSortingEnabled(True)
        self.window.series_no_list.setSortingEnabled(True)
        self.window.director_yes_list.setSortingEnabled(True)
        self.window.director_no_list.setSortingEnabled(True)
        self.window.studio_yes_list.setSortingEnabled(True)
        self.window.studio_no_list.setSortingEnabled(True)
        self.window.language_yes_list.setSortingEnabled(True)
        self.window.language_no_list.setSortingEnabled(True)
        self.window.genres_yes_list.setSortingEnabled(True)
        self.window.genres_no_list.setSortingEnabled(True)
        self.window.tags_yes_list.setSortingEnabled(True)
        self.window.tags_no_list.setSortingEnabled(True)
        self.window.actors_yes_list.setSortingEnabled(True)
        self.window.actors_no_list.setSortingEnabled(True)
Ejemplo n.º 2
0
    def scan(self, startup=False):
        # scans directory for media folders and compares it to the database
        # if there's anything there that isn't in the database, ask to create a new entry
        # if there's anything missing, ask if they want the entries deleted in the database (or backup?)
        local = util.scan(db.get_all('MediaTypes'))
        database = db.get_by_media_type()
        new = {}
        missing = {}

        for media_type in local:
            new_files = [
                new for new in local[media_type]
                if new not in database[media_type]
            ]
            missing_files = [
                missing for missing in database[media_type]
                if missing not in local[media_type]
            ]

            # check to make sure the lists aren't empty
            if new_files:
                new[media_type] = new_files
            if missing_files:
                missing[media_type] = missing_files

        # make sure to scan the new folder as well
        new_files = util.scan(['New'])
        if new_files['New']:
            new.update(
                new_files
            )  # util.scan returns a dict, so this is how we merge the keys and values of two dicts

        self.handle_missing(missing, startup)
        self.handle_new(new, startup)
Ejemplo n.º 3
0
    def populate(self):
        # adds all the contents for lists

        # list adds
        try:
            self.window.series_list.addItems(db.get_all('Series'))
            self.window.director_list.addItems(db.get_all('Directors'))
            self.window.studio_list.addItems(db.get_all('Studios'))
            self.window.language_list.addItems(db.get_all('Languages'))
            self.window.media_type_list.addItems(db.get_all('MediaTypes'))
            self.window.country_list.addItems(db.get_all('Countries'))
            #sorting
            self.window.series_list.setSortingEnabled(True)
            self.window.director_list.setSortingEnabled(True)
            self.window.studio_list.setSortingEnabled(True)
            self.window.language_list.setSortingEnabled(True)
            self.window.media_type_list.setSortingEnabled(True)
            self.window.country_list.setSortingEnabled(True)
        except AttributeError:  # some windows will split these lists into yes/no lists
            self.window.series_no_list.addItems(db.get_all('Series'))
            self.window.director_no_list.addItems(db.get_all('Directors'))
            self.window.studio_no_list.addItems(db.get_all('Studios'))
            self.window.language_no_list.addItems(db.get_all('Languages'))
            self.window.media_type_no_list.addItems(db.get_all('MediaTypes'))
            self.window.country_no_list.addItems(db.get_all('Countries'))
            #sorting
            self.window.series_no_list.setSortingEnabled(True)
            self.window.director_no_list.setSortingEnabled(True)
            self.window.studio_no_list.setSortingEnabled(True)
            self.window.language_no_list.setSortingEnabled(True)
            self.window.media_type_no_list.setSortingEnabled(True)
            self.window.country_no_list.setSortingEnabled(True)
            self.window.series_yes_list.setSortingEnabled(True)
            self.window.director_yes_list.setSortingEnabled(True)
            self.window.studio_yes_list.setSortingEnabled(True)
            self.window.language_yes_list.setSortingEnabled(True)
            self.window.media_type_yes_list.setSortingEnabled(True)
            self.window.country_yes_list.setSortingEnabled(True)

        # many to many list adds
        self.window.genres_no_list.addItems(db.get_all('Genres'))
        self.window.tags_no_list.addItems(db.get_all('Tags'))
        self.window.actors_no_list.addItems(db.get_all('Actors'))
        #sorting
        self.window.genres_yes_list.setSortingEnabled(True)
        self.window.genres_no_list.setSortingEnabled(True)
        self.window.tags_yes_list.setSortingEnabled(True)
        self.window.tags_no_list.setSortingEnabled(True)
        self.window.actors_yes_list.setSortingEnabled(True)
        self.window.actors_no_list.setSortingEnabled(True)
Ejemplo n.º 4
0
def search(anime: str):
    # searches myanimelist for the first 5 most likely results and returns a list of processed info dictionaries
    search = mal.search(
        'anime', anime)['results'][:5]  # get the first 5 entries that pop up
    search_results = [
        (mal.anime(anime['mal_id']),
         mal.anime(anime['mal_id'], extension='characters_staff'))
        for anime in search
    ]  # get more detailed info on each of those searches
    fixed_results = []
    # mtm fields
    genres = db.get_all('Genres')
    directors = db.get_all('Directors')
    actors = db.get_all('Actors')
    studios = db.get_all('Studios')

    # convert the dicts gotten from scraper into readable dicts we can use
    for anime in search_results:
        info = {
            'title':
            anime[0]['title'],
            'alt_title':
            anime[0]['title_english'],
            'animated':
            True,
            'country':
            'Japan',
            'language':
            'Japanese',
            'subtitles':
            True,
            'year':
            anime[0]['aired']['from'][:4],
            'genres':
            [g['name'] for g in anime[0]['genres'] if g['name'] in genres],
            'actors': [],
            'plot':
            anime[0]['synopsis']
        }

        # ignore other media types like OVA and ONA
        if anime[0]['type'] == 'Movie':
            info['media_type'] = 'Movie'
        elif anime[0]['type'] == 'TV':  # convert 'TV' to 'TV Series'
            info['media_type'] = 'TV Series'

        # directors
        for director in [
                d['name'] for d in anime[1]['staff']
                if 'Director' in d['positions']
        ]:
            if name_fixer(director) in directors:
                info['director'] = name_fixer(director)
                break
        if 'director' not in info.keys():
            info[
                'director'] = ''  # make sure it's at least a blank string because we need it to display to create window

        # voice actors
        for character in anime[1]['characters']:
            for actor in character['voice_actors']:
                if name_fixer(actor['name']) in actors:
                    info['actors'].append(name_fixer(actor['name']))
        if not info['actors']:
            del info['actors']

        # studios
        for studio in [s['name'] for s in anime[0]['studios']]:
            if studio in studios:
                info['studio'] = studio
                break

        fixed_results.append(info)

    return fixed_results
Ejemplo n.º 5
0
def search(title: str):
    # searches imdb for the first 3 most likely results and returns a list of processed info dictionaries
    search = imdb.search_movie(title)[:3]
    search_results = [imdb.get_movie(film.movieID) for film in search]
    fixed_results = []

    # mtm fields
    genres = db.get_all('Genres')
    directors = db.get_all('Directors')
    actors = db.get_all('Actors')
    studios = db.get_all('Studios')

    # convert the dicts gotten from scraper into readable dicts we can use
    for film in search_results:
        info = {
            'title': film.get('title'),
            'alt_title': '',
            'animated': True if 'Animation' in film.get('genres') else False,
            'year': str(film.get('year')),
            'genres': [g for g in film.get('genres') if g in genres],
            'plot': film.get('plot outline')
        }

        # Countries         we can only have one entry for this field and there can be more than one country in film.get, so we pick the first match
        if film.get('countries'):
            for country in film.get('countries'):
                if country in db.get_all('Countries'):
                    info['country'] = country
                    break

        if film.get('cast'):
            info['actors'] = [
                a for a in actors
                if a in [c['name'] for c in film.get('cast')]
            ]

        if film.get('languages'):  # might return None
            info['language'] = [
                lang for lang in film.get('languages')
                if lang in db.get_all('Languages')
            ]

        # convert media types
        if 'Documentary' in film.get('genres'):
            info['media_type'] = 'Documentary'
        elif 'movie' == film.get('kind'):
            info['media_type'] = 'Movie'
        elif 'tv series' == film.get('kind'):
            info['media_type'] = 'TV Series'
        else:
            info['media_type'] = ''

        # directors
        if film.get('director'):  # film.get('director') could return None
            for director in film.get('director'):
                if director['name'] in directors:
                    info['director'] = director['name']
                    break
        if 'director' not in info.keys():
            info[
                'director'] = ''  # make sure it's at least a blank string because we need it to display to create window

        # studio
        if film.get('production companies'):
            for studio in film.get('production companies'):
                if studio['name'] in studios:
                    info['studio'] = studio['name']
                    break

        fixed_results.append(info)

    return fixed_results