Play a sound when a tweet contains images

This commit is contained in:
Manuel Cortez 2017-01-07 06:58:53 -06:00
parent cc60235503
commit 146667144a
4 changed files with 11 additions and 1 deletions

View File

@ -595,6 +595,8 @@ class baseBufferController(bufferController):
self.session.sound.play("audio.ogg") self.session.sound.play("audio.ogg")
if utils.is_geocoded(tweet): if utils.is_geocoded(tweet):
self.session.sound.play("geo.ogg") self.session.sound.play("geo.ogg")
if utils.is_media(tweet):
self.session.sound.play("image.ogg")
# @_tweets_exist # @_tweets_exist
def audio(self, url='', *args, **kwargs): def audio(self, url='', *args, **kwargs):

Binary file not shown.

View File

@ -66,6 +66,14 @@ def is_geocoded(tweet):
if tweet.has_key("coordinates") and tweet["coordinates"] != None: if tweet.has_key("coordinates") and tweet["coordinates"] != None:
return True return True
def is_media(tweet):
if tweet["entities"].has_key("media") == False:
return False
for i in tweet["entities"]["media"]:
if i.has_key("type") and i["type"] == "photo":
return True
return False
def get_all_mentioned(tweet, conf, field="screen_name"): def get_all_mentioned(tweet, conf, field="screen_name"):
""" Gets all users that has been mentioned.""" """ Gets all users that has been mentioned."""
results = [] results = []

View File

@ -106,7 +106,7 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
rMode.Add(lbl, 0, wx.ALL, 5) rMode.Add(lbl, 0, wx.ALL, 5)
rMode.Add(self.retweet_mode, 0, wx.ALL, 5) rMode.Add(self.retweet_mode, 0, wx.ALL, 5)
sizer.Add(rMode, 0, wx.ALL, 5) sizer.Add(rMode, 0, wx.ALL, 5)
self.show_screen_names = wx.CheckBox(self, wx.NewId(), _(U"Show screen names instead full names")) self.show_screen_names = wx.CheckBox(self, wx.NewId(), _(U"Show screen names instead of full names"))
sizer.Add(self.show_screen_names, 0, wx.ALL, 5) sizer.Add(self.show_screen_names, 0, wx.ALL, 5)
PersistSizeLabel = wx.StaticText(self, -1, _(u"Number of items per buffer to cache in database (0 to disable caching, blank for unlimited)")) PersistSizeLabel = wx.StaticText(self, -1, _(u"Number of items per buffer to cache in database (0 to disable caching, blank for unlimited)"))
self.persist_size = wx.TextCtrl(self, -1) self.persist_size = wx.TextCtrl(self, -1)