Пример #1
0
def get_single_movie(val, page):
    connection = db_starter()
    query = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename), cp.id_cast, cp.id_plot, group_concat(gg.genre)
        from movies as mm 
        left join cast_plot as cp on cp.id_movie = mm.idmovies
        left join movie_genre as mg on mg.id_movie = mm.idmovies
        left join genre as gg on gg.idgenre = mg.id_genre
        left join movie_url as mu on mu.id_movie = mm.idmovies
        left join url as uu on uu.idurl = mu.id_url
        left join trail_img as tm on tm.id_movie = mm.idmovies
        left join site as ss on ss.idsite = uu.id_site
        where mm.idmovies = {}
        GROUP BY (mm.idmovies);'''.format(val)

    data = []
    genre_list = []
    result = connection.execute(query)

    for row in result:
        temp_dict = {}
        temp_dict['movie_id'] = row[0]
        temp_dict['movie_name'] = row[1]
        temp_dict['img'] = row[2]
        temp_dict['y_src'] = row[3]
        try:
            urls = list(set(row[4].split(',')))
        except:
            urls = []
        try:
            platforms = list(set(row[5].split(',')))
        except:
            platforms = []

        temp_dict['cast'] = row[6]
        temp_dict['plot'] = row[7]
        try:
            temp_dict['genres'] = list(set(row[8].split(',')))
            genre_list = list(set(row[8].split(',')))
        except:
            temp_dict['genres'] = []
            genre_list = []

        plat_dict = {}
        for pp in platforms:
            for url in urls:
                if pp.lower() in url:
                    plat_dict[pp] = url
                    break
        temp_dict['platforms'] = plat_dict
        data.append(temp_dict)

    connection.close()

    if genre_list == []:
        genre_list = ['action', 'comedy', 'adventure']

    similar_titles = get_similar_titles(genre_list, page, False)
    return {'data': data, 'similar': similar_titles}
Пример #2
0
def get_movies_name(val):
    connection = db_starter()
    sql_query = 'Select movie from movies where movie like ' + '"%%' + val + '%%";'
    data = []
    result = connection.execute(sql_query)
    for row in result:
        data.append(row[0])

    connection.close()
    return {"data": data}
Пример #3
0
def get_similar_titles(genre_list, page, language_bool):
    offset = (int(page) - 1)*42
    connection=db_starter()
    query = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename), group_concat(gg.genre)
            from movies as mm 
            left join movie_url as mu on mu.id_movie = mm.idmovies
            left join url as uu on uu.idurl = mu.id_url
            left join trail_img as tm on tm.id_movie = mm.idmovies
            left join site as ss on ss.idsite = uu.id_site
            left join movie_genre as mg on mg.id_movie = mm.idmovies
            left join genre as gg on gg.idgenre = mg.id_genre
            left join rating as rr on rr.idrating = mm.idmovies
            where gg.genre in  ('{}')'''.format("', '".join(genre_list))
            
    
    if language_bool:
        query = query + " AND ll.lang like 'Hindi%%'"
    
    query = query + ''' GROUP BY (mm.idmovies)
            ORDER BY rr.id_rate Desc
            Limit {}, 42;'''.format(offset)

    data = []
    result = connection.execute(query)

    for row in result:
        temp_dict = {}
        temp_dict['movie_id'] = row[0]
        temp_dict['movie_name'] = row[1]
        temp_dict['img'] = row[2]
        temp_dict['y_src'] = row[3]
        try:
            urls = list(set(row[4].split(',')))
        except:
            urls = []
        try:
            platforms = list(set(row[5].split(',')))
        except:
            platforms = []
        
        plat_dict = {}
        for pp in platforms:
            for url in urls:
                if pp.lower() in url:
                    plat_dict[pp] = url
                    break
        temp_dict['platforms'] = plat_dict
        data.append(temp_dict)
    
    random.shuffle(data)
    connection.close()
    return data
Пример #4
0
def feed_back(feedback1):
    connection=db_starter()
    feedback2=feedback1
    email=feedback2["feedback"]["email"]
    first_name=feedback2["feedback"]["first_name"]
    last_name=feedback2["feedback"]["last_name"]
    question=feedback2["feedback"]["question"]
    feedback=feedback2["feedback"]["feedback"]
    quick_review=feedback2["feedback"]["quick_review"]
    
    sql="INSERT INTO feedback(email, first_name, last_name, question, feedback, quick_review) VALUES(:a,:b,:c,:d,:e,:f)"
    sql_query = sqlalchemy.text(sql)
    result = connection.execute(sql_query,a=str(email),b=str(first_name),c=str(last_name),d=str(question),e=str(feedback),f=str(quick_review))
    mail_content = "Name:-"+str(first_name)+" "+str(last_name)+"\nFeedback:-"+str(feedback)+"\nQuick Review:-"+str(quick_review)+"\nQuestion:-"+str(question)+"\nEmail:-"+str(email)
    #The mail addresses and password
    sender_address = '*****@*****.**'
    sender_pass = "******"
    receiver_address = '*****@*****.**'
    #Setup the MIME
    message = MIMEMultipart()
    message['From'] = sender_address
    message['To'] = receiver_address
    message['Subject'] = 'FlickHub Feedback'   #The subject line
    #The body and the attachments for the mail
    message.attach(MIMEText(mail_content, 'plain'))
    #Create SMTP session for sending the mail
    session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
    session.starttls() #enable security
    session.login(sender_address, sender_pass) #login with mail_id and password
    text = message.as_string()
    session.sendmail(sender_address, receiver_address, text)
    session.quit()
    connection.close()
    print('Mail Sent')
    
    
    
Пример #5
0
def title_render(id_mov):
    connection = db_starter()
    name = []
    genre = []
    site = []
    url = []
    im = []
    rate = []
    yr = []
    vt = []
    cst = []
    pl = []
    trail = []
    sql = "SELECT movies.movie,\
        genre.genre,url.url,site.sitename,rating.id_rate,votes.id_votes,\
        cast_plot.id_cast,cast_plot.id_plot,trail_img.id_img,trail_img.id_trail,\
        year.id_year \
        from movies \
        INNER JOIN movie_genre ON movie_genre.id_movie = movies.idmovies \
        INNER JOIN genre ON movie_genre.id_genre = genre.idgenre \
        INNER JOIN movie_url ON movies.idmovies = movie_url.id_movie \
        INNER JOIN url ON movie_url.id_url = url.idurl \
        INNER JOIN site ON url.id_site = site.idsite \
        INNER JOIN rating ON movies.idmovies = rating.idrating \
        INNER JOIN votes ON movies.idmovies = votes.idvotes \
        INNER JOIN cast_plot ON movies.idmovies = cast_plot.id_movie \
        INNER JOIN trail_img ON movies.idmovies = trail_img.id_movie \
        INNER JOIN year ON movies.idmovies = year.idyear \
         "

    w = "WHERE "
    n2 = "movies.idmovies = :a LIMIT 1"
    t = sql + w + n2
    sql_query = sqlalchemy.text(t)
    result = connection.execute(sql_query, a=id_mov)
    result_as_list = result.fetchall()
    for row in result_as_list:
        name.append(row[0])
        genre.append(row[1])
        url.append(row[2])
        site.append(row[3])
        rate.append(row[4])
        vt.append(row[5])
        cst.append(row[6])
        pl.append(row[7])
        im.append(row[8])
        trail.append(row[9])
        yr.append(row[10])

    ##remove duplictes##
    th = []
    name1 = []
    genre1 = []

    url1_site1 = {}
    im1 = []
    rate1 = []
    yr1 = []
    vt1 = []
    cst1 = []
    pl1 = []
    trail1 = []
    id_mv1 = []
    for i in range(len(name)):
        th.append(name[i] + "#" + site[i])
    th = list(dict.fromkeys(th))
    th1 = []
    for i in range(len(th)):
        try:

            for j in range(len(name)):
                if (th[i] == name[j] + "#" + site[j]):
                    url1_site1[name[j]][site[j]] = url[j]
                    name1.append(name[j])
                    genre1.append(genre[j])
                    rate1.append(rate[j])
                    vt1.append(vt[j])
                    cst1.append(cst[j])
                    pl1.append(pl[j])
                    im1.append(im[j])
                    trail1.append(trail[j])
                    yr1.append(yr[j])
                    id_mv1.append(id_mv[j])

                    name.remove(name[j])
                    genre.remove(genre[j])
                    rate.remove(rate[j])
                    vt.remove(vt[j])
                    cst.remove(cst[j])
                    pl.remove(pl[j])
                    im.remove(im[j])
                    trail.remove(trail[j])
                    yr.remove(yr[j])
                    id_mv.remove(id_mv[j])
                    break

        except:

            url1_site1[th[i].split("#")[0]] = {}
            for j in range(len(name)):
                if (th[i] == name[j] + "#" + site[j]):
                    g2 = []
                    for k in range(len(name)):

                        if (name[k] == name[j]):
                            g2.append(genre[k])
                        g2 = list(dict.fromkeys(g2))
                        g3 = ""
                        for m in g2:
                            g3 = g3 + m + ' '

                    url1_site1[name[j]][site[j]] = url[j]
                    name1.append(name[j])
                    genre1.append(g3)
                    rate1.append(rate[j])
                    vt1.append(vt[j])
                    cst1.append(cst[j])
                    pl1.append(pl[j])
                    im1.append(im[j])
                    trail1.append(trail[j])
                    yr1.append(yr[j])
                    id_mv1.append(id_mv[j])

                    name.remove(name[j])
                    genre.remove(genre[j])
                    rate.remove(rate[j])
                    vt.remove(vt[j])
                    cst.remove(cst[j])
                    pl.remove(pl[j])
                    im.remove(im[j])
                    trail.remove(trail[j])
                    yr.remove(yr[j])
                    id_mv.remove(id_mv[j])
                    break
            pass
    resp_data = []

    for i in range(len((name1))):
        temp_dict = {}
        temp_dict["urlname"] = url1_site1[name1[i]]
        temp_dict["image"] = im1[i]
        temp_dict["name"] = name1[i]
        temp_dict["image"] = im1[i]
        temp_dict["genre"] = genre1[i]
        temp_dict["rate"] = rate1[i]
        temp_dict["year"] = yr1[i]
        temp_dict["votes"] = vt1[i]
        temp_dict["cast"] = cst1[i]
        temp_dict["plot"] = pl1[i]
        temp_dict["trailer"] = trail1[i]
        temp_dict["id_mov"] = id_mv1[i]

        resp_data.append(temp_dict)

    return (resp_data)
