示例#1
0
 def delete_review(self, review_id):
     item = return_node(review_id, 'Reviews', 'ID', nodeValue=True)
     bucket = storage.bucket(app=app_fb)
     blob = bucket.blob(item[0][1]['Poster'])
     blob.delete()
     db.child("Reviews").child(item[0][0]).remove()
     return 'Review ID : ' + str(item[0][0]) + ' of movie number : ' + str(review_id) + ' was deleted'
示例#2
0
 def get_numbers(self):
     return {
         'totalReviews' : len(db.child('Reviews').get().val()),
         'totalMessages' : 0 if isinstance(db.child('Contact-Us').get().val(), type(None)) else len(db.child('Contact-Us').get().val()),
         'instagram' : sum(
             i['Instagram'] == 1 for i in list(db.child('Reviews').get().val().values())
         )
     }
示例#3
0
 def delete_message(self):
     string = request.args.get('message_id')
     string1 = string.replace('+',' ')
     string2 = string1.replace('%3A',':')
     string3 = string2.replace('%2F','/')
     message_id = return_node(string3, 'Contact-Us', 'Subject')
     db.child("Contact-Us").child(message_id[0]).remove()
     return 'Message ID: ' + str(message_id) + ' was deleted'
示例#4
0
    def update_review(self, update_data, update_id):
        updated_list = {
            'Name' : update_data.name.data,
            'Review' : update_data.review.data,
            'Netflix' : bool2binary(update_data.netflix.data),
            'Prime' : bool2binary(update_data.prime.data),
            'Director' : update_data.director.data,
            'Acting': update_data.acting.data,
            'Story': update_data.story.data,
            'Execution': update_data.execution.data,
            'Profundity': update_data.profundity.data,
            'Overall': update_data.overall.data,
            'Genre1': update_data.genre1.data,
            'Genre2': update_data.genre2.data,
            'Links': update_data.link.data,
        }

        if update_data.image.data is None:
            db.child("Reviews").child(update_id).update(updated_list)
        else:

            old_img = db.child('Reviews').child(update_id).get().val()['Poster']
            bucket = storage.bucket(app=app_fb)
            blob = bucket.blob(old_img)
            blob.delete()

            save_poster(update_data.image.data)
            f_name,f_ext = os.path.splitext(update_data.image.data.filename)
            picture_fn = f_name + f_ext
            filePath = 'Extra/Images/' + picture_fn
            bucket = storage.bucket(app=app_fb)
            blob = bucket.blob(picture_fn)
            blob.upload_from_filename(filePath)
            blob.make_public()

            updated_list['Poster'] = picture_fn
            updated_list['Image'] = blob.public_url
            db.child("Reviews").child(update_id).update(updated_list)
            remove_img('Extra/Images', picture_fn)
示例#5
0
    def upload_review(self, input_data, token):

        save_poster(input_data.image.data)
        f_name,f_ext = os.path.splitext(input_data.image.data.filename)
        picture_fn = f_name + f_ext
        filePath = 'Extra/Images/' + picture_fn
        bucket = storage.bucket(app=app_fb)
        blob = bucket.blob(picture_fn)
        blob.upload_from_filename(filePath)
        blob.make_public()
        
        dets = MovieInfo(input_data.name.data)

        DB_entry = {
            'ID' : len(db_data.get_reviews()) + 1,
            'Name': input_data.name.data,
            'Review': input_data.review.data,
            'Instagram': 0,
            'Netflix': bool2binary(input_data.netflix.data),
            'Prime': bool2binary(input_data.prime.data),
            'Year': int(dets['year']),
            'Director': input_data.director.data,
            'Lead': str(dets['actors'][0]) + ', ' + str(dets['actors'][1]),
            'Acting': float(input_data.acting.data),
            'Story': float(input_data.story.data),
            'Execution': float(input_data.execution.data),
            'Profundity': float(input_data.profundity.data),
            'Overall': float(input_data.overall.data),
            'Poster': picture_fn,
            'Genre1': input_data.genre1.data,
            'Genre2': input_data.genre2.data,
            'Links': input_data.link.data,
            'Image': blob.public_url,
            'Trailer': dets['trailer']
        }

        result = db.child("Reviews").push(DB_entry, token['idToken'])
        # result = db.child("Reviews").push(DB_entry, user_token['idToken'])
        print(result)
        remove_img('Extra/Images', picture_fn)
示例#6
0
def return_node(id,database, prop, nodeValue=False):
    if nodeValue:
        return [[rev.key(), rev.val()] for rev in db.child(database).get().each() if rev.val()[prop] == id]
    return [rev.key() for rev in db.child(database).get().each() if rev.val()[prop] == id]
示例#7
0
 def get_messages(self):
     my_messages = list(db.child('Contact-Us').get().val().values())
     my_messages.reverse()
     return my_messages
示例#8
0
 def get_reviews(self):
     my_reviews = list(db.child('Reviews').get().val().values())
     my_reviews.reverse()
     return my_reviews
示例#9
0
# import gspread
# from oauth2client.service_account import ServiceAccountCredentials
# scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
# creds = ServiceAccountCredentials.from_json_keyfile_name('./static/credentials.json',scope)
# clients = gspread.authorize(creds)
# sheet = clients.open('mbts_reviews').sheet1
# data = sheet.get_all_records()

import requests
from modules import db

data = list(db.child('Reviews').get().val().values())
data_sf = list(db.child('Short_Films').get().val().values())


def userInput(query):
    url = "https://imdb-internet-movie-database-unofficial.p.rapidapi.com/film/"+query

    headers = {
        'x-rapidapi-host': "imdb-internet-movie-database-unofficial.p.rapidapi.com",
        'x-rapidapi-key' : "42a81c1684msh89e08ede69c15b4p1df539jsn876cffad9666"
        }

    response = requests.request("GET", url, headers=headers)
    store = response.json()

    count = 0
    actors = list()
    for i in store["cast"]:
        if count > 5:
            break
示例#10
0
 def update_ig(self, review_id):
     item = return_node(review_id, 'Reviews', 'ID')
     db.child("Reviews").child(item[0]).update({'Instagram':1})
     return 'Review ID : ' + str(item) + ' was updated to Instagram'