Fix utils.

This commit is contained in:
Bill Dengler 2015-06-10 17:29:26 -04:00
parent 191d42f8a5
commit 6232ec3b7c

View File

@ -44,16 +44,34 @@ def find_next_reply(id, listItem):
if listItem[i]["in_reply_to_status_id_str"] == str(id): return i if listItem[i]["in_reply_to_status_id_str"] == str(id): return i
return None return None
def is_audio(tweet): def is_audio(tweet,force=False):
if force == False and 'is_audio' in tweet:
return tweet['is_audio']
try: try:
if len(find_urls(tweet)) < 1: if len(find_urls(tweet)) < 1:
tweet['is_audio']=False
return False return False
if len(tweet["entities"]["hashtags"]) > 0: if len(tweet["entities"]["hashtags"]) > 0:
for i in tweet["entities"]["hashtags"]: for i in tweet["entities"]["hashtags"]:
if i["text"] == "audio": if i["text"] == "audio":
tweet['is_audio']=True
return True return True
except: except:
log.exception("Exception while executing is_audio hashtag algorithm") log.exception("Exception while executing is_audio hashtag algorithm")
try:
if config.app["app-settings"]["use_slow_audio_algo"]:
for u in find_urls(tweet):
if url_is_audio(u):
tweet['is_audio']=True
return True
except:
log.exception("Exception while executing is_audio Codeofdusk algorithm.")
tweet['is_audio']=False
return False
def url_is_audio(u):
return sound.URLPlayer.is_playable(u)
def is_geocoded(tweet): def is_geocoded(tweet):
if tweet.has_key("coordinates") and tweet["coordinates"] != None: if tweet.has_key("coordinates") and tweet["coordinates"] != None: