Advertisement
Guest User

Tweet XBMC addon

a guest
May 31st, 2013
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. import xbmc, xbmcgui
  2. import tweepy
  3. import time
  4.  
  5. # Needed because it throws an error
  6. oldtitle = ""
  7.  
  8. # While XBMC is still running
  9. while(not xbmc.abortRequested):
  10.  
  11.     # If we are NOT watching a TV show
  12.     if(xbmc.getInfoLabel('VideoPlayer.TVShowTitle') == ""):
  13.         # Set the title to the video we are watching
  14.         title = xbmc.getInfoLabel('VideoPlayer.Title')
  15.     else:
  16.         # Set the title as the TV show and season + episode
  17.         title = xbmc.getInfoLabel('VideoPlayer.TVShowTitle') + ' - Season ' + xbmc.getInfoLabel('VideoPlayer.episode') + ' Episode ' + xbmc.getInfoLabel('VideoPlayer.season')
  18.  
  19.     # If we are watching a new TV show tweet it
  20.     if(title != oldtitle):
  21.  
  22.         # Set the consumer details
  23.         consumer_key="ENTER YOUR DETAILS"
  24.         consumer_secret="ENTER YOUR DETAILS"
  25.  
  26.         # Set the access token details
  27.         access_token="ENTER YOUR DETAILS"
  28.         access_token_secret="ENTER YOUR DETAILS"
  29.  
  30.         # Login
  31.         auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  32.         auth.set_access_token(access_token, access_token_secret)
  33.  
  34.         api = tweepy.API(auth)
  35.  
  36.         # Print your name in the debug log
  37.         print 'Logged in as ' + api.me().name
  38.  
  39.         # So we don't tweet an empty message
  40.     if(title != ""):
  41.             api.update_status('#NW: ' + title)
  42.             oldtitle = title
  43.  
  44. # Sleep for 5 minutes
  45. time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement