From f90249fc051e165514380ec35af30e6870dc676c Mon Sep 17 00:00:00 2001 From: robinuniverse Date: Mon, 12 Jul 2021 16:41:07 -0500 Subject: [PATCH] Actually fixed broken descriptions (they were worse than we thought) (thanks maddie again) --- twitfix.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/twitfix.py b/twitfix.py index 6fac3e4..6d2279a 100644 --- a/twitfix.py +++ b/twitfix.py @@ -109,9 +109,15 @@ def linkToVNFfromAPI(vidlink): url = tweet['extended_entities']['media'][0]['video_info']['variants'][-1]['url'] else: url = tweet['extended_entities']['media'][0]['video_info']['variants'][-2]['url'] - - text = textwrap.shorten(tweet['full_text'], width=200, placeholder="...") + + if len(tweet['full_text']) > 200: + text = textwrap.shorten(tweet['full_text'], width=200, placeholder="...") + else: + text = tweet['full_text'] + print(text) + print(len(text)) + vnf = vidInfo(url, vidlink, text, tweet['extended_entities']['media'][0]['media_url'], tweet['user']['name']) return vnf @@ -184,7 +190,8 @@ def addVNFtoLinkCache(vidlink, vnf): return None def embed(vidlink, vnf): - return render_template('index.html', vidurl=vnf['url'], desc=vnf['description'], pic=vnf['thumbnail'], user=vnf['uploader'], vidlink=vidlink) + desc = re.sub(r' http.*t\.co\S+', '', vnf['description'].replace("#","#")) + return render_template('index.html', vidurl=vnf['url'], desc=desc, pic=vnf['thumbnail'], user=vnf['uploader'], vidlink=vidlink) def oEmbedGen(description, user, vidlink): out = {