Last active
December 11, 2015 00:38
-
-
Save stetro/4517991 to your computer and use it in GitHub Desktop.
LCDproc Twitter Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tweepy import OAuthHandler | |
from tweepy import API | |
from tweepy import Status | |
from lcdproc.server import Server | |
import socket | |
import time | |
import commands | |
def tweepy_auth(): | |
# Keys eintragen ! | |
consumer_key="" | |
consumer_secret="" | |
access_token="" | |
access_token_secret="" | |
auth = OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
return auth; | |
def load_newest_states(auth): | |
api = API(auth) | |
states = api.home_timeline(count = 1) | |
return states | |
def check_for_new_tweets(): | |
auth = tweepy_auth() | |
states = load_newest_states(auth) | |
return states | |
if __name__ == '__main__': | |
lcdServer = Server(hostname="192.168.1.78") | |
lcdServer.start_session() | |
lcdServer.output("Fooo") | |
screen = lcdServer.add_screen("Tweets") | |
screen.set_heartbeat("off") | |
screen.set_duration(20) | |
message = screen.add_scroller_widget("message",text="",left=1, top=2, right=16, bottom=2,speed=10, direction="v") | |
user = screen.add_title_widget("username",text="") | |
tweets = 0 | |
while True: | |
tweets = check_for_new_tweets() | |
for tweet in tweets: | |
user.set_text("@" + tweet.user.screen_name.encode('utf-8')) | |
message.set_text(tweet.text.encode('utf-8')) | |
print "@" + tweet.user.screen_name.encode('utf-8')+" "+tweet.text.encode('utf-8') | |
time.sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment