Merge pull request #50 from adryd325/patch-2

Fix tweet text content appearing in telegram and some other stuff
This commit is contained in:
Robin Universe 2022-05-04 11:05:31 -05:00 committed by GitHub
commit 9d754a9bf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 17 deletions

View file

@ -2,3 +2,4 @@ Flask
youtube_dl
pymongo
twitter
flask_cors

View file

@ -5,7 +5,7 @@
<meta content="{{ appname }}" property="og:title" />
<meta content="{{ message }}" property="og:description" />
<meta content="{{ repo }}" property="og:url" />
<meta content="{{ color }}" data-react-helmet="true" name="theme-color" />
<meta content="{{ color }}" name="theme-color" />
<meta http-equiv = "refresh" content = "0; url = {{ repo }}" />
{% endblock %}

View file

@ -15,7 +15,7 @@
-->
{% block head %}
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="{{ color }}" data-react-helmet="true" name="theme-color" />
<meta content="{{ color }}" name="theme-color" />
<meta property="og:site_name" content="{{ appname }}"/>
<meta name="twitter:card" content="summary_large_image" />

View file

@ -2,7 +2,7 @@
{% block head %}
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
<meta content="{{ color }}" data-react-helmet="true" name="theme-color" />
<meta content="{{ color }}" name="theme-color" />
<meta property="og:site_name" content="{{ appname }}">
<meta name="twitter:card" content="player" />
@ -15,7 +15,6 @@
<meta name="twitter:player:height" content="480" />
<meta name="twitter:player:stream" content="{{ vidurl }}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
<meta property="og:url" content="{{ vidlink }}" />
<meta property="og:video" content="{{ vidurl }}" />
@ -23,10 +22,11 @@
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="720" />
<meta property="og:video:height" content="480" />
<meta property="og:title" content="{{ user }}" />
<!--<meta property="og:description" content="{{ desc }}" />!-->
<meta property="og:description" content="{{ desc }}" />
<meta property="og:image" content="{{ pic }}" />
<meta name="description" content="{{ desc }}" />
<!--!-->
<link rel="alternate" href="{{ url }}/oembed.json?desc={{ urlUser }}&user={{ urlDesc }}&link={{ urlLink }}" type="application/json+oembed" title="{{ user }}">
<meta http-equiv = "refresh" content = "0; url = {{ vidlink }}" />

View file

@ -19,7 +19,7 @@
-->
{% block head %}
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="{{ color }}" data-react-helmet="true" name="theme-color" />
<meta content="{{ color }}" name="theme-color" />
<meta property="og:site_name" content="{{ appname }}"/>
<meta property="og:image" content="{{ pfp }}" />

View file

@ -2,7 +2,7 @@
{% block head %}
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
<meta content="{{ color }}" data-react-helmet="true" name="theme-color" />
<meta content="{{ color }}" name="theme-color" />
<meta property="og:site_name" content="{{ appname }}">
<meta name="twitter:card" content="player" />
@ -19,8 +19,8 @@
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="720" />
<meta property="og:video:height" content="480" />
<meta name="twitter:title" content="{{ user }} (@{{ screenName }})" />
<meta property="og:image" content="{{ pic }}" />
<meta name="description" content="{{ desc }}" />
<link rel="alternate" href="{{ url }}/oembed.json?desc={{ urlUser }}&user={{ urlDesc }}&link={{ urlLink }}&ttype=video" type="application/json+oembed" title="{{ user }}">
<meta http-equiv = "refresh" content = "0; url = {{ vidlink }}" />

View file

@ -387,9 +387,9 @@ def tweetInfo(url, tweet="", desc="", thumb="", uploader="", screen_name="", pfp
def link_to_vnf_from_api(video_link):
print(" ➤ [ + ] Attempting to download tweet info from Twitter API")
imgs = ["","","",""] # initialize this in this scope to not cause errors
twid = int(re.sub(r'\?.*$','',video_link.rsplit("/", 1)[-1])) # gets the tweet ID as a int from the passed url
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
#print(tweet)
print(" ➤ [ + ] Tweet Type: " + tweetType(tweet))
# Check to see if tweet has a video, if not, make the url passed to the VNF the first t.co link in the tweet
if tweetType(tweet) == "Video":
@ -397,13 +397,12 @@ def link_to_vnf_from_api(video_link):
best_bitrate = 0
thumb = tweet['extended_entities']['media'][0]['media_url']
for video in tweet['extended_entities']['media'][0]['video_info']['variants']:
if video.content_type == "video/mp4" and video.bitrate > best_bitrate:
url = video.url
if video['content_type'] == "video/mp4" and video['bitrate'] > best_bitrate:
url = video['url']
elif tweetType(tweet) == "Text":
url = ""
thumb = ""
else:
imgs = ["","","",""]
i = 0
for media in tweet['extended_entities']['media']:
imgs[i] = media['media_url_https']
@ -412,7 +411,6 @@ def link_to_vnf_from_api(video_link):
#print(imgs)
url = ""
images= imgs
thumb = tweet['extended_entities']['media'][0]['media_url_https']
qrt = {}
@ -420,7 +418,7 @@ def link_to_vnf_from_api(video_link):
if 'quoted_status' in tweet:
qrt['desc'] = tweet['quoted_status']['full_text']
qrt['handle'] = tweet['quoted_status']['user']['name']
qrt['screenname'] = tweet['quoted_status']['user']['screen_name']
qrt['screen_name'] = tweet['quoted_status']['user']['screen_name']
text = tweet['full_text']
@ -525,7 +523,7 @@ def embed(video_link, vnf, image):
elif vnf['qrt'] == {}: # Check if this is a QRT and modify the description
desc = (desc + likeDisplay)
else:
qrtDisplay = ("\n─────────────\n ➤ QRT of " + vnf['qrt']['handle'] + " (@" + vnf['qrt']['screenname'] + "):\n─────────────\n'" + vnf['qrt']['desc'] + "'")
qrtDisplay = ("\n─────────────\n ➤ QRT of " + vnf['qrt']['handle'] + " (@" + vnf['qrt']['screen_name'] + "):\n─────────────\n'" + vnf['qrt']['desc'] + "'")
desc = (desc + qrtDisplay + likeDisplay)
except:
vnf['likes'] = 0; vnf['rts'] = 0; vnf['time'] = 0

View file

@ -1,4 +1,5 @@
from twitfix import app
if __name__ == "__main__":
app.run()
# listen on 0.0.0.0 to facilitate testing with real services
app.run(host='0.0.0.0')