Пример #6
0
def filter_movies(params, page):
    offset = (int(page) - 1) * 42
    connection = db_starter()
    query_init = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename)
        from movies as mm 
        left join movie_url as mu on mu.id_movie = mm.idmovies
        left join url as uu on uu.idurl = mu.id_url
        left join trail_img as tm on tm.id_movie = mm.idmovies
        left join site as ss on ss.idsite = uu.id_site
        left join rating as rr on rr.idrating = mm.idmovies
        left join movie_genre as mg on mg.id_movie = mm.idmovies
        left join genre as gg on gg.idgenre = mg.id_genre
        left join year as yy on yy.idyear = mm.idmovies'''

    filter_param = "where "
    if params.get('genre_bool', False):
        filter_param = filter_param + "gg.genre IN ({}) AND".format(
            params['genres'])
    if params.get('rating_bool', False):
        filter_param = filter_param + " rr.id_rate >= {} AND rr.id_rate <= {} AND".format(
            params['rating'][0],
            int(params['rating'][0]) + 1)
    if params.get('platform_bool', False):
        filter_param = filter_param + " ss.sitename IN ({}) AND".format(
            params['platforms'])
    if params.get('year_bool', False):
        filter_param = filter_param + " yy.id_year IN ({}) AND".format(
            params['years'])

    ending = '''GROUP BY (mm.idmovies)
    ORDER BY rr.id_rate Desc
    limit {}, 42
    ;'''.format(offset)

    query = query_init + ' ' + filter_param.strip('AND') + ' ' + ending
    data = []
    result = connection.execute(query)

    for row in result:
        temp_dict = {}
        temp_dict['movie_id'] = row[0]
        temp_dict['movie_name'] = row[1]
        temp_dict['img'] = row[2]
        temp_dict['y_src'] = row[3]
        try:
            urls = list(set(row[4].split(',')))
        except:
            urls = []
        try:
            platforms = list(set(row[5].split(',')))
        except:
            platforms = []

        plat_dict = {}
        for pp in platforms:
            for url in urls:
                if pp.lower() in url:
                    plat_dict[pp] = url
                    break
        temp_dict['platforms'] = plat_dict
        data.append(temp_dict)

    connection.close()
    return {'data': data}
Пример #7
0
def random_cat():
    query = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename)
        from movies as mm 
        left join movie_url as mu on mu.id_movie = mm.idmovies
        left join url as uu on uu.idurl = mu.id_url
        left join trail_img as tm on tm.id_movie = mm.idmovies
        left join site as ss on ss.idsite = uu.id_site
        left join rating as rr on rr.idrating = mm.idmovies
        join movie_genre as mg on mg.id_movie = mm.idmovies
        join genre as gg on gg.idgenre = mg.id_genre
        join movie_lang as ml on ml.id_movie = mm.idmovies
        join language as ll on ll.idlanguage = ml.id_lang
        where gg.genre like '{}%%' and ll.lang like 'Hindi%%'
        GROUP BY (mm.idmovies)
        ORDER BY rr.id_rate Desc
        limit 100
        ;'''
    
    query_fav = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename)
        from movies as mm 
        left join movie_url as mu on mu.id_movie = mm.idmovies
        left join url as uu on uu.idurl = mu.id_url
        left join trail_img as tm on tm.id_movie = mm.idmovies
        left join site as ss on ss.idsite = uu.id_site
        left join rating as rr on rr.idrating = mm.idmovies
        left join movie_genre as mg on mg.id_movie = mm.idmovies
        left join genre as gg on gg.idgenre = mg.id_genre
        left join movie_lang as ml on ml.id_movie = mm.idmovies
        left join language as ll on ll.idlanguage = ml.id_lang
        where mm.idmovies in (2358, 6062, 293, 326, 848, 469, 905, 8749, 1166, 4162)
        GROUP BY (mm.idmovies)
        ORDER BY rr.id_rate Desc
        ;'''
    
    connection=db_starter()
    categories = ['comedy', 'animation', 'action', 'adventure', 'horror']
    
    main_data = {}
    randomlist = random.sample(range(1, 50), 10)
    
    for category in categories:
        temp_int = 0
        query_cat = query.format(category)
        data = []
        result = connection.execute(query_cat)

        for row in result:
            temp_int = temp_int + 1
            if temp_int not in randomlist:
                continue
            temp_dict = {}
            temp_dict['movie_id'] = row[0]
            temp_dict['movie_name'] = row[1]
            temp_dict['img'] = row[2]
            temp_dict['y_src'] = row[3]
            try:
                urls = list(set(row[4].split(',')))
            except:
                urls = []
            try:
                platforms = list(set(row[5].split(',')))
            except:
                platforms = []
            
            plat_dict = {}
            for pp in platforms:
                for url in urls:
                    if pp.lower() in url:
                        plat_dict[pp] = url
                        break
            temp_dict['platforms'] = plat_dict
            data.append(temp_dict)
        
        main_data[category] = data
    
    result_fav = connection.execute(query_fav)
    data = []

    for row in result_fav:
        temp_dict = {}
        temp_dict['movie_id'] = row[0]
        temp_dict['movie_name'] = row[1]
        temp_dict['img'] = row[2]
        temp_dict['y_src'] = row[3]
        try:
            urls = list(set(row[4].split(',')))
        except:
            urls = []
        try:
            platforms = list(set(row[5].split(',')))
        except:
            platforms = []
        
        plat_dict = {}
        for pp in platforms:
            for url in urls:
                if pp.lower() in url:
                    plat_dict[pp] = url
                    break
        temp_dict['platforms'] = plat_dict
        data.append(temp_dict)
    
    main_data['flickhub_fav'] = data
    
    return {'data': main_data}
Пример #8
0
def search_movies(val, page):
    connection=db_starter()
    query = '''Select mm.idmovies, mm.movie, tm.id_img, tm.id_trail, group_concat(uu.url), group_concat(ss.sitename), group_concat(gg.genre)
            from movies as mm 
            left join movie_url as mu on mu.id_movie = mm.idmovies
            left join url as uu on uu.idurl = mu.id_url
            left join trail_img as tm on tm.id_movie = mm.idmovies
            left join site as ss on ss.idsite = uu.id_site
            left join movie_genre as mg on mg.id_movie = mm.idmovies
            left join genre as gg on gg.idgenre = mg.id_genre
            where mm.movie like '%%{}%%'
            GROUP BY (mm.idmovies);'''.format(val)

    data = []
    result = connection.execute(query)

    genre_list = []

    for row in result:
        temp_dict = {}
        temp_dict['movie_id'] = row[0]
        temp_dict['movie_name'] = row[1]
        temp_dict['img'] = row[2]
        temp_dict['y_src'] = row[3]
        try:
            urls = list(set(row[4].split(',')))
        except:
            urls = []
        try:
            platforms = list(set(row[5].split(',')))
        except:
            platforms = []
        
        plat_dict = {}
        for pp in platforms:
            for url in urls:
                if pp.lower() in url:
                    plat_dict[pp] = url
                    break
        temp_dict['platforms'] = plat_dict
        try:
            genre_list.extend(row[6].split(','))
        except:
            pass
        data.append(temp_dict)
    
    genres = []

    while(genre_list != []):
        genres.append(most_frequent(genre_list))
        genre_list = list(filter((most_frequent(genre_list)).__ne__, genre_list))
        if len(genres) == 3:
            break

    
    if genres == []:
        genres = ['action', 'comedy', 'adventure']

    similar_titles = get_similar_titles(genres, page, False)
    connection.close()
    
    return {'data': data, 'similar': similar_titles}
Пример #9
0
from db_initiate import search_movies, random_cat
from filter import get_movies_name, get_single_movie, filter_movies
from feedback import feed_back
from title import title_render
from pytube import YouTube
from flask_cors import CORS
import youtube_dl

from db_start import db_starter
from flask_cors import CORS
import annek

app = Flask(__name__, template_folder="/home/ubuntu/build")
CORS(app)

connection = db_starter()
# Build required files
path = '/home/ubuntu/build/'


@app.route('/')
def hello():
    return render_template('index.html')


@app.route('/public/manifest.json')
def manifest():
    return render_template('manifest.json')


@app.route('/public/logo192.png')