Ejemplo n.º 1
0
def ajax_getvideo(rd, user, data):
    vidid = data.vid
    try:
        obj, tags, category_tag_map, tag_category_map = getVideoDetailWithTags(
            vidid, data.lang, user)
    except UserError:
        abort(404)

    tag_by_category = category_tag_map
    for category in tag_by_category:
        tag_by_category[category] = list(sorted(tag_by_category[category]))
    copies_by_type = defaultdict(list)
    copies = []
    for item in obj['item']['copies']:
        ver = getVideoDetail(item, user)
        if ver:
            copies.append(ver)
            if 'repost_type' in ver['item']:
                copies_by_type[ver['item']['repost_type']].append(ver)
            else:
                copies_by_type['unknown'].append(ver)
    playlists = listPlaylistsForVideo(user, vidid)

    return "json", makeResponseSuccess({
        "video": obj,
        "tags": tags,
        "copies": copies,
        "copies_by_repost_type": copies_by_type,
        "playlists": playlists,
        "tag_by_category": tag_by_category
    })
Ejemplo n.º 2
0
def pages_videodetail(rd, user):
    vidid = request.values['id']
    try:
        obj, tags, category_tag_map, tag_category_map = getVideoDetailWithTags(
            vidid, 'CHS', user)
    except UserError:
        abort(404, "No such video id=%s" % vidid)

    rd.thumbnail_url = obj['item']['thumbnail_url']
    rd.cover_image = obj['item']['cover_image']
    rd.title = obj['item']['title']
    rd.desc = obj['item']['desc']
    rd.link = obj['item']['url']
    if obj['item']['site'] == 'ipfs':
        rd.ipfs_video = True
        ipfs_hash = obj['item']['unique_id']
        rd.ipfs_hash = ipfs_hash[ipfs_hash.find(':') + 1:]
    else:
        rd.ipfs_video = False
    rd.upload_date = obj['item']['upload_time'] if 'upload_time' in obj[
        'item'] else ''
    if not rd.upload_date:
        rd.upload_date = ''
    rd.tags = ' '.join(tags)
    rd.tags_list = tags
    rd.tag_by_category = category_tag_map
    for category in rd.tag_by_category:
        rd.tag_by_category[category] = list(
            sorted(rd.tag_by_category[category]))
    rd.video_id = vidid
    rd.copies = []
    for item in obj['item']['copies']:
        ver = getVideoDetail(item, user)
        if ver:
            rd.copies.append(ver)
    rd.playlists = listPlaylistsForVideo(user, vidid)
    return "content_singlevideo.html"
Ejemplo n.º 3
0
def ajax_getvideo(rd, user, data):
	vidid = data.vid
	try:
		obj, tags, category_tag_map, tag_category_map = getVideoDetailWithTags(vidid, 'CHS', user)
	except UserError:
		abort(404)

	tag_by_category = category_tag_map
	for category in tag_by_category :
		tag_by_category[category] = list(sorted(tag_by_category[category]))
	copies = []
	for item in obj['item']['copies'] :
		ver = getVideoDetail(item, user)
		if ver :
			copies.append(ver)
	playlists = listPlaylistsForVideo(user, vidid)

	return "json", makeResponseSuccess({
		"video" : obj,
		"tags" : tags,
		"copies" : copies,
		"playlists" : playlists,
		"tag_by_category": tag_by_category
	})
Ejemplo n.º 4
0
def ajax_getvideo_basic(rd, user, data):
    vidid = data.vid
    try:
        obj, tags, category_tag_map, tag_category_map = getVideoDetailWithTags(
            vidid, data.lang, user)
    except UserError:
        abort(404)

    tag_by_category = category_tag_map
    for category in tag_by_category:
        tag_by_category[category] = list(sorted(tag_by_category[category]))

    return "json", makeResponseSuccess({
        "title":
        obj['item']['title'],
        "desc":
        obj['item']['desc'],
        "cover":
        "https://thvideo.tv/images/covers/" + obj['item']['cover_image'],
        "url":
        obj['item']['url'],
        "tag_by_category":
        tag_by_category
    })