rainbowstream
rainbowstream copied to clipboard
User is unable to open url's shortened by Twitters URL shortener
- System: Kubuntu 18.04
- Python version: 2.7
- rainbowstream v 1.3.7
Repro:
-
Launch rainbowstream
-
Locate a tweet that contains a URL shortened by Twitters URL shortener(https://t.co/wNYPltI7ll )

-
Type
open id#
Expected:
- The link will open in the default web browser.
Bug:
No url here @.@!is displayed.
Additional Notes:
- I've confirmed that bit.ly and ow.ly shortened links open correctly in my setup.
can not confirm this, since it is working correctly on 1.3.8. Did you try to upgrade?
I upgraded to rainbowstream v1.3.9 using:
sudo pip install -U rainbowstream
I am able to reproduce the same behavior.
To rule out the terminal, I tried both Konsole and st terminal. The same bug behavior was seen in both.
Update:
Had to change my previous comment because I also followed that @HorrorAudio account and found out that the t.co links it is posting do not open for me too.
Not sure what it is related to... But obviously urlopen function returns urls = None, hence the error.
Would like to see developer answer too.
HorrorAudio @HorrorAudio 11 minutes ago
♺:1 ♥:0 id:12 via RoundTeam
RT @RifaOlivier: What makes you stop writing variations, new harmony, trying different path for a track ? What makes you say stop writin, let's produce, now ?
Is it time schedule ? enough material ? Faith ?
#composition #composer #GameAudio https://t.co/SEaTJV2BNw
[@movalex]: open 12
No url here @.@!
It looks like the URLs are provided by Twitter's API library, so this may need to be addressed upstream.
I don't know any Python, but I was able to figure out some workaround for the "No url here @.@" problem. It seems the problem is based on the place of the shown URL in the Twitter API return value for a tweet. So adding some code in rainbow.py function urlopen() to find different places for the URLs does the magic:
def urlopen():
...
urls = tweet['entities']['urls']
if not urls:
try:
urls = tweet['entities']['media']
except:
urls = {}
if not urls:
try:
urls = tweet['retweeted_status']['quoted_status']['entities']['urls']
except:
urls = {}
if not urls:
printNicely(light_magenta('No url here @.@!'))
return
...
I don't know, if I have found all places for URLs. Maybe someone can improve on this.