コード例 #1
0
def getmovies():
    name = User.get_by_email(session['email']).name
    searchlist = []
    query = request.form['search']
    movies = Movie.get_all_movies()
    for m in movies:
        if search(query, m.title):
            print(m.title)
            searchlist.append(m)
    request1 = youtube.search().list(part="snippet",
                                     maxResults=5,
                                     q=query + "movie trailer",
                                     topicId="/m/02vxn",
                                     regionCode="US")
    responselist = request1.execute()
    responselist1 = responselist["items"]
    print(responselist1)

    for response in responselist1:
        try:
            videoId = response["id"]["videoId"]
        except:
            print("something went wrong")
            videoId = None
        title = response["snippet"]["title"]
        poster = response["snippet"]["thumbnails"]["high"]["url"]
        if videoId != None and poster != None and title != None:
            link = "https://www.youtube.com/watch?v=" + videoId
            movie = Movie(title, "search", "search", "", poster, link)
            searchlist.append(movie)
    return render_template("search.html", movies=searchlist, name=name)
コード例 #2
0
def profile():
    user = User.get_by_email(session['email'])
    name = user.name
    movieslist = Movie.movieAI(user._id)
    random.shuffle(movieslist)
    m = movieslist[0]
    return render_template("main.html", name=name, m=m)
コード例 #3
0
def unlike(movieid):
    user = User.get_by_email(session['email'])
    userunliked = user.getunliked()
    for u in userunliked:
        if u["_id"] == movieid:
            print("already added to unliked")
            return redirect("/profile")
    user.addtounliked(movieid)
    return redirect("/profile")
コード例 #4
0
def add_to_unwatched(movieid):
    user = User.get_by_email(session['email'])
    userunwatched = user.getunwatched()
    for u in userunwatched:
        if u["_id"] == movieid:
            print("already added to favourites")
            return redirect("/profile")
    user.addtounwatched(movieid)
    return redirect("/profile")
コード例 #5
0
def add_to_favourites(movieid):
    user = User.get_by_email(session['email'])
    userfavourites = user.getfavourites()
    for u in userfavourites:
        if u["_id"] == movieid:
            print("already added to favourites")
            return redirect("/profile")
    user.addtofavorites(movieid)
    return redirect("/profile")
コード例 #6
0
def getunwatchedcache():
    user = User.get_by_email(session['email'])
    userunwatched = user.getunwatched()
    return userunwatched
コード例 #7
0
def getlikedcache():
    user = User.get_by_email(session['email'])
    userliked = user.getliked()
    return userliked
コード例 #8
0
def getfavcache():
    user = User.get_by_email(session['email'])
    userfavourites = user.getfavourites()
    return userfavourites
コード例 #9
0
def getbolly():
    user = User.get_by_email(session['email'])
    name = user.name
    movies = Movie.get_bollywood()
    return render_template("bollywood.html", movies=movies, name=name)
コード例 #10
0
def gettopmovies():
    user = User.get_by_email(session['email'])
    movies = Movie.get_topmovies()
    name = user.name
    return render_template("topmovies.html", movies=movies, name=name)
コード例 #11
0
def getunwatched():
    user = User.get_by_email(session['email'])
    name = user.name
    userunwatched = getunwatchedcache()
    print(userunwatched)
    return render_template("unwatched.html", movies=userunwatched, name=name)
コード例 #12
0
def getliked():
    user = User.get_by_email(session['email'])
    name = user.name
    userliked = getlikedcache()
    return render_template("liked.html", movies=userliked, name=name)
コード例 #13
0
def getfavourites():
    user = User.get_by_email(session['email'])
    name = user.name
    userfavourites = getfavcache()
    return render_template("favourites.html", movies=userfavourites, name=name)