Merge branch 'Twxtter:main' into main
This commit is contained in:
commit
b5a49706c6
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
<!--
|
||||||
|
{{ color }} - Custom Color Code set in the TwitFix Config
|
||||||
|
{{ appname }} - Custom Appname set in the TwitFix Config
|
||||||
|
{{ user }} - Username of the Source Tweet
|
||||||
|
{{ pic }} - Thumbnail Image for a given video
|
||||||
|
{{ vidlink }} - Direct link back to the source tweet
|
||||||
|
{{ vidurl }} - Direct MP4 link to the video contained in the tweet
|
||||||
|
{{ desc }} - Tweet Text
|
||||||
|
{{ url }} - Base URL of the site hosting TwitFix
|
||||||
|
{{ urlDesc }} - HTTP Encoded Tweet Text
|
||||||
|
{{ urlUser }} - HTTP Encoded Username
|
||||||
|
{{ urlLink }} - HTTP Encoded source link
|
||||||
|
{{ pfp }} - URL of the posters PFP
|
||||||
|
-->
|
||||||
|
{% block head %}
|
||||||
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
||||||
|
<meta content="{{ color }}" name="theme-color" />
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
|
<meta name="twitter:image" content="{{ pic }}" />
|
||||||
|
|
||||||
|
<meta http-equiv = "refresh" content = "0; url = {{ vidlink }}" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
Redirecting you to the tweet in a moment. <a href="{{ vidlink }}">Or click here.</a>
|
||||||
|
{% endblock %}
|
|
@ -2,7 +2,9 @@
|
||||||
module = wsgi:app
|
module = wsgi:app
|
||||||
|
|
||||||
master = true
|
master = true
|
||||||
processes = 5
|
processes = 10
|
||||||
|
|
||||||
|
enable-threads = True
|
||||||
|
|
||||||
socket = twitfix.sock
|
socket = twitfix.sock
|
||||||
chmod-socket = 660
|
chmod-socket = 660
|
||||||
|
|
19
twitfix.py
19
twitfix.py
|
@ -23,9 +23,6 @@ import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
class TwitterUserProtected(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
@ -423,7 +420,7 @@ def dl(sub_path):
|
||||||
print(" ➤ [[ FILE DOES NOT EXIST, DOWNLOADING... ]]")
|
print(" ➤ [[ FILE DOES NOT EXIST, DOWNLOADING... ]]")
|
||||||
addToStat("downloads")
|
addToStat("downloads")
|
||||||
mp4file = urllib.request.urlopen(mp4link)
|
mp4file = urllib.request.urlopen(mp4link)
|
||||||
with open(("/srv/Twxtter-main/static/" + filename), "wb") as output:
|
with open(("/home/twitfix/Twxtter-main/static/" + filename), "wb") as output:
|
||||||
output.write(mp4file.read())
|
output.write(mp4file.read())
|
||||||
|
|
||||||
print(
|
print(
|
||||||
|
@ -474,8 +471,6 @@ def direct_video(video_link): # Just get a redirect to a MP4 link from any twee
|
||||||
addVnfToLinkCache(video_link, vnf)
|
addVnfToLinkCache(video_link, vnf)
|
||||||
return redirect(vnf["url"], 301)
|
return redirect(vnf["url"], 301)
|
||||||
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
||||||
except TwitterUserProtected:
|
|
||||||
return message("This user is guarding their tweets!")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return message("Failed to scan your link!")
|
return message("Failed to scan your link!")
|
||||||
|
@ -494,8 +489,6 @@ def direct_video_link(
|
||||||
addVnfToLinkCache(video_link, vnf)
|
addVnfToLinkCache(video_link, vnf)
|
||||||
return vnf["url"]
|
return vnf["url"]
|
||||||
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
||||||
except TwitterUserProtected:
|
|
||||||
return message("This user is guarding their tweets!")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return message("Failed to scan your link!")
|
return message("Failed to scan your link!")
|
||||||
|
@ -585,10 +578,6 @@ def link_to_vnf_from_api(video_link):
|
||||||
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
|
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
|
||||||
# For when I need to poke around and see what a tweet looks like
|
# For when I need to poke around and see what a tweet looks like
|
||||||
# print(tweet)
|
# print(tweet)
|
||||||
protected = tweet['user']['protected']
|
|
||||||
if protected:
|
|
||||||
raise TwitterUserProtected()
|
|
||||||
|
|
||||||
text = tweet["full_text"]
|
text = tweet["full_text"]
|
||||||
nsfw = tweet.get("possibly_sensitive", False)
|
nsfw = tweet.get("possibly_sensitive", False)
|
||||||
qrt = {}
|
qrt = {}
|
||||||
|
@ -673,9 +662,6 @@ def link_to_vnf(video_link): # Return a VideoInfo object or die trying
|
||||||
if config["config"]["method"] == "hybrid":
|
if config["config"]["method"] == "hybrid":
|
||||||
try:
|
try:
|
||||||
return link_to_vnf_from_api(video_link)
|
return link_to_vnf_from_api(video_link)
|
||||||
except TwitterUserProtected:
|
|
||||||
print(" ➤ [ X ] User is protected, stop.")
|
|
||||||
raise
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(" ➤ [ !!! ] API Failed")
|
print(" ➤ [ !!! ] API Failed")
|
||||||
print(e)
|
print(e)
|
||||||
|
@ -683,9 +669,6 @@ def link_to_vnf(video_link): # Return a VideoInfo object or die trying
|
||||||
elif config["config"]["method"] == "api":
|
elif config["config"]["method"] == "api":
|
||||||
try:
|
try:
|
||||||
return link_to_vnf_from_api(video_link)
|
return link_to_vnf_from_api(video_link)
|
||||||
except TwitterUserProtected:
|
|
||||||
print(" ➤ [ X ] User is protected, stop.")
|
|
||||||
raise
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(" ➤ [ X ] API Failed")
|
print(" ➤ [ X ] API Failed")
|
||||||
print(e)
|
print(e)
|
||||||
|
|
Reference in New Issue