コード例 #1
0
    def getMovieDetailsFromOMDB(self, movieName):

        ## API key
        API_key = "bf1418d4"
        movie = GetMovie(title= movieName, api_key=API_key)

        return movie.get_data('Title','Poster', 'Year', 'Ratings', 'Director', 'Genre')
コード例 #2
0
def get_recommendations(title):
    idx = indices[title]
    sim_scores = list(enumerate(cosine_sim[idx]))
    sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
    sim_scores = sim_scores[1:11]
    movie_indices = [i[0] for i in sim_scores]
    title = df2['title'].iloc[movie_indices]
    date = df2['release_date'].iloc[movie_indices]
    return_df = pd.DataFrame(
        columns=['Title', 'Year', 'Plot', 'Ratings', 'Genre'])
    return_df['Title'] = title
    return_df['Year'] = date
    plot = []
    genre = []
    ratings = []
    for i in title:
        movie = GetMovie(title=i, api_key='65b3ddf')
        mov = movie.get_data('Genre', 'Ratings', 'Plot')
        plot.append(mov['Plot'])
        ratings.append(mov['Ratings'][0]['Value'])
        genre.append(mov['Genre'])
    return_df['Plot'] = plot
    return_df['Ratings'] = ratings
    return_df['Genre'] = genre
    return_df.sort_values(by=['Ratings'], inplace=True, ascending=False)
    return return_df
コード例 #3
0
    def print_recommendations(self, input_user):
        """
        Prints all information
        Args:
            input_user: Name of the user

        Returns:
            None
        """
        def print_info(data, i):
            """
            Print information for single data
            Args:
                data: Sict with all information
                i: Number on list

            Returns:
                None
            """
            print("------{}------".format(i))
            print(data["Title"].upper())
            print("Rating:", data["imdbRating"])
            print("Genre:", data["Genre"])
            print("Plot:", data["Plot"])
            print("Actors:", data["Actors"])
            print("\n")

        titles = self.get_recommendations(input_user)

        for i, title in enumerate(titles, 1):
            movie = GetMovie(title=title, api_key='29e4e98a', plot='full')
            data = movie.get_all_data()
            print_info(data, i)
コード例 #4
0
def is_movie(file):
    """
    :type file: Path
    """
    title, year = get_movie_title_year(file)
    if not (title and year):
        print('    x Not a movie: missing title and/or year')
        return False

    movie = GetMovie(title=title, api_key=OMDBAPI_KEY)
    try:
        movie_year = int(movie.get_data('Year')['Year'])
    except ValueError:
        print(f'    x Not a movie; not found on OMDB: {title}')
        return False

    if not str(year) == str(movie_year):
        print(
            f'    x Not a movie: year on filename {year} does not match OMDB {movie_year}'
        )
        return False

    return True
コード例 #5
0
ファイル: omdb_test.py プロジェクト: 88ben/random_python
# %%
from omdbapi.movie_search import GetMovie
from keys import OMDB_API_KEY

movie = GetMovie(title="Interstellar", api_key=OMDB_API_KEY)
# movie.get_all_data().keys()
# movie.get_data('Title', 'Year', 'Rated', 'Released', 'Runtime', 'Genre', 'Director', 'Writer', 'Actors', 'Plot', 'Poster', 'Ratings', 'Metascore', 'imdbRating', 'imdbVotes', 'imdbID', 'Type')

title, year, rated = movie.get_data('Title', 'Year', 'Rated').values()

print(title, year, rated)
コード例 #6
0
f = codecs.open("imdb_most_popular_movies_dump.html", 'r', 'utf-8')
document = BeautifulSoup(f.read(), 'html.parser')

movies = document.select('td.titleColumn a')

movie_list = []

for index in range(0, len(movies)):
    movie_name = movies[index].get_text()
    movie_list.append(movie_name)

movie_details = []

for title in movie_list:
    # API KEY - http://www.omdbapi.com/apikey.aspx
    movie_info = GetMovie(title=title, api_key='')
    mv = movie_info.get_all_data()
    movie_details.append(mv)

i = 0

