def show_movie(self, event_=None): from movies import movie from info import userinfo try: self.dict = self.userr_coll.aggregate([{ '$match': { '_id': self.userr } }]) x = list(self.dict)[0] except: self.userr_coll.insert_one({ '_id': f'{self.userr}', 'movie': [], 'recommanded': [] }) self.dict = self.userr_coll.aggregate([{ '$match': { '_id': self.userr } }]) x = list(self.dict)[0] docs = x['movie'] if len(docs) == 0: c = userinfo(self.master, self.lst, self.userr_coll, self.userr) else: c = movie(self.lst, self.master, self.userr_coll, self.userr)
def show_movie(self): from info import userinfo from movies import movie if self.db.userr.movie.find({}).count() == 0: c = userinfo(self.master, self.lst, self.db, self.userr) else: c = movie(self.lst,self.master) self.destroy()
def show_movie(self, ): from movies import movie from info import userinfo self.dict = self.userr_coll.aggregate([{ '$match': { '_id': self.userr_name } }]) x = list(self.dict)[0] docs = x['movie'] if len(docs) == 0: c = userinfo(self.master, self.lst, self.userr_coll, self.userr_name) else: c = movie(self.lst, self.master, self.userr_coll, self.userr_name) self.destroy()
def __init__(self,lst,master,userr_coll,userr_name): self.userr_coll = userr_coll self.userr_name = userr_name self.master = master self.lst = [] Template.__init__(self, self.lst, self.master) self.master.title('movies') self.key = -1 try: self.client = pymongo.MongoClient("localhost",27017) self.db = self.client except Exception as e: messagebox.showinfo("Info", e) self.d = self.db.sample_mflix.movies.aggregate([{'$project': {'title': 1}}]) for dic in self.d: self.lst.append(dic['title']) self.movie_list = [] self.names_list = list(self.userr_coll.find({}))[0]['recommanded'] for i in range(10): self.dict = self.db.sample_mflix.movies.aggregate([{'$match': {'title': f'{self.names_list[i]}'}}, {'$limit': 10}]) try: url = list(self.dict)[0]['poster'] except: url = 'https://m.media-amazon.com/images/M/MV5BYzk0YWQzMGYtYTM5MC00NjM2LWE5YzYtMjgyNDVhZDg1N2YzXkEyXkFqcGdeQXVyMzE0MjY5ODA@._V1_SY1000_SX677_AL_.jpg' page = requests.get(url) load = Image.open(io.BytesIO(page.content)) load = load.resize((200, 70), Image.ANTIALIAS) self.movie_list.append(load) self.update_list() self.dict = self.userr_coll.aggregate([{'$match': {'_id': self.userr_name}}]) x = list(self.dict)[0] docs = x['movie'] if len(docs)==0: c = userinfo(self.master,self.lst,self.userr_coll,self.userr_name)
def after_login(self): bottom = Frame(self.master, height=660, width=1536, bg='#2b2929') bottom.place(x=0, y=85) img = Image.open('images/movies_image.png') img = img.resize((400, 300), Image.ANTIALIAS) df = pd.read_csv('data/userProfile.csv') df = df.sort_values(by='0', ascending=False) reduce_df = df[df['0'] > 8] print(df) figure1 = plt.Figure(figsize=(6, 5), dpi=100, facecolor='#2b2929') ax1 = figure1.add_subplot(111) canvas = FigureCanvasTkAgg(figure1, self.master) canvas.get_tk_widget().place(x=250, y=85) y = reduce_df['0'].values labels = reduce_df['Unnamed: 0'].values if len(y) == 0: y = df['0'][:3].values labels = df['Unnamed: 0'][:3].values myexplode = [0.2] for i in range(len(y) - 1): myexplode.append(0) patches, texts, autotexts = ax1.pie(y, labels=labels, startangle=90, shadow=True, explode=myexplode, autopct='%1.1f%%', textprops={'color': "w"}) Label(bottom, text='Recently Watched..', fg='white', font=("Ink Free", 35), bg='#2b2929').place(x=1100, y=10) Label(bottom, text='User Stats', fg='white', font=("Ink Free", 35), bg='#2b2929').place(x=0, y=10) Frame(bottom, height=12, width=1536, bg='#5e5d5b').place(x=0, y=500) Frame(bottom, height=500, width=17, bg='#5e5d5b').place(x=1050, y=0) myfont = Font(family='Ink Free', size=20, weight='bold') try: self.dict = self.userr_coll.aggregate([{ '$match': { '_id': self.userr } }]) x = list(self.dict)[0] except: self.userr_coll.insert_one({ '_id': f'{self.userr}', 'movie': [], 'recommanded': [] }) self.dict = self.userr_coll.aggregate([{ '$match': { '_id': self.userr } }]) x = list(self.dict)[0] docs = x['movie'] if len(docs) == 0: c = userinfo(self.master, self.lst, self.userr_coll, self.userr) else: doc = self.userr_coll.find({}) movie = list(doc)[0]['movie'] movie = pd.DataFrame(movie) movie.drop_duplicates(subset='title', keep='last', inplace=True) movie = movie.tail() for i, title in enumerate(movie['title']): if i % 2 == 0: Label(bottom, text=f'{5-i}. {title}', fg='#6dad86', font=myfont, bg='#2b2929', anchor=W).place(x=1100, y=260 - i * 35) else: Label(bottom, text=f'{5-i}. {title}', fg='#f0b34a', font=myfont, bg='#2b2929', anchor=W).place(x=1100, y=260 - i * 35) Button(bottom, padx=170, font=("Ink Free", 35), fg='#f7ad5e', bg='#383736', text="Movies", command=self.show_movie).place(x=500, y=536)