Exemplo n.º 1
0
    def get_autocomplete_list(self):
        db_results = []
        for book in self.query:
            media_details = {'api_id': book.api_id, 'display_name': book.name,
                             'author': ', '.join(a.name for a in book.authors),
                             'category': 'Books',
                             'type': 'Books', 'image_cover': book.get_media_cover(),
                             'date': change_air_format(book.release_date, books=True)}
            db_results.append(media_details)

        media_results = []
        get_qte = self.API_data.get('totalItems')
        if get_qte and get_qte > 0:
            for result in self.API_data['items']:
                info = result['volumeInfo']
                media_details = {'api_id': result.get('id'),
                                 'display_name': info.get('title', 'Unknown') or 'Unknown',
                                 'author': info.get('authors', ['Unknown'])[0] or 'Unknown',
                                 'date': change_air_format(info.get('publishedDate'), books=True),
                                 'image_cover':
                                     info.get('imageLinks', {'thumbnail': '/static/covers/series_covers/default.jpg'})
                                     ['thumbnail'] or 'Unknown',
                                 'category': 'Books',
                                 'type': 'Books'}

                media_results.append(media_details)

        media_results = db_results + media_results

        return media_results
Exemplo n.º 2
0
    def get_autocomplete_list(self):
        db_results = []
        for game in self.query:
            media_details = {'api_id': game.api_id, 'display_name': game.name, 'category': 'Games',
                             'type': 'Games', 'image_cover': game.get_media_cover(),
                             'date': change_air_format(game.release_date, games=True)}
            db_results.append(media_details)

        media_results = []
        if len(self.API_data) > 0:
            for result in self.API_data:
                media_details = {}
                if len(media_results) >= 8:
                    break

                media_details['api_id'] = result.get('id')
                media_details['display_name'] = result.get('name')
                media_details['category'] = 'Games'
                media_details['type'] = 'Games'
                media_details['image_cover'] = url_for('static', filename="covers/series_covers/default.jpg")
                if result.get('cover'):
                    media_details['image_cover'] = f"{self.poster_base_url}{result['cover']['image_id']}.jpg"

                media_details['date'] = change_air_format(result.get('first_release_date'), games=True)

                media_results.append(media_details)

        media_results = db_results + media_results

        return media_results
Exemplo n.º 3
0
def your_next_airing():
    next_series_airing = get_next_airing(ListType.SERIES)
    next_anime_airing = get_next_airing(ListType.ANIME)
    next_movies_airing = get_next_airing(ListType.MOVIES)
    next_games_airing = get_next_airing(ListType.GAMES)

    series_dates = []
    for series in next_series_airing:
        series_dates.append(change_air_format(series[0].next_episode_to_air))

    anime_dates = []
    for anime in next_anime_airing:
        anime_dates.append(change_air_format(anime[0].next_episode_to_air))

    movies_dates = []
    for movie in next_movies_airing:
        movies_dates.append(change_air_format(movie[0].release_date))

    games_dates = []
    for game in next_games_airing:
        games_dates.append(change_air_format(game.release_date, games=True))

    return render_template('your_next_airing.html',
                           title='Your next airing',
                           airing_series=next_series_airing,
                           series_dates=series_dates,
                           airing_anime=next_anime_airing,
                           anime_dates=anime_dates,
                           airing_movies=next_movies_airing,
                           movies_dates=movies_dates,
                           airing_games=next_games_airing,
                           games_dates=games_dates)
Exemplo n.º 4
0
    def get_trending_movies(self):
        movies_results = []
        for i, self.result in enumerate(self.trending_data['results']):
            self.media_data = {
                'overview': self.result.get('overview', 'Unknown')
                or 'Unknown',
                'display_name': self.result.get('title', 'Unknown')
                or 'Unknown',
                'release_date': self.result.get('release_date', 'Unknown')
                or 'Unknown',
                'api_id': self.result.get('id')
            }

            if self.latin_alphabet(self.result.get('original_title')):
                self.media_data["display_name"] = self.result.get(
                    'original_title')

            # Change the <release_date> format
            if self.media_data["release_date"] != 'Unknown':
                self.media_data['release_date'] = change_air_format(
                    self.result.get('release_date'))

            self.media_data['poster_path'] = self._get_media_cover()
            self.media_data['tmdb_link'] = "{}/{}".format(
                self.movie_tmdb_link, self.result.get('id'))
            self.media_data['media_type'] = 'movieslist'
            self.media_data['media'] = 'Movies'

            movies_results.append(self.media_data)

            if i == 11:
                break
        return movies_results
