+def pocket():
+ """
+ Add new link to Pocket along with tweet id
+ """
+ if not c['POCKET_SUPPORT']:
+ printNicely(yellow('Pocket isn\'t enabled.'))
+ printNicely(yellow('You need to "config POCKET_SUPPORT = true"'))
+ return
+
+ # Get tweet infos
+ p = pckt_authen()
+
+ t = Twitter(auth=authen())
+ try:
+ id = int(g['stuff'].split()[0])
+ tid = c['tweet_dict'][id]
+ except:
+ printNicely(red('Sorry I can\'t understand.'))
+ return
+
+ tweet = t.statuses.show(id=tid)
+
+ if len(tweet['entities']['urls']) > 0:
+ url = tweet['entities']['urls'][0]['expanded_url']
+ else:
+ url = "https://twitter.com/" + \
+ tweet['user']['screen_name'] + '/status/' + str(tid)
+
+ # Add link to pocket
+ try:
+ p.add(title=re.sub(r'(http:\/\/\S+)', r'', tweet['text']),
+ url=url,
+ tweet_id=tid)
+ except:
+ printNicely(red('Something is wrong about your Pocket account,'+ \
+ ' please restart Rainbowstream.'))
+ pocket_credential = os.environ.get(
+ 'HOME',
+ os.environ.get(
+ 'USERPROFILE',
+ '')) + os.sep + '.rainbow_pckt_oauth'
+ if os.path.exists(pocket_credential):
+ os.remove(pocket_credential)
+ return
+
+ printNicely(green('Pocketed !'))
+ printNicely('')
+
+