mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 05:56:37 +00:00
Merge pull request #556 from tcely/patch-1
Some checks failed
Run Django tests for TubeSync / test (3.7) (push) Has been cancelled
Run Django tests for TubeSync / test (3.8) (push) Has been cancelled
Run Django tests for TubeSync / test (3.9) (push) Has been cancelled
Run Django tests for TubeSync / containerise (push) Has been cancelled
Some checks failed
Run Django tests for TubeSync / test (3.7) (push) Has been cancelled
Run Django tests for TubeSync / test (3.8) (push) Has been cancelled
Run Django tests for TubeSync / test (3.9) (push) Has been cancelled
Run Django tests for TubeSync / containerise (push) Has been cancelled
Use YOUTUBE_DL_TEMPDIR setting
This commit is contained in:
commit
30d2b68cbd
@ -5,17 +5,27 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from common.logger import log
|
from common.logger import log
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
|
||||||
|
|
||||||
_youtubedl_cachedir = getattr(settings, 'YOUTUBE_DL_CACHEDIR', None)
|
|
||||||
_defaults = getattr(settings, 'YOUTUBE_DEFAULTS', {})
|
_defaults = getattr(settings, 'YOUTUBE_DEFAULTS', {})
|
||||||
|
_youtubedl_cachedir = getattr(settings, 'YOUTUBE_DL_CACHEDIR', None)
|
||||||
if _youtubedl_cachedir:
|
if _youtubedl_cachedir:
|
||||||
_youtubedl_cachedir = str(_youtubedl_cachedir)
|
_youtubedl_cachedir = str(_youtubedl_cachedir)
|
||||||
_defaults['cachedir'] = _youtubedl_cachedir
|
_defaults['cachedir'] = _youtubedl_cachedir
|
||||||
|
_youtubedl_tempdir = getattr(settings, 'YOUTUBE_DL_TEMPDIR', None)
|
||||||
|
if _youtubedl_tempdir:
|
||||||
|
_youtubedl_tempdir = str(_youtubedl_tempdir)
|
||||||
|
_youtubedl_tempdir_path = Path(_youtubedl_tempdir)
|
||||||
|
_youtubedl_tempdir_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
(_youtubedl_tempdir_path / '.ignore').touch(exist_ok=True)
|
||||||
|
_paths = _defaults.get('paths', {})
|
||||||
|
_paths.update({ 'temp': _youtubedl_tempdir, })
|
||||||
|
_defaults['paths'] = _paths
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -140,8 +150,9 @@ def download_media(url, media_format, extension, output_file, info_json,
|
|||||||
ytopts = {
|
ytopts = {
|
||||||
'format': media_format,
|
'format': media_format,
|
||||||
'merge_output_format': extension,
|
'merge_output_format': extension,
|
||||||
'outtmpl': output_file,
|
'outtmpl': os.path.basename(output_file),
|
||||||
'quiet': True,
|
'quiet': False if settings.DEBUG else True,
|
||||||
|
'verbose': True if settings.DEBUG else False,
|
||||||
'progress_hooks': [hook],
|
'progress_hooks': [hook],
|
||||||
'writeinfojson': info_json,
|
'writeinfojson': info_json,
|
||||||
'postprocessors': [],
|
'postprocessors': [],
|
||||||
@ -161,6 +172,10 @@ def download_media(url, media_format, extension, output_file, info_json,
|
|||||||
'add_metadata': embed_metadata
|
'add_metadata': embed_metadata
|
||||||
}
|
}
|
||||||
opts = get_yt_opts()
|
opts = get_yt_opts()
|
||||||
|
ytopts['paths'] = opts.get('paths', {})
|
||||||
|
ytopts['paths'].update({
|
||||||
|
'home': os.path.dirname(output_file),
|
||||||
|
})
|
||||||
if embed_thumbnail:
|
if embed_thumbnail:
|
||||||
ytopts['postprocessors'].append({'key': 'EmbedThumbnail'})
|
ytopts['postprocessors'].append({'key': 'EmbedThumbnail'})
|
||||||
if skip_sponsors:
|
if skip_sponsors:
|
||||||
|
@ -61,6 +61,7 @@ if BACKGROUND_TASK_ASYNC_THREADS > MAX_BACKGROUND_TASK_ASYNC_THREADS:
|
|||||||
MEDIA_ROOT = CONFIG_BASE_DIR / 'media'
|
MEDIA_ROOT = CONFIG_BASE_DIR / 'media'
|
||||||
DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR
|
DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR
|
||||||
YOUTUBE_DL_CACHEDIR = CONFIG_BASE_DIR / 'cache'
|
YOUTUBE_DL_CACHEDIR = CONFIG_BASE_DIR / 'cache'
|
||||||
|
YOUTUBE_DL_TEMPDIR = DOWNLOAD_ROOT / 'cache'
|
||||||
COOKIES_FILE = CONFIG_BASE_DIR / 'cookies.txt'
|
COOKIES_FILE = CONFIG_BASE_DIR / 'cookies.txt'
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ VIDEO_HEIGHT_IS_HD = 500 # Height in pixels to count as 'HD'
|
|||||||
|
|
||||||
|
|
||||||
YOUTUBE_DL_CACHEDIR = None
|
YOUTUBE_DL_CACHEDIR = None
|
||||||
|
YOUTUBE_DL_TEMPDIR = None
|
||||||
YOUTUBE_DEFAULTS = {
|
YOUTUBE_DEFAULTS = {
|
||||||
'no_color': True, # Do not use colours in output
|
'no_color': True, # Do not use colours in output
|
||||||
'age_limit': 99, # 'Age in years' to spoof
|
'age_limit': 99, # 'Age in years' to spoof
|
||||||
|
Loading…
Reference in New Issue
Block a user