Exclude custom directories by regex

This commit is contained in:
backbonemedia
2025-05-30 20:48:38 +02:00
parent bb1771be7a
commit 46ed0167cb
2 changed files with 11 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import socketio
import logging
import json
import pathlib
import re
from ytdl import DownloadQueueNotifier, DownloadQueue
from yt_dlp.version import __version__ as yt_dlp_version
@@ -24,6 +25,7 @@ class Config:
'DOWNLOAD_DIRS_INDEXABLE': 'false',
'CUSTOM_DIRS': 'true',
'CREATE_CUSTOM_DIRS': 'true',
'CUSTOM_DIRS_EXCLUDE_REGEX': r'(^|/)[.@].*$',
'DELETE_FILE_ON_TRASHCAN': 'false',
'STATE_DIR': '.',
'URL_PREFIX': '',
@@ -214,8 +216,15 @@ def get_custom_dirs():
return s
# Include only directories which do not match the exclude filter
def include_dir(d):
if len(config.CUSTOM_DIRS_EXCLUDE_REGEX) == 0:
return True
else:
return re.search(config.CUSTOM_DIRS_EXCLUDE_REGEX, d) is None
# Recursively lists all subdirectories of DOWNLOAD_DIR
dirs = list(filter(None, map(convert, path.glob('**'))))
dirs = list(filter(include_dir, map(convert, path.glob('**'))))
return dirs