the YoutubeDL object is now created and destroyed as needed to avoid bad guest token bugs after running for a long time
This commit is contained in:
parent
6b4fbf97f0
commit
abb7868e7d
1 changed files with 1 additions and 2 deletions
|
@ -3,7 +3,6 @@ import youtube_dl
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'})
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
pathregex = re.compile("\\w{1,15}\\/status\\/\\d{19}")
|
pathregex = re.compile("\\w{1,15}\\/status\\/\\d{19}")
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ def twitfix(subpath):
|
||||||
print("Link located in cache")
|
print("Link located in cache")
|
||||||
return render_template('index.html', vidurl=link_cache[twitter_url]['url'], tweet=link_cache[twitter_url]['description'], pic=link_cache[twitter_url]['thumbnail'], user=link_cache[twitter_url]['uploader'], tweeturl=twitter_url)
|
return render_template('index.html', vidurl=link_cache[twitter_url]['url'], tweet=link_cache[twitter_url]['description'], pic=link_cache[twitter_url]['thumbnail'], user=link_cache[twitter_url]['uploader'], tweeturl=twitter_url)
|
||||||
else:
|
else:
|
||||||
with ydl:
|
with youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'}) as ydl:
|
||||||
try:
|
try:
|
||||||
print("Link not in cache, downloading and adding details to cache file")
|
print("Link not in cache, downloading and adding details to cache file")
|
||||||
result = ydl.extract_info(twitter_url, download=False)
|
result = ydl.extract_info(twitter_url, download=False)
|
||||||
|
|
Loading…
Reference in a new issue