当前位置: 首页>>代码示例>>Python>>正文


Python Cart.is_playable方法代码示例

本文整理汇总了Python中cart.Cart.is_playable方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.is_playable方法的具体用法?Python Cart.is_playable怎么用?Python Cart.is_playable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cart.Cart的用法示例。


在下文中一共展示了Cart.is_playable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search_library

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import is_playable [as 别名]
def search_library(query):
    """Search the music library for tracks and carts.

    :param query: search term
    """
    results = []

    try:
        res = requests.get(URL_STUDIOSEARCH, params={"query": query})
        results_res = res.json()

        for cart_res in results_res["carts"]:
            filename = LIBRARY_PREFIX + "carts/" + cart_res["filename"]

            cart = Cart(cart_res["cartID"], cart_res["title"], cart_res["issuer"], cart_res["type"], filename)
            if cart.is_playable():
                results.append(cart)

        for track_res in results_res["tracks"]:
            filename = LIBRARY_PREFIX + track_res["file_name"]
            track_id = track_res["album_code"] + "-" + track_res["track_num"]

            track = Cart(track_id, track_res["track_name"], track_res["artist_name"], track_res["rotation"], filename)
            if track.is_playable():
                results.append(track)
    except requests.exceptions.ConnectionError:
        print "Error: Could not fetch search results."

    return results
开发者ID:wsbf,项目名称:ZAutomate,代码行数:31,代码来源:database.py

示例2: get_carts

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import is_playable [as 别名]
def get_carts():
    """Load a dictionary of cart arrays for each cart type."""
    carts = {
        0: [],
        1: [],
        2: [],
        3: []
    }

    try:
        for cart_type in carts:
            res = requests.get(URL_CARTLOAD, params={"type": cart_type})
            carts_res = res.json()

            for cart_res in carts_res:
                # TODO: move pathname building to Cart constructor
                filename = LIBRARY_PREFIX + "carts/" + cart_res["filename"]

                cart = Cart(cart_res["cartID"], cart_res["title"], cart_res["issuer"], cart_res["type"], filename)

                if cart.is_playable():
                    carts[cart_type].append(cart)

    except requests.exceptions.ConnectionError:
        print time.asctime() + " :=: Error: Could not fetch carts."

    return carts
开发者ID:wsbf,项目名称:ZAutomate,代码行数:29,代码来源:database.py

示例3: get_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import is_playable [as 别名]
def get_cart(cart_type):
    """Get a random cart of a given type.

    :param cart_type
    """

    # temporary code to transform cart_type to index
    types = {
        0: "PSA",
        1: "Underwriting",
        2: "StationID",
        3: "Promotion"
    }
    for t in types:
        if types[t] is cart_type:
            cart_type = t

    try:
        # attempt to find a valid cart
        count = 0
        while count < 5:
            # fetch a random cart
            res = requests.get(URL_AUTOCART, params={"type": cart_type})
            cart_res = res.json()

            # return if cart type is empty
            if cart_res is None:
                return None

            # construct cart
            filename = LIBRARY_PREFIX + "carts/" + cart_res["filename"]
            cart = Cart(cart_res["cartID"], cart_res["title"], cart_res["issuer"], cart_res["type"], filename)

            # verify cart filename
            if cart.is_playable():
                return cart
            else:
                count += 1
    except requests.exceptions.ConnectionError:
        print time.asctime() + " :=: Error: Could not fetch cart."

    return None
开发者ID:wsbf,项目名称:ZAutomate,代码行数:44,代码来源:database.py

示例4: get_playlist

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import is_playable [as 别名]
def get_playlist(show_id):
    """Get the playlist from a past show.

    :param show_id: show ID
    """
    playlist = []

    try:
        res = requests.get(URL_AUTOLOAD, params={"showid": show_id})
        playlist_res = res.json()

        for track_res in playlist_res:
            # TODO: move pathname building to Track constructor
            filename = LIBRARY_PREFIX + track_res["file_name"]
            track_id = track_res["lb_album_code"] + "-" + track_res["lb_track_num"]

            track = Cart(track_id, track_res["lb_track_name"], track_res["artist_name"], track_res["rotation"], filename)

            if track.is_playable():
                playlist.append(track)
    except requests.exceptions.ConnectionError:
        print "Error: Could not fetch playlist."

    return playlist
开发者ID:wsbf,项目名称:ZAutomate,代码行数:26,代码来源:database.py


注:本文中的cart.Cart.is_playable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。