def contentById(param): id = param['id'] x = Videos() obj = {} obj2 = {} hash = param['hash'] publc = str(param['publc']) # create a hash m = md5.new(id + publc + _private_key()) # check if this hash is equal to the one transmitted if m.hexdigest() == hash: # get the user's playlists # if username is blank, data will be false pl = Playlists() playlists = pl.getPlaylists(param) data = x.allPublicById(id) if data: obj = { 'detail': 1, # this is a detail page 'id': data[0][0], 'category': data[0][1], 'tags': data[0][2], 'data': data[0][3], 'video_id': data[0][4], 'playlists': playlists #'date_added' : data[0][4] } recommend = x.recommendedByTags(id, obj['tags'], obj['category']) i = 0 if recommend: for item in recommend: obj2[i] = { 'id' : item[0], 'uniq': item[1], 'data' : item[7] } i = i + 1 else: obj2 = False obj['recommend'] = obj2 else: obj = { 'message': 'no record found' } else: obj = { 'message': 'authentication failure' } return obj
def allEmbed(param): x = Videos() username = param['username'] hash = param['hash'] publc = param['publc'] # create a hash m = md5.new(username + publc + _private_key()) # check if this hash is equal to the one transmitted if m.hexdigest() == hash: data = x.allUserData(param) if data: embeds = {} i = 0 for item in data: embeds[i] = { 'id' : item[0], 'category' : item[1], 'tags' : item[2], 'data' : item[3], 'is_public' : item[4], 'pkid' : item[5] #'date_added': item[5] } i = i + 1 else: embeds = False # get the user's playlists # if username is blank, data will be false pl = Playlists() playlists = pl.getPlaylists(param) dat = { 'data': embeds, #'records': x.allUserDataCount(param), 'playlists': playlists, 'id': 1234 } else: dat = { 'data': False, #'records' : 0, 'playlists': False, 'id': 1234 } return dat
def playlists(param): x = Playlists() data = False records = 0 hash = param['hash'] publc = param['publc'] username = param['username'] src = param['src'] if username == 'false': username = '' param = { 'username' : username, 'curPage' : param['curPage'], 'limit' : param['limit'] } m = md5.new(publc + _private_key()) if username: # check if this hash is equal to the one transmitted if m.hexdigest() == hash: if src == 'home': data = x.getPublicPlaylists(param) records = x.getPublicPlaylistsCount(param) else: data = x.getPlaylists(param) else: # check if this hash is equal to the one transmitted if m.hexdigest() == hash: data = x.getPublicPlaylists(param) records = x.getPublicPlaylistsCount(param) return { 'data': data, 'records': records, 'id': 1234 }
def allEmbedFromTags(param): x = Videos() username = param['username'] data = x.allUserData(username) if data: embeds = {} i = 0 for item in data: embeds[i] = { 'id' : item[0], 'category' : item[1], 'tags' : item[2], 'data' : item[3], 'is_public' : item[4], 'pkid' : item[5] #'date_added': item[5] } i = i + 1 else: embeds = False # get the user's playlists # if username is blank, data will be false pl = Playlists() param = { 'username' : username } playlists = pl.getPlaylists(param) dat = { 'data': embeds, 'playlists': playlists, 'id': 1234 } return dat