download_media: Add function for checking if a URL has been downloaded before

pull/408/head
Mike Lang 3 months ago committed by Mike Lang
parent 352c9e9081
commit b46c577014

@ -14,7 +14,7 @@ import prometheus_client as prom
import urllib3.connection import urllib3.connection
from ipaddress import ip_address from ipaddress import ip_address
from . import atomic_write, ensure_directory, jitter from . import atomic_write, ensure_directory, jitter, listdir
from .stats import timed from .stats import timed
@ -52,6 +52,12 @@ class WrongContent(Rejected):
"""Response was not a video or image""" """Response was not a video or image"""
def check_for_media(output_dir, url):
"""Returns True if we have at least one version of content for the given url already."""
url_dir = get_url_dir(output_dir, url)
return any(filename.endswith(".metadata.json") for filename in listdir(url_dir))
@timed() @timed()
def download_media( def download_media(
url, url,

Loading…
Cancel
Save