enable youtube-dl cache dir by default with optional setting for container builds

This commit is contained in:
meeb 2020-12-14 02:01:31 +11:00
parent e709db8ffe
commit 7fd6e41f0c
3 changed files with 8 additions and 0 deletions

View File

@ -11,7 +11,13 @@ from common.logger import log
import youtube_dl
_youtubedl_cachdir = getattr(settings, 'YOUTUBE_DL_CACHEDIR', None)
_defaults = getattr(settings, 'YOUTUBE_DEFAULTS', {})
if _youtubedl_cachdir:
_youtubedl_cachdir = str(_youtubedl_cachdir)
if os.path.isdir(_youtubedl_cachdir):
_defaults['cachedir'] = _youtubedl_cachdir
class YouTubeError(youtube_dl.utils.DownloadError):

View File

@ -29,3 +29,4 @@ DATABASES = {
MEDIA_ROOT = CONFIG_BASE_DIR / 'media'
DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR
YOUTUBE_DL_CACHEDIR = CONFIG_BASE_DIR / 'cache'

View File

@ -138,6 +138,7 @@ VIDEO_HEIGHT_CUTOFF = 360 # Smallest resolution in pixels permitted to dow
VIDEO_HEIGHT_IS_HD = 500 # Height in pixels to count as 'HD'
YOUTUBE_DL_CACHEDIR = None
YOUTUBE_DEFAULTS = {
'no_color': True, # Do not use colours in output
'age_limit': 99, # 'Age in years' to spoof