Add access tracker for cleaning CDN
This commit is contained in:
parent
e43a67b0d5
commit
c18260ebcb
4 changed files with 104 additions and 4 deletions
8
app.py
8
app.py
|
|
@ -17,6 +17,7 @@ from botocore.client import Config as BotoConfig
|
|||
import urllib.parse
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from access_tracker import AccessTracker
|
||||
load_dotenv()
|
||||
|
||||
logging.basicConfig(
|
||||
|
|
@ -83,6 +84,8 @@ download_tracker = {
|
|||
download_lock = threading.Lock()
|
||||
download_queue = []
|
||||
|
||||
access_tracker = AccessTracker()
|
||||
|
||||
def download_and_upload_video(video_id, url, video_quality):
|
||||
try:
|
||||
with download_lock:
|
||||
|
|
@ -411,6 +414,11 @@ if you want to download videos, please consider using a tool like nndownload: ht
|
|||
logger.info(f"{video_id}: Caching HTML response")
|
||||
cache.set(f"{video_id}{cache_html_suffix}", html_response, expire=CACHE_EXPIRATION_HTML)
|
||||
|
||||
# Record access time for CDN cleanup purposes
|
||||
if is_video_in_cdn(video_id):
|
||||
access_tracker.record_access(video_id)
|
||||
logger.debug(f"{video_id}: Recorded access time for CDN tracking")
|
||||
|
||||
logger.info(f"{video_id}: Returning response")
|
||||
logger.debug(f"{video_id}: HTML response:\n----------\n{html_response}\n----------")
|
||||
return Response(html_response, mimetype="text/html")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue