From: Matthew Vernon Date: Fri, 20 May 2016 13:29:57 +0000 (+0100) Subject: Expand video URLs X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?p=irc.git;a=commitdiff_plain;h=eaf2614d23a5ae0a326b1afeeeb1ef7cbf6e1720 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 --- 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: