0

单击我的 SONOS 应用程序上的任一评级按钮会导致出现“操作失败”错误,我不知道为什么。除此以外,该应用程序的其他所有内容均按预期工作。

这是我的费率项目功能的代码。我正在使用 pysimplesoap 模块。

def rateItem(id, rating, device, householdId, loginToken):
    # rating =
    # Unrated track -> rating = 1 (good) | rating = 0 (bad)
    # Track has thumbs up  -> rating = 3 (good) | rating = 2 (bad)
    # Track has thumbs down -> rating = 5 (good) | rating = 6 (bad)
    user_record = SonosUserRecord.collection.find_one({"loginToken": loginToken})
    user = get_user_from_username(username=user_record["username"])

    now = datetime.utcnow()
    SonosUserRecord.collection.update({"loginToken": loginToken}, {"$set": {"last_update": now}})
    #rateItemResponse = {"shouldSkip": "false"}
    if rating == 1 or rating == 5:
        print "Rated positive"
        # Rated positive
        rating_value = 5
        toid = id.split(":")[1]
        rating = MongoTrackRating(user, toid)
        rating.set_rating(int(rating_value))
        MongoTrackRatingAggregate.update_track_rating_aggregate(toid, int(rating_value))
    if rating == 0 or rating == 2:
        print "Rated negative"
        # Rated negative
        #rateItemResponse["shouldSkip"] = "true"
        rating_value = 1
        toid = id.split(":")[1]
        rating = MongoTrackRating(user, toid)
        rating.set_rating(int(rating_value))
        MongoTrackRatingAggregate.update_track_rating_aggregate(toid, int(rating_value))
    return rateItemResponse

然后我注册它。

dispatcher.register_function('rateItem', rateItem,
    returns={"rateItemResult": list},
    args={"id": str, "rating": int, 'device':str, 'householdId':str, 'loginToken': str})

我错过了什么?

4

0 回答 0