From 4c125e4a7a3523b28f73de82f51a88dfcb0daaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Wed, 13 May 2015 08:55:45 -0500 Subject: [PATCH] Reverted audio algorithm --- src/app-configuration.defaults | 1 - src/sessionmanager/session.py | 15 -------------- src/twitter/utils.py | 36 ++++------------------------------ 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index bb6d3abc..05a3e780 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -12,7 +12,6 @@ use_invisible_keyboard_shorcuts = boolean(default=True) play_ready_sound = boolean(default=True) speak_ready_msg = boolean(default=True) log_level = string(default="error") -use_modern_audio_algo = boolean(default=True) [keymap] up = string(default="control+win+up") diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index 4dc62e4a..902cbc49 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -114,7 +114,6 @@ class Session(object): self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults")) self.init_sound() self.deshelve() - self.fix_audio_tags() # except: # log.exception("The session configuration has failed.") # self.settings = None @@ -410,17 +409,3 @@ class Session(object): log.exception("Exception while deshelving" + shelfname) os.remove(shelfname) - def fix_audio_tags(self,force=False): - "Repair audio tags." - for key,value in self.db.items(): - if type(value) == list: - for t in value: - utils.is_audio(t,force=force) - - def clean_is_audio_memmos(self): - "Clean out memmos for is_audio" - for key,value in self.db.items(): - if type(value) == list: - for i in value: - if 'is_audio' in i: - del i['is_audio'] \ No newline at end of file diff --git a/src/twitter/utils.py b/src/twitter/utils.py index 0237e2bb..88627c56 100644 --- a/src/twitter/utils.py +++ b/src/twitter/utils.py @@ -43,29 +43,10 @@ def find_next_reply(id, listItem): return None def is_audio(tweet,force=False): - if force == False and 'is_audio' in tweet: - return tweet['is_audio'] - try: - if len(find_urls(tweet)) < 1: - tweet['is_audio']=False - return False - - if len(tweet["entities"]["hashtags"]) > 0: - for i in tweet["entities"]["hashtags"]: - if i["text"] == "audio": - tweet['is_audio']=True - return True - except: - log.exception("Exception while executing is_audio hashtag algorithm") - try: - if config.app["app-settings"]["use_modern_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 + if len(tweet["entities"]["hashtags"]) > 0: + for i in tweet["entities"]["hashtags"]: + if i["text"] == "audio": + return True return False def is_geocoded(tweet): @@ -131,12 +112,3 @@ def is_allowed(tweet, clients): allowed = False log.exception("Tuit not allowed: %s" % (tweet["text"],)) return allowed -def url_is_audio(u): - try: - response = requests.head(u,allow_redirects=True) - if 'audio' in str(response.headers['content-type']).lower(): - return True - else: - return False - except: - log.exception("Exception while determining audio by HTTP headers")