Added announce flags to play and url methods.

This commit is contained in:
Bill Dengler 2015-05-13 17:29:58 -04:00
parent 58a8e45d56
commit 7f6cf8d30a
3 changed files with 7 additions and 15 deletions

View File

@ -456,7 +456,7 @@ class baseBufferController(bufferController):
else:
output.speak("Not actionable.",True)
def url(self,url=''):
def url(self,url='',announce=True):
if url == '':
tweet = self.get_tweet()
urls = utils.find_urls(tweet)
@ -469,7 +469,8 @@ class baseBufferController(bufferController):
url=urls_list.get_string()
if hasattr(urls_list, "destroy"): urls_list.destroy()
if url != '':
output.speak(_(u"Opening URL..."), True)
if announce:
output.speak(_(u"Opening URL..."), True)
webbrowser.open_new_tab(url)
def clear_list(self):

View File

@ -114,14 +114,15 @@ class URLStream(object):
log.debug("Transformed URL: %s. Prepared" % (self.url,))
self.prepared = True
def play(self, url=None, volume=1.0, stream=None):
def play(self, url=None, volume=1.0, stream=None,announce=True):
if hasattr(self, "stream") and self.stream.is_playing:
output.speak(_(u"Stopped"))
self.stream.stop()
del self.stream
log.debug("Stream stopped")
else:
output.speak(_(u"Playing..."))
if announce:
output.speak(_(u"Playing..."))
log.debug("Attempting to play an URL...")
if url != None:
self.prepare(url)
@ -141,7 +142,7 @@ class URLStream(object):
if self.prepared == True:
stream=sound_lib.stream.URLStream(url=self.url)
if play:
return self.play(stream=stream,volume=volume)
return self.play(stream=stream,volume=volume,announce=False)
return True
except:
log.exception("Exception.")

View File

@ -140,13 +140,3 @@ def is_allowed(tweet, clients):
def url_is_audio(u):
return sound.URLPlayer.is_playable(u)
def old_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")