with open('info.csv', 'w', newline='', encoding='utf-8') as f:
    # csv.DictWriter could be used to simplify the output code
    # (https://docs.python.org/3/library/csv.html#csv.DictWriter)
    writer = csv.writer(f)
    # enumerate could be used to simplify looping with index
    # (https://docs.python.org/3/library/functions.html?highlight=enumerate#enumerate)
    writer.writerow(movie_details[0].keys())
    for item in movie_details:
        writer.writerow(movie_details[i].values())
        i += 1
コード例 #7
0
import omdb
from omdbapi.movie_search import GetMovie
args =input("Enter movie name")
movie = GetMovie(title= args, api_key='46237dd4')
data = movie.get_all_data()
print(data)
print("Rotten Tomatoes rating :: ",data["Ratings"][1]["Value"])
コード例 #8
0
def get_omdb_movie_dataset():
    ##create new dataframe with following features
    features = [
        'Ranking among 250', 'Title', 'Metascore', 'Rotten Tomatoes Score',
        'Year', 'Country', 'Runtime(min)', 'Language', 'Director', 'Writer',
        'Production Company', 'Type', 'Plot'
    ]
    df = pd.DataFrame(columns=features)
    title_list = []
    country_list = []
    release_year_list = []
    language_list = []
    metascore_rating_list = []
    rating_list = []
    director_list = []
    writer_list = []
    plot_list = []
    type_list = []
    runtime_list = []
    production_company_list = []
    words = [
        'Title', 'Metascore', 'Year', 'Country', 'Runtime', 'Language',
        'Director', 'Writer', 'Production', 'Type', 'Plot'
    ]
    ##for each movie, extract corresponding 'Title','Metascore','Year',
    ##'Country','Runtime','Language','Production','Type','Plot' by using getMovie package from omdb library wrapper
    for i in range(len(movie_list)):
        movie = GetMovie(title=movie_list[i], api_key='6de2ae04', plot='full')
        title = movie.get_data('Title')
        title_list.append(title)
        metascore_rating = movie.get_data('Metascore')
        metascore_rating_list.append(metascore_rating)
        release_year = movie.get_data('Year')
        release_year_list.append(release_year)
        country = movie.get_data('Country')
        country_list.append(country)
        runtime = movie.get_data('Runtime')
        runtime_list.append(runtime)
        language = movie.get_data('Language')
        language_list.append(language)
        rating = movie.get_data('Ratings')
        rating_list.append(rating)
        director = movie.get_data('Director')
        director_list.append(director)
        writer = movie.get_data('Writer')
        writer_list.append(writer)
        production_company = movie.get_data('Production')
        production_company_list.append(production_company)
        Type = movie.get_data('Type')
        type_list.append(Type)
        plot = movie.get_data('Plot')
        plot_list.append(plot)

        ## each list constituted by dict which contain features name and corresponding feature value,
        ## below function only extract feature values
        def transform(my_list, word):
            new_value = []
            for x in range(0, len(my_list)):
                Str = my_list[x][word]
                new_value.append(Str)
            return new_value[i]

        ##rating list contains dict which included imdb rating score, rotten tomatoes score and metascore, we only
        ##need rotten tomato score from rating list by using below function
        def transform_rotten_tomatoes_rating(My_list):
            output_list = []
            for rating in My_list:
                rotten_tomato_value = rating['Ratings'][1]['Value'].replace(
                    '%', '')[:2]
                output_list.append(rotten_tomato_value)
            return output_list[i]

        ##apply above two functions to every list
        title_ = transform(title_list, words[0])
        metascore_ = transform(metascore_rating_list, words[1])
        release_year_ = transform(release_year_list, words[2])
        country_ = transform(country_list, words[3])
        runtime_ = transform(runtime_list, words[4])[:3]
        language_ = transform(language_list, words[5])
        director_ = transform(director_list, words[6])
        writer_ = transform(writer_list, words[7])
        production_company_ = transform(production_company_list, words[8])
        type_ = transform(type_list, words[9])
        plot_ = transform(plot_list, words[10])
        ## if indexerror happens, just ignore it and append none to rotten_tomatoes_score
        try:
            rotten_tomatoes_score = transform_rotten_tomatoes_rating(
                rating_list)
        except IndexError:
            rotten_tomatoes_score = ''

        ##append all above movies' feature to dataframe.
        feature_dicts = {
            'Ranking among 250': i + 1,
            'Title': title_,
            'Metascore': metascore_,
            'Rotten Tomatoes Score': rotten_tomatoes_score,
            'Year': release_year_,
            'Country': country_,
            'Runtime(min)': runtime_,
            'Language': language_,
            'Director': director_,
            'Writer': writer_,
            'Production Company': production_company_,
            'Type': type_,
            'Plot': plot_
        }

        df = df.append(
            pd.DataFrame.from_records([feature_dicts],
                                      columns=feature_dicts.keys()))
        df = df[features]
        ##using movies ranking as index in dataframe
    df['Metascore'] = df['Metascore'].str.replace(
        'N/A', '')  # removing comma from column data
    df['Metascore'] = pd.to_numeric(df['Metascore'])
    df['Metascore'].fillna(df['Metascore'].median(), inplace=True)
    df['Rotten Tomatoes Score'] = pd.to_numeric(df['Rotten Tomatoes Score'])
    df['Rotten Tomatoes Score'].fillna(df['Rotten Tomatoes Score'].median(),
                                       inplace=True)
    #df=df.set_index(['Ranking among 250'], drop=True)
    return df
