當前位置: 首頁>>代碼示例>>Python>>正文


Python Playlist.get_videos方法代碼示例

本文整理匯總了Python中models.Playlist.get_videos方法的典型用法代碼示例。如果您正苦於以下問題:Python Playlist.get_videos方法的具體用法?Python Playlist.get_videos怎麽用?Python Playlist.get_videos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Playlist的用法示例。


在下文中一共展示了Playlist.get_videos方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_video

# 需要導入模塊: from models import Playlist [as 別名]
# 或者: from models.Playlist import get_videos [as 別名]
def add_video():
    playlist_id = request.form.get("playlist_id")
    if playlist_id.strip() == "":
        return jsonify({'error': "You must specify a playlist ID for this video."})

    playlist = Playlist.query.get(playlist_id)
    if playlist == None:
        return jsonify({'error': "Playlist not found"})

    slug = request.form.get("slug")
    if slug.strip() == "":
        return jsonify({'error': "You must specify a slug for this video."})

    thumbnail_url = request.form.get("thumbnail_url")
    if thumbnail_url.strip() == "":
        return jsonify({'error': "You must specify a thumbnail for this video."})

    title = request.form.get("title")
    if title.strip() == "":
        return jsonify({'error': "You must specify a title for this video."})

    v = Video(playlist_id, slug, thumbnail_url, title)
    db_session.add(v)
    db_session.commit()    

    # Publish to Redis so that all clients update playlist
    data = {
        "action": "update_playlist",
        "playlist": Playlist.get_videos(playlist_id)
    }

    redis.publish(playlist_id, json.dumps(data))

    return jsonify({"success": True})
開發者ID:camerongray1515,項目名稱:HackDee-2015,代碼行數:36,代碼來源:api.py

示例2: get_playlist

# 需要導入模塊: from models import Playlist [as 別名]
# 或者: from models.Playlist import get_videos [as 別名]
def get_playlist():
    playlist_id = request.args.get("playlist_id")

    # Now get the updated playlist and send it to the client
    videos = Video.query.filter(Video.playlist_id==playlist_id).order_by("rank desc")

    data = {
        "playlist": Playlist.get_videos(playlist_id)
    }

    return jsonify(data)
開發者ID:camerongray1515,項目名稱:HackDee-2015,代碼行數:13,代碼來源:api.py

示例3: mark_played

# 需要導入模塊: from models import Playlist [as 別名]
# 或者: from models.Playlist import get_videos [as 別名]
def mark_played():
    playlist_id = request.form.get("playlist_id")
    video_slug = request.form.get("video_slug")

    video = Video.query.filter(Video.playlist_id==playlist_id).filter(Video.slug==video_slug).first()

    db_session.delete(video)
    db_session.commit()

    # Publish to Redis so that all clients update playlist
    data = {
        "action": "update_playlist",
        "playlist": Playlist.get_videos(playlist_id)
    }

    redis.publish(playlist_id, json.dumps(data))

    return jsonify({"success": True})
開發者ID:camerongray1515,項目名稱:HackDee-2015,代碼行數:20,代碼來源:api.py

示例4: vote

# 需要導入模塊: from models import Playlist [as 別名]
# 或者: from models.Playlist import get_videos [as 別名]
def vote(up_down):
    video_id = request.form.get("video_id")
    playlist_id = request.form.get("playlist_id")

    video = Video.query.filter(Video.playlist_id==playlist_id).filter(Video.slug==video_id).first()

    if up_down == "up":
        video.rank += 1
    elif up_down == "down":
        video.rank -= 1
    else:
        raise TypeError("Please either upvote or downvote this video.")

    db_session.commit()

    # Publish to Redis so that all clients update playlist
    data = {
        "action": "update_playlist",
        "playlist": Playlist.get_videos(playlist_id)
    }

    redis.publish(playlist_id, json.dumps(data))

    return jsonify({"success": True})
開發者ID:camerongray1515,項目名稱:HackDee-2015,代碼行數:26,代碼來源:api.py


注:本文中的models.Playlist.get_videos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。