mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-19 00:40:42 -06:00
Code cleanup and a couple of fixes
This commit is contained in:
parent
f6bf1dcfdc
commit
0045bd223c
@ -20,6 +20,7 @@ from twitter import compose, utils
|
|||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
from twython import TwythonError
|
from twython import TwythonError
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
|
from long_tweets import twishort, tweets
|
||||||
|
|
||||||
log = logging.getLogger("controller.buffers")
|
log = logging.getLogger("controller.buffers")
|
||||||
|
|
||||||
@ -97,10 +98,8 @@ class bufferController(object):
|
|||||||
if hasattr(urls_list, "destroy"): urls_list.destroy()
|
if hasattr(urls_list, "destroy"): urls_list.destroy()
|
||||||
if url != None:
|
if url != None:
|
||||||
output.speak(_(u"Opening media..."), True)
|
output.speak(_(u"Opening media..."), True)
|
||||||
if sound.URLPlayer.is_playable(url=url, play=True, volume=self.session.settings["sound"]["volume"]) == False:
|
if sound.URLPlayer.is_playable(url=url, play=True, volume=self.session.settings["sound"]["volume"]) == False:
|
||||||
return webbrowser.open_new_tab(url)
|
return webbrowser.open_new_tab(url)
|
||||||
elif utils.is_geocoded(tweet):
|
|
||||||
return output.speak("Not implemented",True)
|
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"Not actionable."), True)
|
output.speak(_(u"Not actionable."), True)
|
||||||
self.session.sound.play("error.ogg")
|
self.session.sound.play("error.ogg")
|
||||||
@ -243,6 +242,26 @@ class baseBufferController(bufferController):
|
|||||||
def get_message(self):
|
def get_message(self):
|
||||||
return " ".join(self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"]))
|
return " ".join(self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"]))
|
||||||
|
|
||||||
|
def get_full_tweet(self):
|
||||||
|
tweet = self.get_right_tweet()
|
||||||
|
tweetsList = []
|
||||||
|
tweet_id = tweet["id"]
|
||||||
|
uri = None
|
||||||
|
if tweet.has_key("long_uri"):
|
||||||
|
uri = tweet["long_uri"]
|
||||||
|
tweet = self.session.twitter.twitter.show_status(id=tweet_id)
|
||||||
|
if uri != None:
|
||||||
|
tweet["text"] = twishort.get_full_text(uri)
|
||||||
|
l = tweets.is_long(tweet)
|
||||||
|
while l != False:
|
||||||
|
tweetsList.append(tweet)
|
||||||
|
id = tweets.get_id(l)
|
||||||
|
tweet = self.session.twitter.twitter.show_status(id=id)
|
||||||
|
l = tweets.is_long(tweet)
|
||||||
|
if l == False:
|
||||||
|
tweetsList.append(tweet)
|
||||||
|
return (tweet, tweetsList)
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
|
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
|
||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
|
@ -35,7 +35,6 @@ import pygeocoder
|
|||||||
from pygeolib import GeocoderError
|
from pygeolib import GeocoderError
|
||||||
import logging
|
import logging
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from long_tweets import twishort, tweets
|
|
||||||
|
|
||||||
log = logging.getLogger("mainController")
|
log = logging.getLogger("mainController")
|
||||||
|
|
||||||
@ -655,28 +654,8 @@ class Controller(object):
|
|||||||
def view_item(self, *args, **kwargs):
|
def view_item(self, *args, **kwargs):
|
||||||
buffer = self.get_current_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.type == "baseBuffer" or buffer.type == "favourites_timeline" or buffer.type == "list" or buffer.type == "search":
|
if buffer.type == "baseBuffer" or buffer.type == "favourites_timeline" or buffer.type == "list" or buffer.type == "search":
|
||||||
try:
|
tweet, tweetsList = buffer.get_full_tweet()
|
||||||
tweet = buffer.get_right_tweet()
|
msg = messages.viewTweet(tweet, tweetsList)
|
||||||
tweetsList = []
|
|
||||||
tweet_id = tweet["id"]
|
|
||||||
uri = None
|
|
||||||
if tweet.has_key("long_uri"):
|
|
||||||
uri = tweet["long_uri"]
|
|
||||||
tweet = buffer.session.twitter.twitter.show_status(id=tweet_id)
|
|
||||||
if uri != None:
|
|
||||||
tweet["text"] = twishort.get_full_text(uri)
|
|
||||||
l = tweets.is_long(tweet)
|
|
||||||
while l != False:
|
|
||||||
tweetsList.append(tweet)
|
|
||||||
id = tweets.get_id(l)
|
|
||||||
tweet = buffer.session.twitter.twitter.show_status(id=id)
|
|
||||||
l = tweets.is_long(tweet)
|
|
||||||
if l == False:
|
|
||||||
tweetsList.append(tweet)
|
|
||||||
msg = messages.viewTweet(tweet, tweetsList)
|
|
||||||
except TwythonError:
|
|
||||||
non_tweet = buffer.get_formatted_message()
|
|
||||||
msg = messages.viewTweet(non_tweet, [], False)
|
|
||||||
elif buffer.type == "account" or buffer.type == "empty":
|
elif buffer.type == "account" or buffer.type == "empty":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user