Пример #1
0
    def movieAI(user_id):
        user = User.get_by_id(user_id)
        movielist = []
        liked = user.getliked()
        unliked = user.getunliked()
        unwatched = user.getunwatched()
        favourites = user.getfavourites()
        print(favourites)
        all = Movie.get_topmovies()
        likedgenre = []
        likedcategory = []
        likedids = []
        unlikedids = []
        favouriteids = []
        unwatchedids = []
        for i in liked:
            likedgenre.append(i["genre"])
            likedcategory.append(i["category"])
            likedids.append(i["_id"])
        for i in unliked:
            unlikedids.append(i["_id"])
        for i in favourites:
            favouriteids.append(i["_id"])
        for i in unwatched:
            unwatchedids.append(i["_id"])

        likedgenre = list(dict.fromkeys(likedgenre))
        likedcategory = list(dict.fromkeys(likedcategory))

        for i in all:
            if i.genre in likedgenre and i.category in likedcategory:
                movielist.append(i)

        for i in all:
            movielist.append(i)

        new_list = []
        for v in movielist:
            if v._id not in favouriteids and v._id not in likedids and v._id not in unlikedids and v._id not in unwatchedids:
                new_list.append(v)

        new_list = list(dict.fromkeys(new_list))
        return new_list
Пример #2
0
 def add_to_user_unliked(self, user_id):
     user = User.get_by_id(user_id)
     user.addtounliked(self._id)
Пример #3
0
 def add_to_user_favourite(self, user_id):
     user = User.get_by_id(user_id)
     user.addtofavorites(self._id)