Exemplo n.º 5
0
    def get_search_list(self):
        media_results = []
        get_qte = self.API_data.get('totalItems')
        if get_qte and get_qte > 0:
            for result in self.API_data['items']:
                info = result['volumeInfo']
                media_details = {'api_id': result.get('id'),
                                 'name': info.get('title', 'Unknown') or 'Unknown',
                                 'author': info.get('authors', ['Unknown'])[0] or 'Unknown',
                                 'overview': clean_text(info.get('description', 'Unknown')),
                                 'first_air_date': change_air_format(info.get('publishedDate'), books=True),
                                 'poster_path':
                                     info.get('imageLinks', {'thumbnail': '/static/covers/series_covers/default.jpg'})
                                     ['thumbnail'] or 'Unknown',
                                 'media': 'Books'}

                media_results.append(media_details)

        total_results = self.API_data.get('totalItems')
        try:
            total_pages = total_results // 10
        except:
            total_pages = 1

        return media_results, total_results, total_pages
Exemplo n.º 6
0
    def get_autocomplete_list(self):
        media_results = []
        if self.API_data.get('total_results', 0) > 0:
            for i, result in enumerate(self.API_data["results"]):
                media_details = {}
                if i >= self.API_data["total_results"] or i > 19 or len(media_results) >= 7:
                    break
                if result.get('known_for_department'):
                    continue

                media_details['api_id'] = result.get('id')
                media_details['image_cover']: url_for("static", filename="covers/series_covers/default.jpg")
                if result.get('poster_path'):
                    media_details['image_cover'] = f"{self.poster_base_url}{result.get('poster_path')}"

                if result.get('media_type') == 'tv':
                    media_details['category'] = 'Series/Anime'

                    return_latin = latin_alphabet(result.get('original_name'))
                    media_details['display_name'] = result.get('name')
                    if return_latin is True:
                        media_details['display_name'] = result.get('original_name')

                    media_details['date'] = change_air_format(result.get('first_air_date'))
                    media_details['type'] = 'Series'
                    if result.get('origin_country') == 'JP' or result.get('original_language') == 'ja' \
                            and 16 in result.get('genre_ids'):
                        media_details['type'] = 'Anime'
                elif result.get('media_type') == 'movie':
                    media_details['category'] = 'Movies'

                    return_latin = latin_alphabet(result.get('original_title'))
                    media_details['display_name'] = result.get('title')
                    if return_latin is True:
                        media_details['display_name'] = result.get('original_title')

                    media_details['date'] = change_air_format(result.get('release_date'))
                    media_details['type'] = 'Movies'

                media_results.append(media_details)

        return media_results
Exemplo n.º 7
0
    def get_search_list(self):
        media_results = []
        if len(self.API_data) > 0:
            for result in self.API_data:
                media_data = {'name': result.get('name', 'Unknown'),
                              'overview': result.get('storyline', 'No storyline found.') or 'No storyline found.',
                              'first_air_date': change_air_format(result.get('first_release_date'), games=True),
                              'api_id': result.get('id'),
                              'poster_path': url_for('static', filename="covers/games_covers/default.jpg")}

                # Recover the poster_path or take a default image
                if result.get('cover'):
                    media_data['poster_path'] = "{}{}.jpg".format(self.poster_base_url, result['cover']['image_id'])

                # Put data in different lists in function of media type
                media_data['media'] = 'Games'
                media_data['media_type'] = ListType.GAMES.value
                media_results.append(media_data)

        return media_results, 50, 1
Exemplo n.º 8
0
    def from_API_to_dict(self):
        self.media_details = {'name': self.API_data.get('title', 'Unknown') or 'Unknown',
                              'release_date': change_air_format(self.API_data.get('publishedDate'), books=True),
                              'pages': self.API_data.get('pageCount', 0) or 0,
                              'publishers': self.API_data.get('publisher', 'Unknown') or 'Unknown',
                              'synopsis': clean_text(self.API_data.get('description', 'Unknown')),
                              'language': self.API_data.get('language', 'Unknown') or 'Unknown',
                              'api_id': self.API_id,
                              'image_cover': self.get_media_cover(),
                              'lock_status': True}

        authors, authors_list = self.API_data.get('authors') or None, []
        if authors:
            for author in authors:
                authors_list.append({'name': author})
        else:
            authors_list.append({'name': 'Unknown'})

        genres_list = [{'genre': 'Unknown'}]

        self.all_data = {'media_data': self.media_details, 'genres_data': genres_list, 'authors_data': authors_list}