#33: Add better audio detection support (needs testing, could pose a security risk, users should be able to disable this).

This commit is contained in:
Bill Dengler 2015-05-12 13:31:51 -04:00
parent 1e6a784192
commit 52bfa82ec5

View File

@ -4,6 +4,7 @@ import output
from twython import TwythonError from twython import TwythonError
import config import config
import logging import logging
import requests
log = logging.getLogger("twitter.utils") log = logging.getLogger("twitter.utils")
""" Some utilities for the twitter interface.""" """ Some utilities for the twitter interface."""
@ -46,6 +47,10 @@ def is_audio(tweet):
for i in tweet["entities"]["hashtags"]: for i in tweet["entities"]["hashtags"]:
if i["text"] == "audio": if i["text"] == "audio":
return True return True
for u in find_urls(tweet):
response = requests.head(u)
if 'audio' in str(response.headers['content-type']).lower():
return True
return False return False
def is_geocoded(tweet): def is_geocoded(tweet):