示例#1
0
async def remove(ctx, *args):
    movie = ' '.join(args)
    if "imdb.com" in movie:
        imdb_id = movie.split("title/")[1].split("/")[0]
        if check_movie_id_in_list(imdb_id, viewed=False):
            remove_movie_id(imdb_id)
            # get movie title from id
            found_movie = search_movie_id(imdb_id)
            if found_movie:
                response = f"{found_movie['Title']} was removed from the list."
            else:
                response = f"{movie} was removed from the list."
        else:
            response = "Movie could not be removed. IMDB id was not found in the list."
    else:
        # Remove by title
        found_movie = search_movie_title(movie)
        if found_movie:
            if check_movie_id_in_list(found_movie['imdbID'], viewed=False):
                remove_movie_id(found_movie['imdbID'])
                response = f"{found_movie['Title']} was removed from the list."
            else:
                response = f"Tried to remove {found_movie['Title']} (https://imdb.com/title/{found_movie['imdbID']}), could not find in list. Try more exact title or IMDB link."
        else:
            response = "Movie could not be removed. Double check the title in the list."
    await ctx.send(response)
示例#2
0
async def setviewed(ctx, *args):
    movie = ' '.join(args)
    if "imdb.com" in movie:
        imdb_id = movie.split("title/")[1].split("/")[0]
        if check_movie_id_in_any_list(imdb_id) is None:
            response = "Can't set movie to viewed, not in watchlist."
        elif check_movie_id_in_list(imdb_id, viewed=True) is None:
            set_viewed_by_id(imdb_id)
            response = "Movie was added to the viewed list."
        else:
            response = "Movie is already in viewed list."
    else:
        # Set viewed by title
        found_movie = search_movie_title(movie)
        print(found_movie)
        if found_movie:
            if check_movie_id_in_any_list(found_movie['imdbID']) is None:
                response = f"Can't set {found_movie['Title']} (https://imdb.com/title/{found_movie['imdbID']}) to viewed, not in watchlist."
            elif check_movie_id_in_list(found_movie['imdbID'],
                                        viewed=True) is None:
                set_viewed_by_id(found_movie['imdbID'])
                response = f"{found_movie['Title']} was added to the viewed list."
            else:
                response = f"{found_movie['Title']} is already in viewed list."
        else:
            response = f"Could not find {movie} in list."

    await ctx.send(response)
示例#3
0
async def bulkadd(ctx, *args):
    movies = list(filter(bool, ' '.join(args).strip().split(',')))
    print(movies)
    response = ""
    for movie in movies:
        if "imdb.com" in movie:
            imdb_id = movie.split("title/")[1].split("/")[0]
            if check_movie_id_in_list(imdb_id, viewed=False) is None:
                movie_found = add_movie_id(imdb_id, ctx.author.mention)
                if movie_found is not False:
                    response += f"{movie_found} was added to the list.\n"
                else:
                    response += f"{movie} could not be added, double check the URL.\n"
            else:
                response += f"{movie} is already in the list.\n"
        else:
            # add by title
            if check_movie_title_in_list(movie, viewed=False) is None:
                movie_found = add_movie_title(movie, ctx.author.mention)
                if movie_found is not False:
                    response += f"{movie_found} was added to the list.\n"
                else:
                    response += f"{movie} could not be added. Double check the title or try adding an IMDB link.\n"
            else:
                response += f"{movie} is already in the list.\n"
    await ctx.send(response)
示例#4
0
async def add(ctx, *args):
    movie = ' '.join(args)
    if "imdb.com" in movie:
        imdb_id = movie.split("title/")[1].split("/")[0]
        if check_movie_id_in_list(imdb_id, viewed=False) is None:
            movie_found = add_movie_id(imdb_id, ctx.author.mention)
            if movie_found is not False:
                response = f"{movie_found} was added to the list."
            else:
                response = f"{movie} could not be added, double check the URL."
        else:
            response = f"{movie} is already in the list."
    else:
        # add by title
        if check_movie_title_in_list(movie, viewed=False) is None:
            found_movie = search_movie_title(movie)
            if found_movie:
                # add rtScore value for ease of access and to mirror DB
                if len(found_movie["Ratings"]) > 1:
                    found_movie['rtScore'] = found_movie["Ratings"][1]['Value']
                else:
                    found_movie['rtScore'] = "N/A"
                found_movie['submitter'] = ctx.author.mention
                embed = build_movie_embed(
                    found_movie, "Is this the movie you were looking for?")
                message = await ctx.send(embed=embed)
                message_id = message.id
                emojis = ['\U00002705', '\U0000274c']
                for emoji in emojis:
                    await message.add_reaction(emoji)
                await asyncio.sleep(20)
                # Count reactions
                message = await ctx.fetch_message(message_id)
                reactions = {}
                for reaction in message.reactions:
                    reactions[reaction.emoji] = reaction.count
                print(reactions)
                if reactions['\U00002705'] > reactions['\U0000274c']:
                    # Add movie as it was accepted by user
                    movie_found = add_movie_title(movie, ctx.author.mention)
                    if movie_found is not False:
                        response = f"{movie_found} was added to the list."
                    else:
                        response = "Movie could not be added. Please try again."
                else:
                    response = "Movie will not be added. Try another movie or try adding an IMDB link."
            else:
                response = f"{movie} could not be added. Double check the title or try adding an IMDB link."
        else:
            response = f"{movie} is already in the list."
    await ctx.send(response)