示例#1
0
文件: main.py 项目: jd5688/embedible
def contentsByTagPl(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 = p.getPublicPlaylistsByTag(param)
		dat = {
			'id': 1234, # just a random id
			'data': data,
			'records': p.getPublicPlaylistsByTagCount(param)
		}
	else:
		dat = {
			'id': 1234, # just a random id
			'data': False,
			'records': 0
		}
	return dat
示例#2
0
文件: main.py 项目: jd5688/embedible
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
示例#3
0
文件: user.py 项目: jd5688/embedible
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
示例#4
0
文件: user.py 项目: jd5688/embedible
def deletePlaylist(hash, publc, pl_id):
	x = Playlists()
	
	# create a hash
	m = md5.new(pl_id + publc + _private_key())
	
	if m.hexdigest() == hash:
		param = {
			'pl_id': pl_id
		}
		bool = x.deletePlaylist(param)
		dat = { 'response' : bool }
	else:
		dat = { 'response': 'failed' }
		
	return dat
示例#5
0
文件: user.py 项目: jd5688/embedible
def set_pl_public(hash, publc, is_public, pl_id):
	x = Playlists()
	
	# create a hash
	m = md5.new(pl_id + publc + _private_key())
	
	if m.hexdigest() == hash:
		param = {
			'pl_id': pl_id,
			'is_public': is_public
		}
		bool = x.playlistToPublic(param)
		dat = { 'response' : bool }
	else:
		dat = { 'response': 'failed' }
		
	return dat
示例#6
0
文件: user.py 项目: jd5688/embedible
def add_to_playlist(hash, publc, atpl_id, list_ids):
	x = Playlists()
	
	# create a hash
	m = md5.new(atpl_id + publc + _private_key())
	
	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
		param = {
			'atpl_id' : atpl_id,
			'list_ids': list_ids
		}
		data = x.add_to_playlist(param)
		dat = { 'response' : data }
	else:
		dat = { 'response' : '' }
		
	return dat
示例#7
0
文件: user.py 项目: jd5688/embedible
def add_playlist(param):
	x = Playlists()
	
	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:
		data = {
			'username' 	: param['username'],
			'playlist' 	: param['pl_name'],
			'description': param['pl_desc'],
			'tags'		: param['pl_tags'],
			'key'		: _private_key()
		}
		
		return x.add_playlist(data)
	else:
		return 'failed'
示例#8
0
文件: user.py 项目: jd5688/embedible
def playlist(hash, publc, uniq_id, username=""):
	if username == 'false':
		username = ''
		
	x = Playlists()
	data = False
	# create a hash
	m = md5.new(publc + uniq_id + _private_key())
	
	# check if this hash is equal to the one transmitted
	if m.hexdigest() == hash:
		
			
		param = {
			'uniq_id' : uniq_id,
			'username': username
		}
		data = x.getPlaylist(param)
			
	return {
		'data': data,
		'id': 1234
	}
示例#9
0
文件: user.py 项目: jd5688/embedible
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
示例#10
0
文件: user.py 项目: jd5688/embedible
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
	}