Fixes for default preset.
This commit is contained in:
parent
45227be6bf
commit
fcb2eda4ba
9 changed files with 77 additions and 77 deletions
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
|
|
@ -34,7 +34,8 @@
|
|||
"YTP_TEMP_PATH": "${workspaceFolder}/var/tmp",
|
||||
"YTP_URL_HOST": "http://localhost:8081",
|
||||
"YTP_LOG_LEVEL": "DEBUG",
|
||||
"YTP_DEBUG": "false",
|
||||
"YTP_DEBUG": "true",
|
||||
"YTP_YTDL_DEBUG": "true",
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class DataStore:
|
|||
return None
|
||||
|
||||
async def test(self) -> bool:
|
||||
await self.connection.execute('SELECT "id" FROM "history" LIMIT 1').fetchone()
|
||||
self.connection.execute('SELECT "id" FROM "history" LIMIT 1').fetchone()
|
||||
return True
|
||||
|
||||
def _updateStoreItem(self, type: str, item: ItemDTO) -> None:
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Download:
|
|||
self.output_template_chapter = info.output_template_chapter
|
||||
self.output_template = info.output_template
|
||||
self.preset = info.preset
|
||||
self.ytdl_opts = get_opts(self.preset, info.ytdlp_config if info.ytdlp_config else {})
|
||||
self.ytdl_opts = info.ytdlp_config if info.ytdlp_config else {}
|
||||
self.info = info
|
||||
self.id = info._id
|
||||
self.default_ytdl_opts = config.ytdl_options
|
||||
|
|
@ -121,7 +121,7 @@ class Download:
|
|||
'break_on_existing': True,
|
||||
'progress_hooks': [self._progress_hook],
|
||||
'postprocessor_hooks': [self._postprocessor_hook],
|
||||
**mergeConfig(self.default_ytdl_opts, self.ytdl_opts),
|
||||
**get_opts(self.preset, mergeConfig(self.default_ytdl_opts, self.ytdl_opts)),
|
||||
}
|
||||
|
||||
if 'format' not in params and self.default_ytdl_opts.get('format', None):
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class DownloadQueue:
|
|||
):
|
||||
ytdlp_config = ytdlp_config if ytdlp_config else {}
|
||||
|
||||
LOG.info(f"Adding url '{url}' to folder '{folder}' with the following options 'Preset: {preset=}' 'Naming: {output_template}', 'Cookies: {ytdlp_cookies}' 'YTConfig: {ytdlp_config}'.")
|
||||
LOG.info(f"Adding url '{url}' to folder '{folder}' with the following options 'Preset: {preset}' 'Naming: {output_template}', 'Cookies: {ytdlp_cookies}' 'YTConfig: {ytdlp_config}'.")
|
||||
|
||||
if isinstance(ytdlp_config, str):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -32,33 +32,33 @@ def get_opts(preset: str, ytdl_opts: dict) -> dict:
|
|||
opts = copy.deepcopy(ytdl_opts)
|
||||
|
||||
if 'default' == preset:
|
||||
LOG.debug("Using default preset.")
|
||||
return opts
|
||||
|
||||
from .config import Config
|
||||
presets = Config.get_instance().presets
|
||||
|
||||
if preset not in presets:
|
||||
found = False
|
||||
for _preset in presets:
|
||||
if _preset['name'] == preset:
|
||||
found = True
|
||||
preset_opts = _preset
|
||||
break
|
||||
|
||||
if not found:
|
||||
LOG.error(f"Preset '{preset}' is not defined in the presets.")
|
||||
return opts
|
||||
|
||||
preset_opts = presets[preset]
|
||||
|
||||
opts['format'] = preset_opts.get('format')
|
||||
|
||||
if 'postprocessors' in preset_opts:
|
||||
if 'postprocessors' not in opts:
|
||||
opts['postprocessors'] = []
|
||||
|
||||
opts['postprocessors'].extend(preset_opts['postprocessors'])
|
||||
opts['postprocessors'] = preset_opts['postprocessors']
|
||||
|
||||
if 'args' in preset_opts:
|
||||
for ignored_key in IGNORED_KEYS:
|
||||
for key, value in preset_opts['args'].items():
|
||||
if key == ignored_key:
|
||||
continue
|
||||
|
||||
opts[key] = value
|
||||
for key, value in preset_opts['args'].items():
|
||||
opts[key] = value
|
||||
|
||||
LOG.debug(f"Using preset '{preset}', altered options: {opts}")
|
||||
return opts
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,43 +66,50 @@ class Config:
|
|||
ytdlp_version: str = YTDLP_VERSION
|
||||
tasks: list = []
|
||||
presets: list = [
|
||||
{'name': 'default', 'format': 'default', 'postprocessors': [],
|
||||
'args': {}},
|
||||
{'name': 'Video - 1080p h264/acc', 'format': 'bv[height<=1080][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]',
|
||||
'args': {'format_sort': ['vcodec:h264'], }, },
|
||||
{'name': 'Video - 720p h264/acc', 'format': 'bv[height<=720][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]',
|
||||
'args': {'format_sort': ['vcodec:h264'], }, },
|
||||
{
|
||||
'name': 'Default - Use default yt-dlp format',
|
||||
'format': 'default',
|
||||
'postprocessors': [],
|
||||
'args': {}
|
||||
},
|
||||
# {
|
||||
# 'name': 'Audio - Best audio [MP3]',
|
||||
# 'format': 'bestaudio',
|
||||
# 'postprocessors': [
|
||||
# {'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': 'best'},
|
||||
# {"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"},
|
||||
# {'key': 'FFmpegMetadata'},
|
||||
# {'key': 'EmbedThumbnail'},
|
||||
# ],
|
||||
# 'args': {
|
||||
# 'writethumbnail': True
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'name': 'Video - 1080p h264/acc',
|
||||
'format': 'bv[height<=1080][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]',
|
||||
'name': 'Audio - Best audio [MP3]',
|
||||
'format': 'bestaudio/best',
|
||||
'postprocessors': [
|
||||
{
|
||||
"key": "FFmpegExtractAudio",
|
||||
"preferredcodec": "mp3",
|
||||
"preferredquality": "5",
|
||||
"nopostoverwrites": False
|
||||
},
|
||||
{
|
||||
"key": "FFmpegMetadata",
|
||||
"add_chapters": True,
|
||||
"add_metadata": True,
|
||||
"add_infojson": "if_exists"
|
||||
},
|
||||
{
|
||||
"key": "EmbedThumbnail",
|
||||
"already_have_thumbnail": False
|
||||
},
|
||||
{
|
||||
"key": "FFmpegConcat",
|
||||
"only_multi_video": True,
|
||||
"when": "playlist"
|
||||
}
|
||||
],
|
||||
'args': {
|
||||
'format_sort': [
|
||||
'vcodec:h264'
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'Video - 720p h264/acc',
|
||||
'format': 'bv[height<=720][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]',
|
||||
'args': {
|
||||
'format_sort': [
|
||||
'vcodec:h264'
|
||||
],
|
||||
},
|
||||
},
|
||||
"outtmpl": {
|
||||
"pl_thumbnail": ""
|
||||
},
|
||||
"ignoreerrors": "only_download",
|
||||
"retries": 10,
|
||||
"fragment_retries": 10,
|
||||
"writethumbnail": True,
|
||||
"extract_flat": "discard_in_playlist",
|
||||
"final_ext": "mp3",
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
_manual_vars: tuple = ('temp_path', 'config_path', 'download_path',)
|
||||
|
|
@ -119,7 +126,7 @@ class Config:
|
|||
'ytdlp_version', 'version', 'url_host', 'started', 'url_prefix',
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ staticmethod
|
||||
def get_instance():
|
||||
""" Static access method. """
|
||||
return Config() if not Config.__instance else Config.__instance
|
||||
|
|
@ -207,7 +214,7 @@ class Config:
|
|||
LOG.error(f"Error starting debugpy server at '0.0.0.0:{self.debugpy_port}'. {e}")
|
||||
|
||||
optsFile: str = os.path.join(self.config_path, 'ytdlp.json')
|
||||
if os.path.exists(optsFile) and os.path.getsize(optsFile) > 0:
|
||||
if os.path.exists(optsFile) and os.path.getsize(optsFile) > 4:
|
||||
LOG.info(f"Loading yt-dlp custom options from '{optsFile}'.")
|
||||
|
||||
(opts, status, error) = load_file(optsFile, dict)
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@
|
|||
<div v-if="item.thumbnail && false === hideThumbnail" class="card-image">
|
||||
<figure class="image is-3by1">
|
||||
<template v-if="item.status === 'finished'">
|
||||
<NuxtLink v-tooltip="`Play: ${item.title}`" :href="makeDownload(config, item, 'm3u8')"
|
||||
<a v-tooltip="`Play: ${item.title}`" :href="makeDownload(config, item, 'm3u8')"
|
||||
@click.prevent="playVideo(item)">
|
||||
<img
|
||||
:src="config.app.url_host + config.app.url_prefix + 'thumbnail?url=' + encodePath(item.thumbnail)"
|
||||
:alt="item.title" />
|
||||
</NuxtLink>
|
||||
</a>
|
||||
</template>
|
||||
<template v-else>
|
||||
<NuxtLink target="_blank" :href="item.url" v-tooltip="`Open: ${item.title} link`">
|
||||
|
|
@ -403,16 +403,7 @@ const requeueIncomplete = () => {
|
|||
if ('finished' === item.status) {
|
||||
continue;
|
||||
}
|
||||
|
||||
emits('deleteItem', 'completed', key);
|
||||
emits('addItem', {
|
||||
url: item.url,
|
||||
format: item.preset,
|
||||
folder: item.folder,
|
||||
ytdlp_config: item.ytdlp_config,
|
||||
ytdlp_cookies: item.ytdlp_cookies,
|
||||
output_template: item.output_template,
|
||||
});
|
||||
reQueueItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -428,8 +419,7 @@ const reQueueItem = item => {
|
|||
socket.emit('item_delete', item._id)
|
||||
socket.emit('add_url', {
|
||||
url: item.url,
|
||||
format: item.format,
|
||||
quality: item.quality,
|
||||
preset: item.preset,
|
||||
folder: item.folder,
|
||||
ytdlp_config: item.ytdlp_config,
|
||||
ytdlp_cookies: item.ytdlp_cookies,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<div class="control is-expanded">
|
||||
<div class="select is-fullwidth">
|
||||
<select id="preset" class="is-fullwidth" :disabled="!socket.isConnected" v-model="selectedPreset">
|
||||
<option v-for="item in config.presets" :key="item.name" :value="item.format">
|
||||
<option v-for="item in config.presets" :key="item.name" :value="item.name">
|
||||
{{ item.name }}
|
||||
</option>
|
||||
</select>
|
||||
|
|
@ -135,7 +135,7 @@ const config = useConfigStore();
|
|||
const socket = useSocketStore();
|
||||
const toast = useToast();
|
||||
|
||||
const selectedPreset = useStorage('selectedPreset', 'default')
|
||||
const selectedPreset = useStorage('selectedPreset', '')
|
||||
const ytdlpConfig = useStorage('ytdlp_config', '')
|
||||
const ytdlpCookies = useStorage('ytdlp_cookies', '')
|
||||
const output_template = useStorage('output_template', null)
|
||||
|
|
@ -166,8 +166,8 @@ const resetConfig = () => {
|
|||
ytdlpConfig.value = '';
|
||||
ytdlpCookies.value = '';
|
||||
output_template.value = null;
|
||||
url.value = '';
|
||||
downloadPath.value = '';
|
||||
url.value = null;
|
||||
downloadPath.value = null;
|
||||
showAdvanced.value = false;
|
||||
|
||||
toast.success('Local configuration has been reset.');
|
||||
|
|
@ -186,6 +186,11 @@ const statusHandler = async data => {
|
|||
url.value = '';
|
||||
}
|
||||
|
||||
onMounted(() => socket.on('status', statusHandler))
|
||||
onMounted(() => {
|
||||
socket.on('status', statusHandler)
|
||||
if ('' === selectedPreset.value) {
|
||||
selectedPreset.value = 'default'
|
||||
}
|
||||
})
|
||||
onUnmounted(() => socket.off('status', statusHandler))
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ export const useSocketStore = defineStore('socket', () => {
|
|||
socket.value.on('completed', stream => {
|
||||
const item = JSON.parse(stream);
|
||||
|
||||
console.log(item)
|
||||
if (true === stateStore.has('queue', item._id)) {
|
||||
stateStore.remove('queue', item._id);
|
||||
}
|
||||
|
|
@ -56,7 +55,6 @@ export const useSocketStore = defineStore('socket', () => {
|
|||
const id = JSON.parse(stream);
|
||||
|
||||
if (true !== stateStore.has('queue', id)) {
|
||||
console.log(stream)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +69,6 @@ export const useSocketStore = defineStore('socket', () => {
|
|||
const id = JSON.parse(stream);
|
||||
|
||||
if (true !== stateStore.has('history', id)) {
|
||||
console.log(stream)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue