mirror of
https://github.com/Dasemu/x-space-downloader.git
synced 2026-11-28 00:06:50 +00:00
refactor: improve downloader robustness and test coverage
- Add test for cookies_file parameter verification - Add test for yt-dlp configuration (format, outtmpl, postprocessors) - Use validator module for robust space_id extraction - Replace fragile URL splitting with validate_space_url() - Handles trailing slashes and query parameters correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
0a6a2ffd71
commit
73775c122b
2 files changed
+66
-2
No files matched your search
+8
-2
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import yt_dlp
|
||||
from typing import Optional
|
||||
from src.validator import validate_space_url
|
||||
|
||||
|
||||
def download_space(
|
||||
@@ -19,8 +20,13 @@ def download_space(
|
||||
Returns:
|
||||
Path to the downloaded MP3 file
|
||||
"""
|
||||
# Extract space ID from URL for filename
|
||||
space_id = space_url.split('/')[-1]
|
||||
# Extract space ID from URL using validator for robustness
|
||||
is_valid, space_id, error_message = validate_space_url(space_url)
|
||||
if not is_valid:
|
||||
raise ValueError(f"Invalid space URL: {error_message}")
|
||||
|
||||
if space_id is None:
|
||||
raise ValueError("Could not extract space ID from URL")
|
||||
|
||||
# Configure yt-dlp options
|
||||
ydl_opts = {
|
||||
|
||||
Reference in new issue
Block a user