Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get url from parsed tweet when entities urls are not found #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rainbowstream/colorset/config
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"IMAGE_MAX_HEIGHT" : 90,
// Seconds to wait before displaying another tweet, will drop all tweets while waiting.
"STREAM_DELAY" : 0,
// Set default browser for open link, default is w3m
"BROWSER": "w3m",
// Stream config
"USER_DOMAIN" : "userstream.twitter.com",
"PUBLIC_DOMAIN" : "stream.twitter.com",
Expand Down
10 changes: 6 additions & 4 deletions rainbowstream/rainbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from twitter.oauth import OAuth, read_token_file
from twitter.oauth_dance import oauth_dance
from twitter.util import printNicely
from ttp import ttp
from subprocess import call

from pocket import Pocket

Expand Down Expand Up @@ -753,14 +755,14 @@ def urlopen():
return
tid = c['tweet_dict'][int(g['stuff'])]
tweet = t.statuses.show(id=tid)
urls = tweet['entities']['urls']
# get url from entities. If it's not found get url from parsed tweet
urls = tweet['entities']['urls'] or ttp.Parser().parse(tweet).urls
if not urls:
printNicely(light_magenta('No url here @.@!'))
return
else:
for url in urls:
expanded_url = url['expanded_url']
webbrowser.open(expanded_url)
expanded_url = url['expanded_url'] or url
call([c['BROWSER'],expanded_url])
except:
debug_option()
printNicely(red('Sorry I can\'t open url in this tweet.'))
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"twitter",
"Pillow",
"PySocks",
"pocket"
"pocket",
"twitter-text-python"
]

# Default user (considers non virtualenv method)
Expand Down