feat: 媒体库多根配置生效并增强扫描健壮性

This commit is contained in:
tigerenwork 2026-08-16 19:22:06 +08:00
parent 2ca9e0a975
commit 78554ea022
4 changed files with 23 additions and 16 deletions

View File

@ -47,8 +47,8 @@ guide to switching back to the official build once the upstream fix lands.
./build-ytdlp.sh
docker buildx build --platform linux/amd64 \
--build-arg VERSION=1.30 \
-t 192.168.2.212:3000/tigeren/metube:1.30 \
--build-arg VERSION=1.31 \
-t 192.168.2.212:3000/tigeren/metube:1.31 \
--push .
```

View File

@ -95,6 +95,8 @@ class Config:
self.LIBRARY_ROOTS = normalize_library_roots(roots)
if self.LIBRARY_DIRS and not self.LIBRARY_ROOTS:
log.warning('Library feature disabled: none of LIBRARY_DIRS exists')
if self.LIBRARY_ROOTS:
log.info('Library roots: ' + ', '.join(f'{label or "(root)"} -> {path}' for label, path in self.LIBRARY_ROOTS))
if not self.URL_PREFIX.endswith('/'):
self.URL_PREFIX += '/'
@ -402,7 +404,10 @@ def _scan_library_folders(roots):
exclude = re.compile(config.CUSTOM_DIRS_EXCLUDE_REGEX) if config.CUSTOM_DIRS_EXCLUDE_REGEX else None
folders = []
for label, root in roots:
for dirpath, dirnames, filenames in os.walk(root):
def _on_walk_error(exc):
log.warning(f'Library scan error under "{root}": {exc!r}')
for dirpath, dirnames, filenames in os.walk(root, onerror=_on_walk_error):
rel = os.path.relpath(dirpath, root)
dirnames[:] = [d for d in dirnames
if not (exclude and exclude.search(os.path.normpath(os.path.join(rel, d))))]

View File

@ -11,14 +11,14 @@ services:
volumes:
- ./downloads:/downloads
- ./metube-config:/config
# Media library for the organize/browse feature (change the host path to your real library)
- ./library:/library
# Media library for the organize/browse feature (change the host path to your real library)
- ./library:/library
# Multiple library mounts share one Library view; each mount becomes a
# top-level collapsible group. Uncomment to use instead of ./library:
# - /mnt/media-a:/media/media-a
# - /mnt/media-b:/media/media-b
# Optional: mount cookies file for authenticated downloads
# - ./cookies:/cookies:ro
- ./library/media-a:/media/media-a
- ./library/media-b:/media/media-b
# Optional: mount cookies file for authenticated downloads
# - ./cookies:/cookies:ro
environment:
# Basic configuration
- UID=0
@ -29,10 +29,10 @@ services:
- DOWNLOAD_DIR=/downloads
- STATE_DIR=/config
- TEMP_DIR=/downloads
# Media library (organize/browse feature); leave empty to disable
- LIBRARY_DIR=/library
# Multi-root alternative (overrides LIBRARY_DIR, comma-separated):
# - LIBRARY_DIRS=/media/media-a,/media/media-b
# Media library (organize/browse feature); leave empty to disable
- LIBRARY_DIR=/library
# Multi-root alternative (overrides LIBRARY_DIR, comma-separated):
- LIBRARY_DIRS=/media/media-a,/media/media-b
# Download behavior
- DOWNLOAD_MODE=limited
@ -117,4 +117,4 @@ services:
# metube-downloads:
# driver: local
# metube-cookies:
# driver: local
# driver: local

View File

@ -177,12 +177,14 @@
background: var(--bg)
color: var(--fg)
svg
fa-icon
display: inline-block
font-size: 11px
line-height: 1
transition: transform 0.15s ease
transform: rotate(90deg)
&.collapsed svg
&.collapsed fa-icon
transform: none
.lib-group-item