예제 #1
0
 def find_all(cls):
     sql = cls.query
     df = pd.read_sql(sql.statement, sql.session.bind)
     df_movie_id = df['mov_id']
     print(df_movie_id[0])
     print(len(df['mov_id']))
     count = 0
     for movie in df_movie_id:
         df_movie_id[count] = MovieDao.find_by_id(movie).title_kor 
         print(MovieDao.find_by_id(movie).title_kor)
         count += 1
     return json.loads(df.to_json(orient='records'))
예제 #2
0
 def delete(mov_id):
     print('***** MOVIE DELETE *****')
     movie = MovieDao.find_by_id(mov_id)  # Primary Key로 삭제하려는 리뷰의 Row를 불러옴.
     try:
         MovieDao.delete_movie(movie.mov_id)  # 해당 리뷰를 데이터베이스에서 삭제
         return {'code': 0, 'message': 'SUCCESS'}, 200
     except:
         return {'message': 'An error occured deleting the movie'}, 500
    def get(self, title_naver_eng):
        print("영화 추천")
        print(f'ID : {title_naver_eng}')

        ai = self.movieai
        recommendation_df = ai.hook(title_naver_eng)
        print(recommendation_df)
        recommendation_mov_id = recommendation_df['id']
        print(recommendation_mov_id)
        mov_id_list = recommendation_df['id'].tolist()
        print(mov_id_list)


        # a = MovieDao.find_by_id(mov_id_list[0])
        # print(a)
        # print(a.json())
        movie_list = []
        for i in mov_id_list:
            print(i)
            try:
                movie = MovieDao.find_by_id(i)
                movie_list.append(movie)
            except:
                print('없는 영화')
            if len(movie_list) >= 6:
                break

        movie_json_list = []
        for d in movie_list:
            movie_json_list.append(d.json())
        
        print('***** end *****')
        print(movie_json_list)

        return movie_json_list

# if __name__ == "__main__":
#     t = MovieRecommendation()
#     t.hook()