コード例 #9
0
def omdb():

    speak('enter name of movie:')
    name = s_input()

    movie = GetMovie(title=name,
                     api_key='Enter API key ')  #get api key from imdb
    print(movie.get_data('Title'))
    print(movie.get_data('Yaer'))
    print(movie.get_data('Rated'))
    print(movie.get_data('Language'))
    print(movie.get_data('Director'))
    print(movie.get_data('Actors'))
    print(movie.get_data('writer'))
    print(movie.get_data('Ratings'))
    print(movie.get_data('Runtime'))
    print(movie.get_data('Boxoffice'))
    print(movie.get_data('Genre'))
    print(movie.get_data('imdbRating'))

    speak(movie.get_data('Title'))
    speak(movie.get_data('Yaer'))
    speak(movie.get_data('Language'))
    speak(movie.get_data('Director'))
    speak(movie.get_data('Actors'))
    speak(movie.get_data('writer'))
    speak(movie.get_data('Runtime'))
    speak(movie.get_data('Genre'))
    speak(movie.get_data('imdbRating'))
コード例 #10
0
# coding: utf-8

# In[ ]:

from omdbapi.movie_search import GetMovie
import pandas as pd
from tabulate import tabulate as td
"Library Imported"

# In[ ]:

search = input("Enter the movie you want to search for :")

# In[ ]:

movie = GetMovie(title=search, api_key='723686e0', plot='full')

# In[ ]:

result = movie.get_data('Title', 'Year', 'Genre', 'Director', 'Actors',
                        'Rated', 'imdbRating', 'imdbVotes')
result_data = pd.DataFrame.from_dict(result, orient='index')
"Your Returned Result : "

# In[ ]:

print(td(result_data, tablefmt="rst"))

# In[ ]:

# In[ ]:
コード例 #11
0
ファイル: main.py プロジェクト: suchacomic/Mubi-radarr-list
for heading in division:
    movie_name = heading.find('h2')
    movie_year = heading.find("span", {"class": "css-0 e1n7piqx10"})
    movie_title.append(movie_name.text.title())
    #movie_period.append(movie_year.tex[-4:])

division2 = soup.findAll('div', {'class': 'css-14yfd4f etvj1lh3'})
for heading2 in division2:
    movie_name2 = heading2.find('h2')
    movie_year2 = heading2.find("span", {"class": "css-0 etvj1lh8"})
    movie_title.append(movie_name2.text.title())
    #movie_period.append(movie_year2.text[-4:])

#querying omdb
for i in tqdm(movie_title):
    movie_search = GetMovie(title=i, api_key=omdb_api_key)
    results = movie_search.get_data('Title', 'Released', 'imdbID')
    results['imdb_id'] = results.pop('imdbID')
    results['title'] = results.pop('Title')
    results['year'] = results.pop('Released')
    movies.append(results)

with open('listfile', 'w') as f:
    f.write('\u005B')
    for items in movies:
        f.write('%s' % items + '\u002C' + '\n')
    f.close()
with open('listfile', 'a') as file:
    file.write('\u005D')
    file.close()