is_audio, is_geocoded, is_media, get_urls ignore dm's for now #215

This commit is contained in:
Manuel Cortez 2018-07-18 09:28:16 -05:00
parent 7dad22189a
commit 019e83c55b

View File

@ -22,6 +22,8 @@ def find_urls_in_text(text):
return [s.strip(bad_chars) for s in url_re2.findall(text)] return [s.strip(bad_chars) for s in url_re2.findall(text)]
def find_urls (tweet): def find_urls (tweet):
if tweet.has_key("entities") == False:
return []
urls = [] urls = []
# Let's add URLS from tweet entities. # Let's add URLS from tweet entities.
for i in tweet["entities"]["urls"]: for i in tweet["entities"]["urls"]:
@ -72,6 +74,7 @@ def find_next_reply(id, listItem):
return None return None
def is_audio(tweet): def is_audio(tweet):
if tweet.has_key("entities") == False: return False
try: try:
if len(find_urls(tweet)) < 1: if len(find_urls(tweet)) < 1:
return False return False
@ -88,6 +91,7 @@ def is_geocoded(tweet):
return True return True
def is_media(tweet): def is_media(tweet):
if tweet.has_key("entities") == False: return False
if tweet["entities"].has_key("media") == False: if tweet["entities"].has_key("media") == False:
return False return False
for i in tweet["entities"]["media"]: for i in tweet["entities"]["media"]: