mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-02-16 22:44:09 -06:00
Added announce flags to play and url methods.
This commit is contained in:
parent
58a8e45d56
commit
7f6cf8d30a
@ -456,7 +456,7 @@ class baseBufferController(bufferController):
|
|||||||
else:
|
else:
|
||||||
output.speak("Not actionable.",True)
|
output.speak("Not actionable.",True)
|
||||||
|
|
||||||
def url(self,url=''):
|
def url(self,url='',announce=True):
|
||||||
if url == '':
|
if url == '':
|
||||||
tweet = self.get_tweet()
|
tweet = self.get_tweet()
|
||||||
urls = utils.find_urls(tweet)
|
urls = utils.find_urls(tweet)
|
||||||
@ -469,7 +469,8 @@ class baseBufferController(bufferController):
|
|||||||
url=urls_list.get_string()
|
url=urls_list.get_string()
|
||||||
if hasattr(urls_list, "destroy"): urls_list.destroy()
|
if hasattr(urls_list, "destroy"): urls_list.destroy()
|
||||||
if url != '':
|
if url != '':
|
||||||
output.speak(_(u"Opening URL..."), True)
|
if announce:
|
||||||
|
output.speak(_(u"Opening URL..."), True)
|
||||||
webbrowser.open_new_tab(url)
|
webbrowser.open_new_tab(url)
|
||||||
|
|
||||||
def clear_list(self):
|
def clear_list(self):
|
||||||
|
@ -114,14 +114,15 @@ class URLStream(object):
|
|||||||
log.debug("Transformed URL: %s. Prepared" % (self.url,))
|
log.debug("Transformed URL: %s. Prepared" % (self.url,))
|
||||||
self.prepared = True
|
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:
|
if hasattr(self, "stream") and self.stream.is_playing:
|
||||||
output.speak(_(u"Stopped"))
|
output.speak(_(u"Stopped"))
|
||||||
self.stream.stop()
|
self.stream.stop()
|
||||||
del self.stream
|
del self.stream
|
||||||
log.debug("Stream stopped")
|
log.debug("Stream stopped")
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"Playing..."))
|
if announce:
|
||||||
|
output.speak(_(u"Playing..."))
|
||||||
log.debug("Attempting to play an URL...")
|
log.debug("Attempting to play an URL...")
|
||||||
if url != None:
|
if url != None:
|
||||||
self.prepare(url)
|
self.prepare(url)
|
||||||
@ -141,7 +142,7 @@ class URLStream(object):
|
|||||||
if self.prepared == True:
|
if self.prepared == True:
|
||||||
stream=sound_lib.stream.URLStream(url=self.url)
|
stream=sound_lib.stream.URLStream(url=self.url)
|
||||||
if play:
|
if play:
|
||||||
return self.play(stream=stream,volume=volume)
|
return self.play(stream=stream,volume=volume,announce=False)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.exception("Exception.")
|
log.exception("Exception.")
|
||||||
|
@ -140,13 +140,3 @@ def is_allowed(tweet, clients):
|
|||||||
|
|
||||||
def url_is_audio(u):
|
def url_is_audio(u):
|
||||||
return sound.URLPlayer.is_playable(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")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user