Exemplo n.º 1
0
def search(param):
	x = Videos()
	p = Playlists()
	
	hash = param['hash']
	publc = param['publc']
	
	# create a hash
	m = md5.new(publc + _private_key())

	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
		data = x.allPublicBySearch(param)
		
		obj = {}
		i = 0
		if data:
			for item in data:
				obj[i] = {
					'id' : item[0],
					'category' : item[1],
					'tags' : item[2],
					'data' : item[3]
					#'date_added': item[4]
				}
				i = i + 1
		else:
			obj = data
		
		dat = {
			'id': 1234, # just a random id
			'data': obj,
			'records': x.allPublicBySearchCount(param),
		}
	return dat
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
def deleteEmbed(hash, publc, id):
	x = Videos()
	
	# create a hash
	m = md5.new(id + publc + _private_key())
	if m.hexdigest() == hash:
		param = {
			'hash': hash,
			'id': id
		}
		bool = x.deleteEmbed(param)
		dat = { 'response' : bool }
	else:
		dat = { 'response': 'failed' }
		
	return dat
Exemplo n.º 5
0
def set_public(hash, publc, is_public, id):
	x = Videos()
	
	# create a hash
	m = md5.new(id + publc + _private_key())
	
	if m.hexdigest() == hash:
		param = {
			'id': id,
			'is_public': is_public
		}
		bool = x.embedToPublic(param)
		dat = { 'response' : bool }
	else:
		dat = { 'response': 'failed' }
		
	return dat
Exemplo n.º 6
0
def tagscloud(hash, publc):
	x = Videos()
	
	# create a hash
	m = md5.new(publc + _private_key())
	
	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
		data = x.getAllTags()
		dat = {
			'id': 1234, # just a random id
			'data': data
		}
	else:
		dat = {
			'id': 1234, # just a random id
			'data': False
		}
	return dat
Exemplo n.º 7
0
def contents(param):
	x = Videos()
	
	hash = param['hash']
	publc = param['publc']
	type = param['type']
	
	# create a hash
	m = md5.new(publc + _private_key())

	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
	
		data = x.allPublicByType(param)
		
		obj = {}
		i = 0
		if data:
			for item in data:
				obj[i] = {
					'id' : item[0],
					'category' : item[1],
					'tags' : item[2],
					'data' : item[3]
					#'date_added': item[4]
				}
				i = i + 1
		else:
			obj = False
		
		dat = {
			'id': 1234, # just a random id
			'records': x.countRecords('videos', type, 1),
			'data': obj
		}
	else:
		dat = {
			'id': 1234, # just a random id
			'records': 0,
			'data': False
		}
	return dat
Exemplo n.º 8
0
def main(param):
	x = Videos()
	
	hash = param['hash']
	publc = param['publc']
	
	# create a hash
	m = md5.new(publc + _private_key())

	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
	
		data = x.allPublic(param)
		
		if data:
			obj = {}
			i = 0
			for item in data:
				obj[i] = {
					'id' : item[0],
					'category' : item[1],
					'tags' : item[2],
					'data' : item[3]
					#'date_added': item[4]
				}
				i = i + 1
		else:
			obj = False
			
		dat = {
			'data': obj,
			'records': x.countRecords('videos', '', 1),
			'id': 1234
		}
	else:
		dat = {
			'data': False,
			'records': 0,
			'id': 1234
		}
	
	return dat
Exemplo n.º 9
0
def cat_data():
	x = Videos()
	categ = x.allCategories()
	embedly = x.embedlyKey()
	
	#reassemble data into an object
	obj = {}
	i = 0
	for item in categ:
		obj[i] = {
			'id' : item[0],
			'name' : item[1]
		}
		i = i + 1
	
	data = {
		'key'	: embedly,
		'data'	: obj
	}
	return data
Exemplo n.º 10
0
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
Exemplo n.º 11
0
def embed_data(param):
	x = Videos()
	
	hash = param['hash']
	publc = str(param['publc'])

	# create a hash
	m = md5.new(publc + _private_key())

	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
		#param arrived 'encodeURIComponent' from the front end so use urllib.unquote_plus to decode
		data = {
			'data': urllib.unquote_plus(param['data']),
			'username' : param['username'],
			'is_public' : param['is_public'],
			'category' : param['category'],
			'tags' : param['tags'],
			'is_approved' : 0
		}

		return x.embed(data)
	else:
		return 'failed'