added discord functionality to extension and polished some of downloader process.

This commit is contained in:
Bryan Van Deusen
2026-01-24 23:15:03 -05:00
parent b9b8048a2d
commit 058901cd05
6 changed files with 186 additions and 28 deletions
+25 -4
View File
@@ -134,13 +134,16 @@ class GalleryDLService:
- Managing temporary config files
"""
# Platform-specific default content types
# Platform-specific default content types and options
# Directory patterns are relative - subscription_name/platform is prepended automatically
PLATFORM_DEFAULTS = {
"patreon": {
"content_types": ["images", "image_large", "attachments", "postfile", "content"],
"directory": ["{date:%Y-%m-%d}_{id}_{title[:40]}"],
"filename": "{num:>02}_{filename}.{extension}",
# Additional options
"videos": True, # Download video content
"embeds": True, # Download embedded URLs (YouTube, etc.)
},
"subscribestar": {
"content_types": ["all"],
@@ -151,11 +154,16 @@ class GalleryDLService:
"content_types": ["pictures"],
"directory": [], # Flat structure within platform folder
"filename": "{category}_{index:>03}_{title[:50]}.{extension}",
"include": "all", # Include all content types
},
"discord": {
"content_types": ["all"],
"directory": ["{channel}"],
"filename": "{date:%Y%m%d}_{message_id}_{filename}.{extension}",
"directory": ["{channel[name]}"],
"filename": "{date:%Y%m%d}_{id}_{filename}.{extension}",
# Additional options
"embeds": True, # Download embedded URLs
"stickers": True, # Download stickers
"reactions": False, # Skip reaction images
},
}
@@ -256,6 +264,11 @@ class GalleryDLService:
# Build platform-specific section
platform_config = {}
# Apply all platform defaults first (videos, embeds, stickers, etc.)
for key, value in platform_defaults.items():
if key not in ["content_types", "directory", "filename"]:
platform_config[key] = value
# Content types (platform-specific handling)
if platform == "patreon":
# Patreon uses "files" array for content types
@@ -266,7 +279,7 @@ class GalleryDLService:
elif platform == "hentaifoundry":
# HentaiFoundry uses "include" for content filtering
if "pictures" in source_config.content_types or "all" in source_config.content_types:
platform_config["include"] = "pictures"
platform_config["include"] = "all"
# Directory pattern
if source_config.directory_pattern:
@@ -342,6 +355,7 @@ class GalleryDLService:
platform: str,
source_config: Optional[SourceConfig] = None,
cookies_path: Optional[str] = None,
auth_token: Optional[str] = None,
) -> DownloadResult:
"""Execute a gallery-dl download.
@@ -351,6 +365,7 @@ class GalleryDLService:
platform: Platform name (patreon, subscribestar, etc.)
source_config: Optional per-source configuration overrides
cookies_path: Optional path to cookies file
auth_token: Optional auth token (for Discord and other token-based platforms)
Returns:
DownloadResult with success status and details
@@ -377,6 +392,12 @@ class GalleryDLService:
if cookies_path:
config["extractor"]["cookies"] = cookies_path
# Add auth token for Discord
if auth_token and platform == "discord":
if "discord" not in config["extractor"]:
config["extractor"]["discord"] = {}
config["extractor"]["discord"]["token"] = auth_token
# Write temporary config file
with tempfile.NamedTemporaryFile(
mode="w",