Ejemplo n.º 1
0
def _populate_comment_counters(channel_id, video_id, tree):
    counters = []
    like_ctr_to_node = {}
    dislike_ctr_to_node = {}
    for comment in tree.comments():
        like_ctr = comment_like_counter(channel_id, video_id, comment["i"])
        dislike_ctr = comment_dislike_counter(channel_id, video_id, comment["i"])
        counters.extend([like_ctr, dislike_ctr])
        like_ctr_to_node[like_ctr] = comment
        dislike_ctr_to_node[dislike_ctr] = comment
    results = fastcounter.get_counts(counters)
    for i in xrange(0, len(counters)):
        if like_ctr_to_node.has_key(counters[i]):
            node = like_ctr_to_node[counters[i]]
            node["l"] = results[i]
        else:
            node = dislike_ctr_to_node[counters[i]]
            node["d"] = results[i]
Ejemplo n.º 2
0
def dislike_comment(channel_id, video_id, comment_id, delta=1):
    fastcounter.incr(comment_dislike_counter(channel_id, video_id, comment_id))