diff --git a/plexpy/config.py b/plexpy/config.py index afe81bf8..9cc23068 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -360,9 +360,10 @@ _CONFIG_DEFINITIONS = { 'TV_NOTIFY_ON_STOP': (int, 'Monitoring', 0), 'TV_NOTIFY_ON_PAUSE': (int, 'Monitoring', 0), 'TWITTER_ENABLED': (int, 'Twitter', 0), - 'TWITTER_PASSWORD': (str, 'Twitter', ''), - 'TWITTER_PREFIX': (str, 'Twitter', 'PlexPy'), - 'TWITTER_USERNAME': (str, 'Twitter', ''), + 'TWITTER_ACCESS_TOKEN': (str, 'Twitter', ''), + 'TWITTER_ACCESS_TOKEN_SECRET': (str, 'Twitter', ''), + 'TWITTER_CONSUMER_KEY': (str, 'Twitter', ''), + 'TWITTER_CONSUMER_SECRET': (str, 'Twitter', ''), 'TWITTER_ON_PLAY': (int, 'Twitter', 0), 'TWITTER_ON_STOP': (int, 'Twitter', 0), 'TWITTER_ON_PAUSE': (int, 'Twitter', 0), diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index a23f8b58..360fa47e 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -1165,8 +1165,10 @@ class TwitterNotifier(object): SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate' def __init__(self): - self.consumer_key = "2LdJKXHDUwJtjYBsdwJisIOsh" - self.consumer_secret = "QWbUcZzAIiL4zbDCIhy2EdUkV8yEEav3qMdo5y3FugxCFelWrA" + self.access_token = plexpy.CONFIG.TWITTER_ACCESS_TOKEN + self.access_token_secret = plexpy.CONFIG.TWITTER_ACCESS_TOKEN_SECRET + self.consumer_key = plexpy.CONFIG.TWITTER_CONSUMER_KEY + self.consumer_secret = plexpy.CONFIG.TWITTER_CONSUMER_SECRET def notify(self, subject, message): if not subject or not message: @@ -1191,16 +1193,16 @@ class TwitterNotifier(object): else: request_token = dict(parse_qsl(content)) - plexpy.CONFIG.TWITTER_USERNAME = request_token['oauth_token'] - plexpy.CONFIG.TWITTER_PASSWORD = request_token['oauth_token_secret'] + plexpy.CONFIG.TWITTER_ACCESS_TOKEN = request_token['oauth_token'] + plexpy.CONFIG.TWITTER_ACCESS_TOKEN_SECRET = request_token['oauth_token_secret'] return self.AUTHORIZATION_URL + "?oauth_token=" + request_token['oauth_token'] def _get_credentials(self, key): request_token = {} - request_token['oauth_token'] = plexpy.CONFIG.TWITTER_USERNAME - request_token['oauth_token_secret'] = plexpy.CONFIG.TWITTER_PASSWORD + request_token['oauth_token'] = plexpy.CONFIG.TWITTER_ACCESS_TOKEN + request_token['oauth_token_secret'] = plexpy.CONFIG.TWITTER_ACCESS_TOKEN_SECRET request_token['oauth_callback_confirmed'] = 'true' token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret']) @@ -1225,20 +1227,20 @@ class TwitterNotifier(object): else: # logger.info(u"PlexPy Notifiers :: Your Twitter Access Token key: %s" % access_token['oauth_token']) # logger.info(u"PlexPy Notifiers :: Access Token secret: %s" % access_token['oauth_token_secret']) - plexpy.CONFIG.TWITTER_USERNAME = access_token['oauth_token'] - plexpy.CONFIG.TWITTER_PASSWORD = access_token['oauth_token_secret'] + plexpy.CONFIG.TWITTER_ACCESS_TOKEN = access_token['oauth_token'] + plexpy.CONFIG.TWITTER_ACCESS_TOKEN_SECRET = access_token['oauth_token_secret'] plexpy.CONFIG.write() return True def _send_tweet(self, message=None): - username = self.consumer_key - password = self.consumer_secret - access_token_key = plexpy.CONFIG.TWITTER_USERNAME - access_token_secret = plexpy.CONFIG.TWITTER_PASSWORD + consumer_key = self.consumer_key + consumer_secret = self.consumer_secret + access_token = self.access_token + access_token_secret = self.access_token_secret # logger.info(u"PlexPy Notifiers :: Sending tweet: " + message) - api = twitter.Api(username, password, access_token_key, access_token_secret) + api = twitter.Api(consumer_key, consumer_secret, access_token, access_token_secret) try: api.PostUpdate(message) @@ -1251,30 +1253,37 @@ class TwitterNotifier(object): def return_config_options(self): config_option = [{'label': 'Instructions', - 'description': 'Step 1: Click the Request Authorization button below.
\ - Step 2: Input the Authorization Key you received from Step 1 below.
\ - Step 3: Click the Verify Key button below.', + 'description': 'Step 1: Visit \ + Twitter Apps to Create New App. A vaild "Website" is not required.
\ + Step 2: Go to Keys and Access Tokens and click \ + Create my access token.
\ + Step 3: Fill in the Consumer Key, Consumer Secret, \ + Access Token, and Access Token Secret below.', 'input_type': 'help' }, - {'label': 'Request Authorization', - 'value': 'Request Authorization', - 'name': 'twitterStep1', - 'description': 'Request Twitter authorization. (Ensure you allow the browser pop-up).', - 'input_type': 'button' - }, - {'label': 'Authorization Key', - 'value': '', - 'name': 'twitter_key', - 'description': 'Your Twitter authorization key.', + {'label': 'Twitter Consumer Key', + 'value': self.consumer_key, + 'name': 'twitter_consumer_key', + 'description': 'Your Twitter consumer key.', 'input_type': 'text' }, - {'label': 'Verify Key', - 'value': 'Verify Key', - 'name': 'twitterStep2', - 'description': 'Verify your Twitter authorization key.', - 'input_type': 'button' + {'label': 'Twitter Consumer Secret', + 'value': self.consumer_secret, + 'name': 'twitter_consumer_secret', + 'description': 'Your Twitter consumer secret.', + 'input_type': 'text' }, - {'input_type': 'nosave' + {'label': 'Twitter Access Token', + 'value': self.access_token, + 'name': 'twitter_access_token', + 'description': 'Your Twitter access token.', + 'input_type': 'text' + }, + {'label': 'Twitter Access Token Secret', + 'value': self.access_token_secret, + 'name': 'twitter_access_token_secret', + 'description': 'Your Twitter access token secret.', + 'input_type': 'text' } ]