From eaf2614d23a5ae0a326b1afeeeb1ef7cbf6e1720 Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Fri, 20 May 2016 14:29:57 +0100 Subject: [PATCH] Expand video URLs The previous patch gave you the photo link for the video, not the video itself; this fixes that (and handles non-ascii better again, though it's a bit of a hack having to UTF-8 it twice). patch by adam --- commands.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands.py b/commands.py index ec133f5..ce6b199 100755 --- a/commands.py +++ b/commands.py @@ -519,7 +519,9 @@ def getTweet(urlstring,twitapi): for medium in status.media: if "media_url_https" in medium: - tweetText = tweetText.replace(medium["url"], medium["media_url_https"]) + link = medium["media_url_https"] + link = re.sub(r"/tweet_video_thumb/(\w+).jpg", r"/tweet_video/\1.mp4", link) + tweetText = tweetText.replace(medium["url"], link) for url in status.urls: toReplace = url.expanded_url @@ -535,6 +537,7 @@ def getTweet(urlstring,twitapi): tweetText = tweetText.replace(">",">") tweetText = tweetText.replace("<","<") tweetText = tweetText.replace("&","&") + tweetText = tweetText.encode('UTF-8', 'replace') stringout = "tweet by %s (%s): %s" %(tweeter_screen,tweeter_name,tweetText) except twitter.TwitterError: -- 2.30.2