def get_movie_from_imdb(title):
    id = movieLink.get(title)
    return IMDb().get_movie(id)
示例#2
0
    def update(self, text):
        if self.search:
            self.fill((255, 255, 255))
            im = IMDb()
            series = im.search_movie(text)[0]

            # Get title
            self.title = series["long imdb title"]

            # Get cover image
            cover = series["full-size cover url"]
            r = requests.get(cover)
            img = Image.open(io.BytesIO(r.content))
            img = img.resize((256, 384))

            self.cover_img = pygame.image.fromstring(img.tobytes(), img.size,
                                                     img.mode)

            self.overall_rating = im.get_movie(series.getID())["rating"]

            if series["kind"] == "tv series":
                im.update(series, "episodes")
                num_of_series = sorted(series["episodes"].keys())

                ratings = []

                # Get each episodes rating
                for s in num_of_series:
                    num_of_episodes = sorted(series["episodes"][s].keys())
                    e_ratings = []
                    for e in num_of_episodes:
                        e_ratings.append(series["episodes"][s][e].get(
                            "rating", 0))
                    ratings.append(e_ratings)

                # Get box sizes
                max_episodes = max(ratings, key=len)
                box_width = (self.w - 30) / len(max_episodes)
                box_height = (self.h - 30) / len(ratings)

                # Draw axis labels
                self.blit(self.font.render("Episodes", True, (0, 0, 0)),
                          ((self.w // 2) - (font.size("Episodes")[0] // 2), 0))

                letter_size = font.size("S")
                vert_start = (self.h // 2) - ((letter_size[1] * 6) // 2)
                for pos, letter in enumerate("Series"):
                    self.blit(self.font.render(letter, True, (0, 0, 0)),
                              (0, vert_start + (letter_size[1] * pos)))

                # Get colour gradient
                colours = list(Color("red").range_to(Color("green"), 50))
                colours[:0] = [Color("red")] * 50

                # Insert blank episode spaces
                for s in ratings:
                    if len(s) < len(max_episodes):
                        s.extend([None] * (len(max_episodes) - len(s)))

                # Draw episode text
                for en in range(len(max_episodes)):
                    e_txt = self.font.render(str(en + 1), True, (0, 0, 0))
                    et_pos = ((en * box_width) + 30 + (box_width // 2), 15)
                    self.blit(e_txt, et_pos)

                # Series loop
                for s_pos, s in enumerate(ratings):
                    # Draw series text
                    s_txt = self.font.render(str(s_pos + 1), True, (0, 0, 0))
                    st_pos = (15,
                              (s_pos * box_height) + 30 + (box_height // 2))
                    self.blit(s_txt, st_pos)
                    # Episode loop
                    for e_pos, e in enumerate(s):
                        e_rect = pygame.Rect((e_pos * box_width) + 30,
                                             (s_pos * box_height) + 30,
                                             box_width, box_height)
                        if e is not None:
                            # Draw episode rect
                            c = list(
                                map(
                                    lambda x: x * 255,
                                    colours[int(e * 10) -
                                            (1 if e > 0 else 0)].rgb))
                            pygame.draw.rect(self, c, e_rect)

                            # Draw rating text
                            r_txt = self.font.render(
                                str(e)[:3], True, (0, 0, 0))
                            r_size = font.size(str(e)[:3])
                            r_pos = (e_rect.centerx - (r_size[0] // 2),
                                     e_rect.centery - (r_size[1] // 2))
                            self.blit(r_txt, r_pos)

                        pygame.draw.rect(self, (0, 0, 0), e_rect, 2)
            else:
                self.blit(font.render("NOT A SERIES", True, (0, 0, 0)),
                          (self.w // 2, self.h // 2))

        self.search = False
    def crawl_by_id(self, movie_id=None, driver=None):
        driver = self.driver
        ia = IMDb()
        try:
            x = ia.get_movie(movie_id[2:])
        except:
            return

        # find popularity
        popularity = find_pop(movie_id=movie_id, driver=driver)

        try:
            box_office = find_box_office(movie_id=movie_id, driver=driver)
        except:
            box_office = None

        # find budget
        try:
            budget = find_budget(movie_id=movie_id, driver=driver)
            if budget == box_office:
                budget = None
        except:
            budget = None

        # find title
        try:
            title = x['title']  # title
        except:
            title = None

        # find cast
        try:
            cast_list = x['cast']  # cast_id
        except:
            cast_info = [None]
        else:
            cast_info = []
            for i in range(len(cast_list)):
                d = {'id': cast_list[i].getID(), 'name': cast_list[i]['name']}
                cast_info.append(d)

        # find run time
        try:
            run_time = x['runtimes']  # run time
        except:
            run_time = None

        # find country
        try:
            country = x['country codes']  # country codes
        except:
            country = None

        # find language
        try:
            language = x['language codes']  # language
        except:
            language = None

        # find production companies
        try:
            company_list = x['production companies']  # production companies
        except:
            company = None
        else:
            product_company = []
            for i in range(len(company_list)):
                d = {
                    'id': company_list[i].getID(),
                    'name': company_list[i]['name']
                }
                product_company.append(d)

        # find genres
        try:
            genres = x['genres']
        except:
            genres = None

        # find rating
        try:
            rating = x['rating']
        except:
            rating = None

        # find votes
        try:
            votes = x['votes']
        except:
            votes = None

        # get crew members
        try:
            data_list = list(x.data.keys())
            crew_list = list()
        except:
            crew_list = None
        else:
            for i in range(len(data_list)):
                if 'ors' in data_list[i] or 'ers' in data_list[
                        i] or 'depart' in data_list[i]:
                    crew_list.append(data_list[i])

            if 'distributors' in crew_list:
                crew_list.remove('distributors')

        crew_info = []
        for i in range(0, len(crew_list)):
            crew_temp = x[crew_list[i]]
        for n in range(len(crew_temp)):
            try:
                id_temp = crew_temp[n].getID()
                name_temp = crew_temp[n]['name']
            except:
                id_temp = None
                name_temp = None
            else:
                d = {'id': id_temp, 'name': name_temp}
            crew_info.append(d)

        # get release date
        try:
            date_info = x['original air date']
            date = get_date(date_info=date_info)
        except:
            date = "01/01/2019"

        # driver.close()

        dataset = {
            'budget': [budget],
            'genres': [genres],
            'imdb_id': [movie_id],
            'spocken_languages': [language],
            'original_title': [title],
            'popularity': [popularity],
            'production_companies': [product_company],
            'production_countries': [country],
            'release_date': [date],
            'runtime': run_time,
            'cast': [cast_info],
            'crew': [crew_info],
        }
        # 'wb_info':[box_office]}
        df_meta = pd.DataFrame(dataset)
        # df_meta.to_csv('./get_meta/meta_info.csv', columns=df_meta.columns, index=False)
        return df_meta
示例#4
0
from __future__ import division
import threading
import os
from imdb import IMDb
import xml.etree.ElementTree as ET

ib = IMDb()


def initMovieItems():
    items = []
    items.append("title")
    items.append("year")
    items.append("genres")
    items.append("director")
    items.append("producer")
    items.append("writer")
    items.append("editor")
    items.append("cast")
    items.append("original music")
    items.append("production companies")
    items.append("distributors")
    items.append("runtimes")
    items.append("countries")
    items.append("languages")

    return items


def getMovieByTitleAndYear(title, year):
    movies = ib.search_movie(title)
示例#5
0
main = Blueprint('main', __name__)

# local - use local mysql db
local = False

# enable_extra - loads poster and plot overview from tmdb for movie info
enable_extra = True

# to laod posters on profile page
posters_on_profile_page = True

tmdb_img_url = r'https://image.tmdb.org/t/p/w342'

if local:
    ia = IMDb('s3', 'mysql+mysqldb://may:venom123@localhost/imdb')
else:
    ia = IMDb()


def db_fav_exists(tconst, user_id):
    """
    checks if the tconst exists as a favorite for the user of user id `user_id`
    """
    fav_tconst = fav.query.filter_by(user_id=user_id).all()
    if fav_tconst:  # user already has favorites
        for a in fav_tconst:
            if a.tconst == int(tconst):  # the same tconst already exists
                return True

    return False
示例#6
0
def get_show_imdb_info(imdb_id):
    from imdb import IMDb
    ia = IMDb()
    return ia.get_movie(imdb_id)
示例#7
0
class Movie:

    # Get location of Movie Malarkey source (for proper retrieval of stripped dataset)
    movie_malarkey_loc = pathlib.Path(
        __file__).parent.absolute().parent.absolute()
    local_datastore = pathlib.Path.joinpath(movie_malarkey_loc,
                                            'dataset/malarkey.tsv')

    ia = IMDb()

    def __init__(self, title: str, year: str, movie_id: str = None):
        """
        Constructor for Movie object

        Args:
            title (str): Title of the Movie
            year (str): Year of the Movie's release. Uses a str for non-standard years ('N/A', 'Unknown', etc.)
            movie_id (str, Optional): IMDb ID of the Movie (if given). Defaults to None
        """
        self.title = title
        self.year = year
        self.id = movie_id
        self._imdbpy_movie = None

    def __repr__(self):
        return f'{self.title} ({self.year})'

    def __str__(self):
        return repr(self)

    @property
    def plot(self):
        raw_plot = self._imdbpy_movie["plot"][0]

        # Some plots seem to use '::' to credit the author of the plot summary
        return raw_plot.split('::')[0]

    def populate(self):
        self._imdbpy_movie = Movie.ia.get_movie(self.id)

    def serialize(self, full=False):
        """
        Serializes the object as JSON.

        Args:
            full (bool): If True, returns all data. If False, does not return the Plot of the Movie. This can be useful
             when hiding the 'correct' plot from the guessers.

        Returns:
            dict: JSON representation of this Movie
        """
        return {'title': self.title, 'plot': self.plot if full else ''}

    @staticmethod
    def get_random():
        """
        Gets a random Movie from the local datastore

        Returns:
            Movie: Random Movie object
        """
        with open(Movie.local_datastore, "r") as local_ds:
            content = local_ds.read()
            movies = content.split("\n")[1:]

            num_movies = len(movies)

            selected_index = randrange(num_movies - 1)
            selected = movies[selected_index]

            movie_pieces = selected.split("\t")

            movie_id = movie_pieces[0].split("tt")[-1]
            movie_title = movie_pieces[2]
            movie_year = str(movie_pieces[5])

            movie = Movie(movie_title, movie_year, movie_id=movie_id)
            movie.populate()

            return movie
from imdb import IMDb

i = IMDb('sql', uri='postgresql://localhost/imdb')

resList = i.search_movie('Moana')

for x in resList:
    print x
ti = resList[0]
i.update(ti)
print ti['director'][0]
示例#9
0
    def mail_send(self):
        
        

            self.s1 = self.eadminmail.get()
            self.s2 = self.eadminpass.get()
            self.s3 = self.emailto.get()

            s='select movie1,movie2,movie3,movie4 from userinput where email like %s;'
            mydb.execute(s,(self.s3,))
            self.r=mydb.fetchall();

            for self.i in self.r:
                self.mov1=self.i[0]
                self.mov2=self.i[1]
                self.mov3=self.i[2]
                self.mov4=self.i[3]

            
            imd = IMDb('http')
            tm1=self.mov1
            tm2=self.mov2
            tm3=self.mov3
            tm4=self.mov4
            sm1=imd.search_movie(tm1)[0]
            sm2=imd.search_movie(tm2)[0]
            sm3=imd.search_movie(tm3)[0]
            sm4=imd.search_movie(tm4)[0]
            print(sm1)
            print(sm2)
            print(sm3)
            print(sm4)
            movid1 = sm1.movieID
            movid2 = sm2.movieID
            movid3 = sm3.movieID
            movid4 = sm4.movieID

            imd.get_movie(movid1)
            imd.get_movie(movid2)
            imd.get_movie(movid3)
            imd.get_movie(movid4)

            imd.update(sm1,'episodes')
            imd.update(sm2,'episodes')
            imd.update(sm3,'episodes')
            imd.update(sm4,'episodes')
            xa=sorted(sm1['episodes'].keys())
            xb=sorted(sm2['episodes'].keys())
            xc=sorted(sm3['episodes'].keys())
            xd=sorted(sm4['episodes'].keys())
            ja=max(xa)
            jb=max(xb)
            jc=max(xc)
            jd=max(xd)
            sea1=sm1['episodes'][ja]
            sea2=sm2['episodes'][jb]
            sea3=sm3['episodes'][jc]
            sea4=sm4['episodes'][jd]
            la=len(sea1)
            lb=len(sea2)
            lc=len(sea3)
            ld=len(sea4)

            e1=sm1['episodes'][ja][la]
            e2=sm2['episodes'][jb][lb]
            e3=sm3['episodes'][jc][lc]
            e4=sm4['episodes'][jd][ld]
    

            self.data1=e1['long imdb canonical title']
            self.data2=e2['long imdb canonical title']
            self.data3=e3['long imdb canonical title']
            self.data4=e4['long imdb canonical title']
            self.spl1=self.data1.split('#')
            self.spl2=self.data2.split('#')
            self.spl3=self.data3.split('#')
            self.spl4=self.data4.split('#')
            
            print(self.spl1)
            print(self.spl2)
            print(self.spl3)
            print(self.spl4)


            self.subject = 'TV series reminder'
            self.msg =('Hi \n\nThere is latest tv series upates ,\n Status: \n'+str(self.spl1[0])+'  '+str(self.spl1[1])+ ': \n\n'
                         + str(self.spl2[0])+'  '+str(self.spl2[1])+ ':\n\n'
                         + str(self.spl3[0])+ '  '+str(self.spl3[1])+ ':  \n\n'
                         + str(self.spl4[0])+ '  '+str(self.spl4[1])+': \n\n')

            server = smtplib.SMTP('smtp.gmail.com:587')
            server.ehlo()
            server.starttls()
            server.login(self.s1,self.s2)
            message='Subject: {}\n\n{}'.format(self.subject,self.msg)
            server.sendmail(self.s1,self.s3,message)
            server.quit()
            tkinter.messagebox.showinfo(' send','message successfully send.  ')
            print("Success:Email send!")
def init_IMDBb():

    ia = IMDb()

    movie = ia.get_movie('0094878')
示例#11
0
from imdb import IMDb
import bs4
import datetime
import random
import re
import requests
import sqlite3
import time
from tqdm import tqdm
ia = IMDb(adultSearch=False)
db = sqlite3.connect('usernames.db')
c = db.cursor()
# Initialise tables if they don't already exist
c.execute(
    "CREATE TABLE IF NOT EXISTS details(username TEXT, password TEXT, lastFilms TEXT, likedFilms TEXT)")
c.execute("CREATE TABLE IF NOT EXISTS info(username TEXT, name TEXT, address TEXT, dateofbirth TEXT, gender TEXT, interests TEXT)")
db.commit()


# Changes ["spam", "eggs"] to "spam, eggs"
def listBeaut(ugly): return ', '.join(ugly)

def authLoop(expression, message):
    # prompts the user for input until a regex expression is not met
    variable = ''
    while not(re.compile(expression).match(''.join(sorted(variable)))):
        variable = input(message)
    return variable

def tryAttr(movie, variable):
    # checks if an attribute for a movie exists, catches any exceptions
def get_year(title):
    id = movieLink.get(title)
    movie = IMDb().get_movie(id)
    return movie['year']
def get_genres(title):
    id = movieLink.get(title)
    movie = IMDb().get_movie(id)
    return movie['genres']
def get_cover(title):
    id = movieLink.get(title)
    movie = IMDb().get_movie(id)
    return movie['cover url']
示例#15
0
import requests
from random import seed
import sqlite3
import pandas as pd
import re

import pickle
from flaskblog import creating_model
from math import isnan
from warnings import filterwarnings
from flaskblog import db
from flaskblog.models import User, Admin, Movie, Seat, Screening, Reserved, Cost

filterwarnings("ignore")
lm, IMDB, feature_columns = creating_model.create_model()
imdb_obj = IMDb()
proxy = {"https": "185.56.209.114:51386"}
s = requests.Session()
s.proxies = {"http": "http://50.203.239.28:80"}
seed(1)


def cost(predicted_movie_rating):
    premium_cost = 0
    if (predicted_movie_rating > 0 and predicted_movie_rating < 3):
        premium_cost = 100
    elif (predicted_movie_rating >= 3 and predicted_movie_rating < 6):
        premium_cost = 120
    elif (predicted_movie_rating >= 6 and predicted_movie_rating < 8):
        premium_cost = 160
    elif (predicted_movie_rating >= 8 and predicted_movie_rating <= 10):
示例#16
0
    def __init__(self, application):

        self.application = application
        self.settings = Gio.Settings(schema_id="org.x.hypnotix")
        self.icon_theme = Gtk.IconTheme.get_default()
        self.manager = Manager(self.settings)
        self.providers = []
        self.active_provider = None
        self.active_group = None
        self.active_serie = None
        self.marked_provider = None
        self.content_type = TV_GROUP  # content being browsed
        self.back_page = None  # page to go back to if the back button is pressed
        self.active_channel = None
        self.fullscreen = False
        self.mpv = None
        self.ia = IMDb()

        # Set the Glade file
        gladefile = "/usr/share/hypnotix/hypnotix.ui"
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(APP)
        self.builder.add_from_file(gladefile)
        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("Hypnotix"))
        self.window.set_icon_name("hypnotix")

        provider = Gtk.CssProvider()
        provider.load_from_path("/usr/share/hypnotix/hypnotix.css")
        screen = Gdk.Display.get_default_screen(Gdk.Display.get_default())
        # I was unable to found instrospected version of this
        Gtk.StyleContext.add_provider_for_screen(
            screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        # Prefs variables
        self.selected_pref_provider = None
        self.edit_mode = False

        # Create variables to quickly access dynamic widgets
        self.generic_channel_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
            "/usr/share/hypnotix/generic_tv_logo.png", 22, 22)
        widget_names = ["headerbar", "status_label", "status_bar", "sidebar", "go_back_button", "channels_box", \
            "provider_button", "preferences_button", \
            "mpv_drawing_area", "stack", "fullscreen_button", \
            "provider_ok_button", "provider_cancel_button", \
            "name_entry", "path_label", "path_entry", "browse_button", "url_label", "url_entry", \
            "username_label", "username_entry", "password_label", "password_entry", "epg_label", "epg_entry", \
            "tv_logo", "movies_logo", "series_logo", "tv_button", "movies_button", "series_button", \
            "tv_label", "movies_label", "series_label", \
            "categories_flowbox", \
            "channels_flowbox", \
            "vod_flowbox", \
            "episodes_box", \
            "stop_button", "pause_button", "show_button", "playback_label", "playback_bar", \
            "providers_flowbox", "new_provider_button", "reset_providers_button", \
            "delete_no_button", "delete_yes_button", \
            "reset_no_button", "reset_yes_button", \
            "info_section", "info_revealer", "info_name_label", "info_plot_label", "info_rating_label", "info_year_label", "close_info_button", \
            "info_genre_label", "info_duration_label", "info_votes_label", "info_pg_label", "divider_label", \
            "useragent_entry", "referer_entry", "mpv_entry", "mpv_link", \
            "mpv_stack", "spinner"]

        for name in widget_names:
            widget = self.builder.get_object(name)
            if widget == None:
                print("Could not find widget %s!" % name)
                sys.exit(1)
            else:
                setattr(self, name, widget)

        self.divider_label.set_text("/10")

        # Widget signals
        self.window.connect("key-press-event", self.on_key_press_event)
        self.mpv_drawing_area.connect("realize",
                                      self.on_mpv_drawing_area_realize)
        self.mpv_drawing_area.connect("draw", self.on_mpv_drawing_area_draw)
        self.fullscreen_button.connect("clicked",
                                       self.on_fullscreen_button_clicked)

        self.provider_ok_button.connect("clicked", self.on_provider_ok_button)
        self.provider_cancel_button.connect("clicked",
                                            self.on_provider_cancel_button)

        self.name_entry.connect("changed", self.toggle_ok_sensitivity)
        self.url_entry.connect("changed", self.toggle_ok_sensitivity)
        self.path_entry.connect("changed", self.toggle_ok_sensitivity)

        self.tv_button.connect("clicked", self.show_groups, TV_GROUP)
        self.movies_button.connect("clicked", self.show_groups, MOVIES_GROUP)
        self.series_button.connect("clicked", self.show_groups, SERIES_GROUP)
        self.go_back_button.connect("clicked", self.on_go_back_button)

        self.stop_button.connect("clicked", self.on_stop_button)
        self.pause_button.connect("clicked", self.on_pause_button)
        self.show_button.connect("clicked", self.on_show_button)

        self.provider_button.connect("clicked", self.on_provider_button)
        self.preferences_button.connect("clicked", self.on_preferences_button)

        self.new_provider_button.connect("clicked",
                                         self.on_new_provider_button)
        self.reset_providers_button.connect("clicked",
                                            self.on_reset_providers_button)
        self.delete_no_button.connect("clicked", self.on_delete_no_button)
        self.delete_yes_button.connect("clicked", self.on_delete_yes_button)
        self.reset_no_button.connect("clicked", self.on_reset_no_button)
        self.reset_yes_button.connect("clicked", self.on_reset_yes_button)

        self.browse_button.connect("clicked", self.on_browse_button)

        self.close_info_button.connect("clicked", self.on_close_info_button)

        # Settings widgets
        self.bind_setting_widget("user-agent", self.useragent_entry)
        self.bind_setting_widget("http-referer", self.referer_entry)
        self.bind_setting_widget("mpv-options", self.mpv_entry)

        # Menubar
        accel_group = Gtk.AccelGroup()
        self.window.add_accel_group(accel_group)
        menu = self.builder.get_object("main_menu")
        item = Gtk.ImageMenuItem()
        item.set_image(
            Gtk.Image.new_from_icon_name(
                "preferences-desktop-keyboard-shortcuts-symbolic",
                Gtk.IconSize.MENU))
        item.set_label(_("Keyboard Shortcuts"))
        item.connect("activate", self.open_keyboard_shortcuts)
        key, mod = Gtk.accelerator_parse("<Control>K")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        menu.append(item)
        item = Gtk.ImageMenuItem()
        item.set_image(
            Gtk.Image.new_from_icon_name("help-about-symbolic",
                                         Gtk.IconSize.MENU))
        item.set_label(_("About"))
        item.connect("activate", self.open_about)
        key, mod = Gtk.accelerator_parse("F1")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        menu.append(item)
        item = Gtk.ImageMenuItem(label=_("Quit"))
        image = Gtk.Image.new_from_icon_name("application-exit-symbolic",
                                             Gtk.IconSize.MENU)
        item.set_image(image)
        item.connect('activate', self.on_menu_quit)
        key, mod = Gtk.accelerator_parse("<Control>Q")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        key, mod = Gtk.accelerator_parse("<Control>W")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        menu.append(item)
        menu.show_all()

        # Type combox box (in preferences)
        model = Gtk.ListStore(str, str)  # PROVIDER_TYPE_ID, PROVIDER_TYPE_NAME
        model.append([PROVIDER_TYPE_URL, _("M3U URL")])
        model.append([PROVIDER_TYPE_LOCAL, _("Local M3U File")])
        model.append([PROVIDER_TYPE_XTREAM, _("Xtream API")])
        self.provider_type_combo = self.builder.get_object(
            "provider_type_combo")
        renderer = Gtk.CellRendererText()
        self.provider_type_combo.pack_start(renderer, True)
        self.provider_type_combo.add_attribute(renderer, "text",
                                               PROVIDER_TYPE_NAME)
        self.provider_type_combo.set_model(model)
        self.provider_type_combo.set_active(0)  # Select 1st type
        self.provider_type_combo.connect("changed",
                                         self.on_provider_type_combo_changed)

        self.tv_logo.set_from_pixbuf(
            GdkPixbuf.Pixbuf.new_from_file_at_size(
                "/usr/share/hypnotix/pictures/tv.svg", 258, 258))
        self.movies_logo.set_from_pixbuf(
            GdkPixbuf.Pixbuf.new_from_file_at_size(
                "/usr/share/hypnotix/pictures/movies.svg", 258, 258))
        self.series_logo.set_from_pixbuf(
            GdkPixbuf.Pixbuf.new_from_file_at_size(
                "/usr/share/hypnotix/pictures/series.svg", 258, 258))

        self.reload(page="landing_page")

        # Redownload playlists after a little while...
        GLib.timeout_add_seconds(60 * 5, self.force_reload)

        self.window.show()
        self.playback_bar.hide()
示例#17
0
    sp.getoutput("sudo ansible-playbook /mail.yml")


#--------------------------main------------------------------------------------------------

try:
    conn = mysql.connector.connect(user=secret.mysqluser(),
                                   password=secret.mysqlpwd(),
                                   host='localhost')
except:
    print("Error in connection to mysql")
mycursor = conn.cursor()

database()
tv = IMDb()

while True:
    receiver_emailid = input("Email address: ")
    Tv_series = input("Tv Series:")

    params = (receiver_emailid, Tv_series.lower())

    mycursor.execute("Insert into input_data(email,tv_series) values (%s,%s)",
                     params)
    conn.commit()
    mycursor.execute("select * from input_data")
    data = mycursor.fetchall()
    a = data[len(data) - 1]  # fetch the last input value from table
    s_list = a[1].split(
        ','
from imdb import IMDb
import csv
import re

#with open('zz-episode_data.csv', 'a') as csvfile:
#    writer = csv.writer(csvfile)

# process each title
with open('approved_titles.txt') as titles:
    for line in titles.readlines():
        title = line[:-1]
        i = IMDb()
        try:

            show_search = i.search_movie(title)
            ### get the id of the first search result

            tv_show = show_search[0].movieID

            ### use id to get the specific show
            show = i.get_movie(tv_show)
            if show['kind'] == 'tv series':
                #print title
                i.update(show, 'episodes')
                ### process each season and episode, print to csv
                for season in show['episodes']:
                    #print show['episodes'][season]
                    for episode in show['episodes'][season]:
                        #print episode
                        ep = show['episodes'][season][episode]
                        i.update(ep)
示例#19
0
def send_to_s3(conn, filename):
    api_stream = conn.get_bucket('flickbot-api')
    k = Key(api_stream)
    k.key = str(filename)
    k.set_contents_from_filename(filename, policy='public-read')


def save_to_json(filename, dict_name):
    with open(filename, 'w') as fp:
        json.dump(dict_name, fp, ensure_ascii=False, encoding='utf-8',
                  sort_keys=True)


if __name__ == '__main__':
    conn = IMDb()
    conn_s3 = S3Connection()
    credentials = yaml.load(open(os.path.expanduser(
                                 '~/admin/bot-api.yml')))
    youtube = build(credentials['youtube']["YOUTUBE_API_SERVICE_NAME"],
                    credentials['youtube']["YOUTUBE_API_VERSION"],
                    developerKey=credentials['youtube']["DEVELOPER_KEY"])
    in_theaters = "https://api.themoviedb.org/3/movie/now_playing?api_key=" \
                  + credentials['themoviedb']['API_KEY'] \
                  + "&language=en-US&page=1"
    coming_soon = "https://api.themoviedb.org/3/movie/upcoming?api_key=" \
                  + credentials['themoviedb']['API_KEY'] \
                  + "&language=en-US&page=1"
    genres_url = "https://api.themoviedb.org/3/genre/movie/list?api_key=" \
                 + credentials['themoviedb']['API_KEY'] \
                 + "&language=en-US"
示例#20
0
def tv_show_analysis(search_term):
    
    ia = IMDb()
    
    movie_search = search_term.title()
    
    all_data = ia.search_movie(movie_search)
    
    movie_id = all_data[0].movieID
    
    episodes = ia.get_movie_episodes(movie_id)
    seasons = episodes['data']['episodes']
    
    season_eps = []
    episode_ids = []
    
    j = 0
    while j < len(seasons):
        for x in seasons:
            season_eps.append(len(seasons[x]))
            for f in seasons[x]:
                episode_ids.append(seasons[x][f].movieID)
            j += 1
    
    season_eps_extend = []
    
    q = 0
    while q < len(season_eps):
        season_eps_extend.extend(repeat(q + 1, season_eps[q]))
        q += 1
    
    rating = []
    
    voting_demographics = ia.get_movie_vote_details(movie_id)
    
    age_ratings = []
    age_categories = ['Under 18', '18-29', '30-44', '45+']
    
    try:
        age_ratings.append(voting_demographics['data']['demographics']['aged under 18']['rating'])
    except:
        age_categories.pop(0)
    
    try:
        age_ratings.append(voting_demographics['data']['demographics']['aged 18 29']['rating'])
    except:
        age_categories.pop(1)
    
    try:
        age_ratings.append(voting_demographics['data']['demographics']['aged 30 44']['rating'])
    except:
        age_categories.pop(2)
    
    try:
        age_ratings.append(voting_demographics['data']['demographics']['aged 45 plus']['rating'])
    except:
        age_categories.pop(3)
    
    p = 0
    while p < len(episode_ids):
        try:
            rating.append(ia.get_movie_vote_details(episode_ids[p])['data']['arithmetic mean'])
            p += 1
        except:
            episode_ids.pop(p)
            season_eps_extend.pop(p)
            p += 1
    
    min_rating_index = rating.index(min(rating))
    min_rating_episode = ia.get_movie(episode_ids[min_rating_index])
    min_episode = str(min_rating_episode) + " (" + str(round(min(rating), 1)) + ")"
    
    max_rating_index = rating.index(max(rating))
    max_rating_episode = ia.get_movie(episode_ids[max_rating_index])
    max_episode = str(max_rating_episode) + " (" + str(round(max(rating), 1)) + ")"
    average_rating = round(statistics.mean(rating), 1)
    
    episodes = []
    myset = list(set(season_eps_extend))
    test = []
    for x in myset:
        test.append(season_eps_extend.count(x))
    
    for x in test:
        for j in range(1, x + 1):
            episodes.append(j)
    
    df = pd.DataFrame(list(zip(episodes, season_eps_extend, rating)), columns=['Episode', 'Season', 'Rating'])
    
    data = df.pivot("Episode", "Season", "Rating")
    
    figsize = (8.333 + 3.333 * max(season_eps_extend)), (6.666 + 0.8333 * max(episodes))
    font_size = round(22 / (8.333 + 3.333 * max(season_eps_extend)) * (6.666 + 0.8333 * max(episodes)))
    plt.style.use('dark_background')
    plt.rcParams['figure.facecolor'] = 'grey'
    plt.figure(figsize=figsize)
    font = {'family': 'DejaVu Sans',
            'weight': 'normal',
            'size': font_size}
    plt.rc('font', **font)
    ax = sns.heatmap(data, square=True, vmin=0, vmax=10, cmap="RdYlGn", annot=True, linewidths=.2,
                     annot_kws={"size": round((24.55 - .2758 * max(season_eps_extend)))})
    ax.set(ylim=(0, max(episodes)))
    ax.xaxis.set_ticks_position("top")
    ax.xaxis.set_label_position('top')
    plt.gca().invert_yaxis()
    ax.xaxis.labelpad = font_size
    ax.yaxis.labelpad = font_size
    ax.xaxis.label.set_size(round(font_size * 1.25))
    ax.yaxis.label.set_size(round(font_size * 1.25))
    plt.rcParams['figure.facecolor'] = 'grey'
    
    plot_name = 'test.png'
    plt.savefig(plot_name, facecolor=(0.15, 0.15, 0.15))
    
    plt.style.use('dark_background')
    
    plt_size = (figsize[0] * 0.45, figsize[1] * 0.45)
    plt.rcParams.update({'font.size': round(figsize[0] * 0.45 * figsize[1] * 0.45 * .3)})
    fig = plt.figure(figsize=plt_size)
    ax = fig.add_subplot(111)
    ax.bar(age_categories, age_ratings, label=age_ratings)
    ax.set(ylim=(1, 10.5))
    ax.axes.get_yaxis().set_visible(False)
    plt.title("Average Rating by Age Group")
    
    
    try:
        plt.annotate(str(age_ratings[0]), (-.15, age_ratings[0] + .25))
    except:
        pass
    
    try:
        plt.annotate(str(age_ratings[1]), (.85, age_ratings[1] + .25))
    except:
        pass
    
    try:
        plt.annotate(str(age_ratings[2]), (1.85, age_ratings[2] + .25))
    except:
        pass
    
    try:
        plt.annotate(str(age_ratings[3]), (2.85, age_ratings[3] + .25))
    except:
        pass
    
    line_name = 'line.png'
    plt.savefig(line_name, facecolor=(0.15, 0.15, 0.15))
    
    season_rating = []
    
    season_nums = []
    
    for x in myset:
        num = season_eps.count(x)
        season_nums.append(num)
    
    ep_count = 0
    season_index = 0
    while season_index < (len(season_eps) - 1):
        s = slice(int(ep_count), int((season_eps[season_index]) + sum(season_eps[0:season_index])))
        avg = statistics.mean(rating[s])
        season_rating.append(avg)
        ep_count += (season_eps[season_index])
        season_index += 1
    
    file1 = plot_name
    file2 = line_name
    
    best_season = season_rating.index(max(season_rating)) + 1
    worst_season = season_rating.index(min(season_rating)) + 1
    
    im2 = Image.open(file2)
    
    im1 = Image.open(file1)
    
    w1, h1 = im1.size
    w2, h2 = im2.size
    
    offset = (int(-15), ((h1 - h2) * 8) // 9)
    offset_text_title = (int(w2 * .1), ((h1 - h2) * 1) // 6)
    offset_text_body = (int(w2 * .1), ((h1 - h2) * 2) // 6)
    
    im1.paste(im2, offset)
    
    draw = ImageDraw.Draw((im1))
    
    title_font_size = (w1 * h1 * 0.00001857) + 32.142
    body_font_size = title_font_size * 0.58333
    
    title_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Semibold.ttf",
                                    round(title_font_size))
    
    font_width = 0.45
    body_font_height = 0.35
    
    while title_font.getsize(movie_search)[0] > font_width * im1.size[0]:
        title_font_size -= 1
        title_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Semibold.ttf",
                                        round(title_font_size))
    
    body_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Light.ttf",
                                   round(body_font_size))
    
    draw.text(offset_text_title, movie_search + " \n", font=title_font)
    
    body = "\n" + "Average Rating: " + str(average_rating) + "\n" + "\n" \
                                                                    "Best Season: " + str(best_season) + " (" + str(
        round(max(season_rating), 1)) + ")" + "\n" + "\n" \
                                                     "Worst Season: " + str(worst_season) + " (" + str(
        round(min(season_rating), 1)) + ")"
    
    while body_font.getsize("Average Rating: " + str(average_rating))[0] > font_width * im1.size[0]:
        body_font_size -= 1
        body_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Light.ttf",
                                       round(body_font_size))
    
    while body_font.getsize("Average Rating: " + str(average_rating))[1] * 6 > body_font_height * im1.size[1]:
        body_font_size -= 1
        body_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Light.ttf",
                                       round(body_font_size))
    
    draw.text(offset_text_body, body, font=body_font)

    signature_offset = (0, h1 - (h1 * 0.045))
    signature_font = ImageFont.truetype("/Users/cartermeetze/PycharmProjects/shows/open-sans/OpenSans-Light.ttf",
                                        round(body_font_size * 0.75))
    
    draw.text(signature_offset, "https://www.linkedin.com/in/carter-meetze/", font=signature_font)

    file_name = movie_search + " Analysis.png"
    im1.save(file_name)
    
    return file_name + " Created"
示例#21
0
 def __init__(self):
     self.dataSet = IMDb(reraiseExceptions=True)
示例#22
0
文件: movie.py 项目: abhijo89mi/movie
def main():

    count = 1
    data_fetched = 0
    if (len(sys.argv) > 1):
        count = sys.argv[1]
    ia = IMDb()
    # Get url from the tblmovieurl
    try:
        url_object = movieurl.objects.filter(runcount__lt=1)[:count]

        start_movie_id = url_object[0].id
    except:
        start_movie_id = 0
    total_count = int(count)
    total_run_count = 0
    extractor_statistics = Movie_Fetch_Statistics(
        start_date=datetime.now(),
        total_count=total_count,
        start_movie_imdbid=start_movie_id,
        total_run_count=total_run_count,
        end_date=datetime.now(),
        end_movie_imdbid=0)
    extractor_statistics.save()
    for url in url_object:
        sucess_factor = 0
        imdbid = url.imdbid.replace('tt', '')

        print "Get movie information : ", url.movie_name
        the_matrix = ia.get_movie(imdbid)

        tblmovie = fnMovie(the_matrix, sucess_factor)

        try:
            animation_department = the_matrix.data['animation department']
            for person in animation_department:

                tblperson = fnPerson(person, sucess_factor)
                tblanimation_department, c = Animation_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.animation_department.add(tblanimation_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            art_department = the_matrix.data['art department']
            for person in art_department:

                tblperson = fnPerson(person, sucess_factor)

                tblart_department, c = Art_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.art_department.add(tblart_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            art_direction = the_matrix.data['art direction']
            for person in art_direction:

                tblperson = fnPerson(person, sucess_factor)

                tblart_direction, c = Art_direction.objects.get_or_create(
                    name=tblperson)
                tblmovie.art_direction.add(tblart_direction)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            assistant_director = the_matrix.data['assistant director']
            for person in assistant_director:

                tblperson = fnPerson(person, sucess_factor)

                tblassistant_director, c = Assistant_director.objects.get_or_create(
                    name=tblperson)
                tblmovie.assistant_director.add(tblassistant_director)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            camera_and_electrical_department = the_matrix.data[
                'camera and electrical department']
            for person in camera_and_electrical_department:

                tblperson = fnPerson(person, sucess_factor)

                tblcamera_and_electrical_department, c = Camera_and_electrical_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.camera_and_electrical_department.add(
                    tblcamera_and_electrical_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            casting_department = the_matrix.data['casting department']
            for person in casting_department:

                tblperson = fnPerson(person, sucess_factor)

                tblcasting_department, c = Casting_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.casting_department.add(tblcasting_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:

            casting_director = the_matrix.data['casting director']
            for person in casting_director:

                tblperson = fnPerson(person, sucess_factor)

                tblcasting_director, c = Casting_director.objects.get_or_create(
                    name=tblperson)
                tblmovie.casting_director.add(tblcasting_director)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:

            cinematographer = the_matrix.data['cinematographer']
            for person in cinematographer:

                tblperson = fnPerson(person, sucess_factor)

                tblcinematographer, c = Cinematographer.objects.get_or_create(
                    name=tblperson)
                tblmovie.cinematographer.add(tblcinematographer)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            costume_department = the_matrix.data['costume department']
            for person in costume_department:

                tblperson = fnPerson(person, sucess_factor)

                tblcostume_department, c = Costume_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.costume_department.add(tblcostume_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            costume_designer = the_matrix.data['costume designer']
            for person in costume_designer:

                tblperson = fnPerson(person, sucess_factor)

                tblcostume_designer, c = Costume_designer.objects.get_or_create(
                    name=tblperson)
                tblmovie.costume_designer.add(tblcostume_designer)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            director = the_matrix.data['director']
            for person in director:

                tblperson = fnPerson(person, sucess_factor)
                tbldirector, c = Director.objects.get_or_create(name=tblperson)
                tblmovie.director.add(tbldirector)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:

            editor = the_matrix.data['editor']
            for person in editor:

                tblperson = fnPerson(person, sucess_factor)

                tbleditor, c = Editor.objects.get_or_create(name=tblperson)
                tblmovie.editor.add(tbleditor)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            make_up = the_matrix.data['make up']
            for person in make_up:

                tblperson = fnPerson(person, sucess_factor)

                tblmake_up, c = Make_up.objects.get_or_create(name=tblperson)
                tblmovie.make_up.add(tblmake_up)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            miscellaneous_crew = the_matrix.data['miscellaneous crew']
            for person in miscellaneous_crew:

                tblperson = fnPerson(person, sucess_factor)

                tblmiscellaneous_crew, c = Miscellaneous_crew.objects.get_or_create(
                    name=tblperson)
                tblmovie.miscellaneous_crew.add(tblmiscellaneous_crew)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            music_department = the_matrix.data['music department']
            for person in music_department:

                tblperson = fnPerson(person, sucess_factor)

                tblmusic_department, c = Music_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.music_department.add(tblmusic_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            original_music = the_matrix.data['original music']
            for person in original_music:

                tblperson = fnPerson(person, sucess_factor)

                tbloriginal_music, c = Original_music.objects.get_or_create(
                    name=tblperson)
                tblmovie.original_music.add(tbloriginal_music)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:

            producer = the_matrix.data['producer']
            for person in producer:

                tblperson = fnPerson(person, sucess_factor)
                tblproducer, c = Producer.objects.get_or_create(name=tblperson)
                tblmovie.producer.add(tblproducer)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:

            production_design = the_matrix.data['production design']
            for person in production_design:

                tblperson = fnPerson(person, sucess_factor)
                tblproduction_design, c = Production_design.objects.get_or_create(
                    name=tblperson)
                tblmovie.production_design.add(tblproduction_design)

        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            production_manager = the_matrix.data['production manager']
            for person in production_manager:

                tblperson = fnPerson(person, sucess_factor)
                tblproduction_manager, c = Production_manager.objects.get_or_create(
                    name=tblperson)
                tblmovie.production_manager.add(tblproduction_manager)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            set_decoration = the_matrix.data['set decoration']
            for person in set_decoration:

                tblperson = fnPerson(person, sucess_factor)
                tblset_decoration, c = Set_decoration.objects.get_or_create(
                    name=tblperson)
                tblmovie.set_decoration.add(tblset_decoration)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            sound_crew = the_matrix.data['sound crew']
            for person in sound_crew:

                tblperson = fnPerson(person, sucess_factor)
                tblsound_crew, c = Sound_crew.objects.get_or_create(
                    name=tblperson)
                tblmovie.sound_crew.add(tblsound_crew)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            special_effects_department = the_matrix.data[
                'special effects department']
            for person in special_effects_department:

                tblperson = fnPerson(person, sucess_factor)
                tblspecial_effects_department, c = Special_effects_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.special_effects_department.add(
                    tblspecial_effects_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            stunt_performer = the_matrix.data['stunt performer']
            for person in stunt_performer:

                tblperson = fnPerson(person, sucess_factor)
                tblstunt_performer, c = Stunt_performer.objects.get_or_create(
                    name=tblperson)
                tblmovie.stunt_performer.add(tblstunt_performer)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            transportation_department = the_matrix.data[
                'transportation department']
            for person in transportation_department:

                tblperson = fnPerson(person, sucess_factor)
                tbltransportation_department, c = Transportation_department.objects.get_or_create(
                    name=tblperson)
                tblmovie.transportation_department.add(
                    tbltransportation_department)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            visual_effects = the_matrix.data['visual effects']
            for person in visual_effects:

                tblperson = fnPerson(person, sucess_factor)
                tblvisual_effects, c = Visual_effects.objects.get_or_create(
                    name=tblperson)
                tblmovie.visual_effects.add(tblvisual_effects)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            writer = the_matrix.data['writer']
            for person in writer:

                tblperson = fnPerson(person, sucess_factor)
                tblwriter, c = Writer.objects.get_or_create(name=tblperson)
                tblmovie.writer.add(tblwriter)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            distributors = the_matrix.data['distributors']
            for company in distributors:

                tblperson = fnCompany(company)
                tbldistributors, c = Distributors.objects.get_or_create(
                    name=tblperson)
                tblmovie.distributors.add(tbldistributors)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            miscellaneous_companies = the_matrix.data[
                'miscellaneous companies']
            for company in miscellaneous_companies:

                tblcompany = fnCompany(company)
                tblmiscellaneous_companies, c = Miscellaneous_companies.objects.get_or_create(
                    name=tblcompany)
                tblmovie.miscellaneous_companies.add(
                    tblmiscellaneous_companies)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            production_companies = the_matrix.data['production companies']
            for company in production_companies:

                tblcompany = fnCompany(company)
                tblproduction_companies, c = Production_companies.objects.get_or_create(
                    name=tblcompany)
                tblmovie.production_companies.add(tblproduction_companies)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            special_effects_companies = the_matrix.data[
                'special effects companies']
            for company in special_effects_companies:

                tblcompany = fnCompany(company)
                tblspecial_effects_companies, c = Special_effects_companies.objects.get_or_create(
                    name=tblcompany)
                tblmovie.special_effects_companies.add(
                    tblspecial_effects_companies)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            cast = the_matrix.data['cast']
            for person in cast:

                tblcharactor = fnCharactor(person)
                tblperson = fnPerson(person, sucess_factor)
                tblcast, c = Cast.objects.get_or_create(name=tblperson)
                tblcast.charactor.add(tblcharactor)
                tblmovie.cast.add(tblcast)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            akas = the_matrix.data['akas']
            for name in akas:
                tblakas, c = Akas.objects.get_or_create(name=name)
                tblmovie.akas_id.add(tblakas)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            plot = the_matrix.data['plot']
            for name in plot:
                tblplot, c = Plot.objects.get_or_create(name=name)
                tblmovie.plot.add(tblplot)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            certificates = the_matrix.data['certificates']

            for name in certificates:
                tblcertificates, c = Certificates.objects.get_or_create(
                    name=name)
                tblmovie.certificates.add(tblcertificates)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass
        try:
            color_info = the_matrix.data['color info']
            for name in color_info:
                tblcolor_info, c = Color_info.objects.get_or_create(color=name)
                tblmovie.color_info.add(tblcolor_info)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            genres = the_matrix.data['genres']
            for display_name in genres:
                name = display_name.replace('-', '_').lower()
                tblgenres, c = Genre.objects.get_or_create(
                    display_name=display_name, name=name)
                tblmovie.genres.add(tblgenres)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            runtimes = the_matrix.data['runtimes']
            for name in runtimes:
                tblruntimes, c = Runtimes.objects.get_or_create(name=name)
                tblmovie.runtimes.add(tblruntimes)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            countries = the_matrix.data['countries']
            code = the_matrix.data['country codes']
            i = 0
            for name in countries:
                tblcountries, c = Countries.objects.get_or_create(name=name,
                                                                  code=code[i])
                tblmovie.countries.add(tblcountries)
                i = i + 1
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            sound_mix = the_matrix.data['sound mix']
            for name in sound_mix:
                tblsound_mix, c = Sound_mix.objects.get_or_create(name=name)
                tblmovie.sound_mix.add(tblsound_mix)
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        try:
            languages = the_matrix.data['languages']
            code = the_matrix.data['language codes']
            i = 0
            for name in languages:
                tbllanguages, c = Languages.objects.get_or_create(name=name,
                                                                  code=code[i])
                tblmovie.languages.add(tbllanguages)
                i = i + 1
        except Exception as e:
            print e
            sucess_factor = sucess_factor + 1
            pass

        url.runcount += 1
        url.last_rundate = datetime.now()
        url.save()

        #Update Statistics
        extractor_statistics.total_run_count += 1
        extractor_statistics.end_date = datetime.now()
        extractor_statistics.end_movie_imdbid = url.id
        extractor_statistics.save()

    return 0
示例#23
0
import urlparse

from chalice import Chalice
from imdb import IMDb

app = Chalice(app_name='imdbbot')
imdb = IMDb()


def to_response(text, public=True):
    response = {
        'text': text,
        'unfurl_links': True
    }

    if public:
        response['response_type'] = 'in_channel'

    return response


@app.route('/', cors=True)
def handler():
    title = app.current_request.query_params.get('text', None)

    if not title:
        return to_response('Need a movie title, stupid', public=False)

    results = imdb.search_movie(title)

    if results:
示例#24
0
        for name in self.movie_list:
            print(name)
            try:
                db = IMDb()
                result = db.search_movie(name)
                movie_ids = []
                cache = []
                for i, r in enumerate(result):
                    movieobj = db.get_movie(r.movieID)
                    cache.append([r.movieID, movieobj])
                    movie_ids.append(r.movieID)

                    if i > 5:
                        break

                self.signals.callback.emit(cache)

            except Exception as e:
                self.error.emit(e)


if __name__ == '__main__':
    db = IMDb()
    m = db.get_movie("0075640")
    for k in m.__dict__.keys():
        print(k, m.__dict__[k])
    print(db.get_imdbID(m))
    # result = db.search_movie("Matrix")
    # for r in result:
    #     movieobj = db.get_movie(r.movieID)
    #     print(movieobj.keys())
import pandas as pd
import numpy as np
from imdb import IMDb

##Creating the IMDb instance
ia = IMDb()

## Creating CSV filepath variables
movies_csv_path = "Resources/AllMoviesDetailsCleaned.csv"
streaming_csv_path = "Resources/MoviesOnStreamingPlatforms_updated.csv"

movies_df = pd.read_csv(movies_csv_path, encoding="utf-8", delimiter=";", parse_dates=["release_date"])
streaming_df = pd.read_csv(streaming_csv_path, encoding="utf-8", parse_dates=["Year"])

#Uniforming the dates between both CSVs.
movies_df["release_date"] = movies_df["release_date"].dt.year
streaming_df["Year"] = streaming_df["Year"].dt.year
movies_df = movies_df.loc[(movies_df["release_date"].isnull() != True),:]
movies_df["release_date"] = movies_df["release_date"].astype(int)


### Creating a merged dataframe on Title and Year
super_merge = pd.merge(movies_df, streaming_df, left_on=["title", "release_date"], right_on=["Title", "Year"]).reset_index(drop=True)
super_merge['genres'] = super_merge['genres'].str.replace(pat="|", repl=",")
movie_merge = pd.merge(movies_df, streaming_df, left_on=["title", "release_date"], right_on=["Title", "Year"]).reset_index(drop=True)
desiredColumns = ['title', 'genres', 'Genres', 'release_date', 'budget', 'revenue', 'Runtime', 'Country', 'Language', 'spoken_languages_number', 'Age', 'popularity', 'vote_average', 'vote_count', 'imdb_id', 'IMDb', 'Rotten Tomatoes', 'Directors']
super_merge = super_merge.loc[:, desiredColumns]

#cleaned up imdb_id with a left strip. now this id is usable with the imdb module
super_merge['imdb_id'] = super_merge['imdb_id'].str.lstrip('tt')
示例#26
0
def imdb_ia_fixture() -> IMDb:
    """Return the IMDb class."""
    return IMDb()
示例#27
0
def getEps(title,max_len=1024,debug=False):
	"""Returns a text string containing schedule info for the last aired and the next upcoming episodes for the given TV series title"""

	# Validate title
	assert isinstance(title,str), 'A string input was not provided.'

	# Preprocess title
	title=title.strip()

	# Determine if the next upcoming episode's plot should be included if available (Default is True)
	if title.lower().endswith('/noplot'):
		title=title[:-len('/noplot')].rstrip()
		include_plot=False
	else:
		include_plot=True

	try:

		# Validate title further
		if len(title)==0: return 'A title was not provided.'
	
		# Create IMDb object
		i=IMDb()
	
		# Get search results
		max_attempts=3 # Set to anything greater than 1
		for attempt in range(1,max_attempts+1):
			try:
				search_results=i.search_movie(title)
				break
			except:
				if attempt<max_attempts:
					if debug: print 'An error occurred while attempting to retrieve search results for "%s". %s attempts were made.'%(title,attempt)+'\n'
					sleep(attempt*2)
				else:
					return 'An error occurred while attempting to retrieve search results for "%s". %s attempts were made.'%(title,attempt)
		del attempt,max_attempts
	
		# Get first search result that is a TV series
		search_results=ifilter(lambda s:s['kind']=='tv series',search_results)
		search_results=list(islice(search_results,0,1))
		if len(search_results)==0: return 'No TV series match was found for "%s".'%title
		s=search_results[0]
		del search_results
	
		# Get episodes
		i.update(s,'episodes')
		s_title=s['long imdb title']
		if (not s.has_key('episodes')) or len(s['episodes'])==0: return 'Episode info is unavailable for %s.'%s_title
		s=sortedEpisodes(s)
		if len(s)==0: return 'Episode info is unavailable for %s.'%s_title
	
		# Sort episodes in approximately the desired order
		s.reverse() # This results in episodes that are sorted in the desired order. If, however, the episodes are not listed in proper order at the source, such as for "Showtime Championship Boxing" (1987) as of 2/29/08, the error will be copied here.
		s=list(dropwhile(lambda e:e['season']=='unknown',s))+list(takewhile(lambda e:e['season']=='unknown',s)) # While this may not always produce the most accurate results, it prevents episodes belonging to an unknown season from being thought of as most recent.
	
		# Process date related info for episodes
		date_today=date.today()
		for ep_ind in xrange(len(s)):
			if s[ep_ind].has_key('original air date'):
				try:
					s[ep_ind]['date']=strptime(s[ep_ind]['original air date'],'%d %B %Y')
				except:	pass
			if s[ep_ind].has_key('date'):
				s[ep_ind]['date']=date(*s[ep_ind]['date'][0:3])
				s[ep_ind]['age']=(s[ep_ind]['date']-date_today).days # Age is date delta in days
				if s[ep_ind]['age']<0:
					s[ep_ind]['has aired']=True
				else:
					s[ep_ind]['has aired']=False
			else:
				s[ep_ind]['has aired']=False
		del date_today,ep_ind
	
		# Print last 10 listed episodes (if debugging)
		if debug:
			print 'Last 10 listed episodes:\nS# Epi# Age   Episode Title'
			for e in s[:10]: print '%s %s %s %s'%(str(e['season']).zfill(2)[:2],str(e['episode']).zfill(4),e.has_key('age') and str(e['age']).zfill(5) or ' '*5,e['title'].encode('latin-1'))
			print
	
		# Declare convenient functions for use in generating output string
		def getSE(e):
			if not isinstance(e['season'],int): return ''
			Sstr='S'+str(e['season']).zfill(2)
			Estr='E'+str(e['episode']).zfill(2)
			return ' ('+Sstr+Estr+')'
		def getAge(e): return locale.format('%i',abs(e['age']),grouping=True)
		def getDate(e): return 'i.e. on '+e['date'].strftime('%a, ')+str(e['date'].day)+e['date'].strftime(' %b %y')
	
		# Determine last aired episode
		# (An episode that airs today is considered to be not yet aired)
		e=ifilter(lambda e:e['has aired'],s)
		e=list(islice(e,0,1))
		if len(e)>0:
			e=e[0]
			e_schedule= e['age']!=-1 and ('%s days ago'%getAge(e)) or 'yesterday'
	
			# Generate output string when last aired episode is available
			e_out='The episode that aired last for '+s_title+' is "'+e['title']+'"'+getSE(e)+'. It aired '+e_schedule+', '+getDate(e)+'. '
			del e_schedule
	
		else:
			# Generate output string when last aired episode is unavailable
			e_out=''
	
		# Determine next upcoming episode
		# (An episode that airs today is considered to be an upcoming episode)
		e=list(takewhile(lambda e:e['has aired']==False,s)) # Memory inefficient
		if len(e)>0:
			e=e[-1]
	
			# Generate output string when next upcoming episode is available
			e_out=e_out+'The next upcoming episode '+(e_out=='' and ('for '+s_title+' ') or '')+'is "'+e['title']+'"'+getSE(e)+'.'
	
			if e.has_key('age'):
				e_schedule= e['age']>1 and ('in %s days'%getAge(e)) or e['age']==1 and 'tomorrow' or e['age']==0 and 'today'
				e_out=e_out+' It airs '+e_schedule+', '+getDate(e)+'.'
				del e_schedule
			else:
				e_out=e_out+' Its air date is unavailable.'
	
			if include_plot:
				if e.has_key('plot') and e['plot']!='Related Links':
					e_out=e_out+' Its plot is: '+e['plot']
				elif e_out.endswith('Its air date is unavailable.'):
					e_out=e_out.replace('Its air date is unavailable.','Its air date and plot are unavailable.')
				else:
					e_out=e_out+' Its plot is unavailable.'
	
		else:
			if e_out!='': # Last: available; Next: unavailable
				e_out=e_out+'No upcoming episode is scheduled.'
			else: # Last: unavailable; Next: unavailable
				e_out='Episode info is unavailable for %s.'%s_title
	
		# Conditionally trim output string
		if (max_len not in [0,None]) and len(e_out)>max_len-3: e_out=e_out[:max_len-3]+'...'
	
		# Return output string
		return e_out

	except:	return 'An unknown error occurred while attempting to retrieve episode info for "%s".'%title
示例#28
0
from imdb import IMDb
import pickle

IA = IMDb()

## getting top 250 movies
top250 = IA.get_top250_movies()
dump = pickle.dumps(top250)

with open('top250.dat', 'wb') as file:
    file.write(dump)
示例#29
0
from bs4 import BeautifulSoup
import requests
import re
from imdb import IMDb
import json
from textblob import TextBlob

ia = IMDb()  # create an imdb instance

url = "https://www.filmsite.org/boxoffice.html"  # url from which the names of the top grossing movies are scraped from

url_request = requests.get(url)

soup = BeautifulSoup(url_request.content, 'html.parser')  # gets content

scrape = soup.find_all("li")  # saving all li tags

data = []
for names in scrape:  # saving just the text from the tags
    data.append(names.text)
# maybe combine lines 20 till 38 maybe in a function see if you can do a sapply like thing
titles = []

for x in data:  # from the text, saving only the movie titles
    if re.match(r">?.*\d{4}", x, re.DOTALL):
        titles.append(x)

clean = []
for title in titles:  # cleaning the movie title names
    title = re.sub(r"Filmsite.org", "", title)
    title = re.sub(r"\r|\n", "", title)
def get_plot(title):
    id = movieLink.get(title)
    movie = IMDb().get_movie(id)
    return movie['plot']