def setCat():
    if request.method == "POST":
        cat = request.form["Category"]
        category = Individual()
        res = category.Insert_Genres(cat)
        if res:
            return "Saved"
        return "fail"

    Geners = Movies()
    return Response(json.dumps(Geners.Full_Genres()),
                    mimetype='application/json')
def setCast():
    if request.method == "POST":
        cast = request.form["Name"]
        casts = Individual()
        res = casts.Insert_Actor(cast)
        if res:
            return "Saved"
        return "fail"

    Actors = Movies()
    return Response(json.dumps(Actors.Full_Actors()),
                    mimetype='application/json')
def setDr():
    if request.method == "POST":
        dr = request.form["Name"]
        drs = Individual()
        res = drs.Insert_Director(dr)
        if res:
            return "Saved"
        return "fail"

    Directors = Movies()
    return Response(json.dumps(Directors.Full_Directors()),
                    mimetype='application/json')
def Update():
    m_id = request.form['Id']
    updated_name = request.form["Name"]
    updated_link = request.form["Link"]
    updated_type = request.form["Type"]
    updated_cast = request.form["Cast"]
    updated_director = request.form["Dr"]
    updated_blurb = request.form["Blurb"]
    f = request.files['Poster']

    updated_poster = secure_filename(f.filename)
    f.save(os.path.join('./static/MoviePoster', updated_poster))

    Object = Movies()
    Object.Movies_update(mid=m_id,
                         mname=updated_name,
                         drname=updated_director,
                         acname=updated_cast,
                         genname=updated_type,
                         ml=updated_link,
                         mblrb=updated_blurb,
                         mp=updated_poster)
    return "Done"
def saveDetails():
    if request.method == "POST":
        name = request.form["Name"]
        tp = request.form["Type"]
        cast = request.form["Cast"]
        dr = request.form["Dr"]
        b = request.form["Blurb"]
        link = request.form["Link"]
        f = request.files['Poster']
        poster = secure_filename(f.filename)
        f.save(os.path.join('./static/MoviePoster', poster))
        print(poster)
        movie = Movies()
        movie.Movies_Insert(mname=name,
                            acname=cast,
                            drname=dr,
                            genname=tp,
                            mblrb=b,
                            mp=poster,
                            ml=link)

    App = Movies()
    return Response(json.dumps(App.DisplayAll(1)), mimetype='application/json')
def getStarted():
    gtStart = Movies()
    return Response(json.dumps(gtStart.DisplayGetStarted()),
                    mimetype='application/json')
def getCount(count):
    a = int(count)
    Ct = Movies()
    return Response(json.dumps(Ct.DisplayAll(a)), mimetype='application/json')
def RemoveMovie(query):
    Obj = Movies()
    Obj.Movies_delete(a=query)
    return "Successfully Deleted"
def GetNMovie(mid):
    A = Movies()
    return Response(json.dumps(A.Movies_Data_Display(a=mid)),
                    mimetype='application/json')