def trendingChannelsList():
    twitv = TwiTv()
    rank = twitv.channelRank()
    response = ""
    i = 0
    while i < len(rank):
        twits = rank[i][0]
        idChannel = rank[i][1]
        channelName = rank[i][2]
        channelNumber = str(rank[i][3])
        channelImage = rank[i][4]
        response += '<tr><td>%s</td><td>%s</td><td>%s</td><td><img src="%s" /></td></tr>' % (
            idChannel,
            channelName,
            channelNumber,
            channelImage,
        )
        i += 1
    response = "<table>" + response + "</table>"
    return response
def trendingChannels():
    twitv = TwiTv()
    rank = twitv.channelRank()
    response = []
    i = 0
    while i < len(rank):
        twits = rank[i][0]
        idChannel = rank[i][1]
        channelName = rank[i][2]
        channelNumber = str(rank[i][3])
        channelImage = rank[i][4]
        response.append(
            {
                "twits": twits,
                "idChannel": idChannel,
                "channelName": channelName,
                "channelNumber": channelNumber,
                "channelImage": channelImage,
            }
        )
        i += 1
    return json.dumps({"response": response})
Esempio n. 3
0
#!C:\Python27

from twython import Twython
from time import sleep
from twitv import TwiTv, sprint
from db import DB
from datetime import timedelta, datetime
import sys

db = DB()
twitv = TwiTv()
twitter = Twython()

#Condition to keep this loop running forever
while True:
	hashTags=twitv.hashtags()
	#Crear nuevo TimeSlice
	idTimeSlice=twitv.newTimeSlice()
	i=0
	while i<len(hashTags):
		limit = twitv.lastTwit(hashTags[i])
		ht = ' OR '.join(hashTags[i][4:])
		twitterRequest = ht
		channelNumber=hashTags[i][2]
		channelName=hashTags[i][3]
		sprint(str(channelNumber), channelName)
		try:
			search_results = twitter.search(since_id=limit, q=twitterRequest, rpp="100")
		except:
			print " Error en el Request a Twitter"
			#print search_results