From abb7868e7d4539913b06a9da74c91847f4bd5208 Mon Sep 17 00:00:00 2001 From: Robin Universe Date: Sun, 4 Jul 2021 16:52:38 -0500 Subject: [PATCH] the YoutubeDL object is now created and destroyed as needed to avoid bad guest token bugs after running for a long time --- twitfix.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/twitfix.py b/twitfix.py index 0bac35d..9ad2e94 100644 --- a/twitfix.py +++ b/twitfix.py @@ -3,7 +3,6 @@ import youtube_dl import json import re -ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'}) app = Flask(__name__) pathregex = re.compile("\\w{1,15}\\/status\\/\\d{19}") @@ -26,7 +25,7 @@ def twitfix(subpath): 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) else: - with ydl: + with youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'}) as ydl: try: print("Link not in cache, downloading and adding details to cache file") result = ydl.extract_info(twitter_url, download=False)