Skip to content

Add optional filename_template support and filename migration CLI#826

Open
wrxco wants to merge 3 commits intomxpv:mainfrom
wrxco:codex/pr-filename-template
Open

Add optional filename_template support and filename migration CLI#826
wrxco wants to merge 3 commits intomxpv:mainfrom
wrxco:codex/pr-filename-template

Conversation

@wrxco
Copy link

@wrxco wrxco commented Feb 17, 2026

Summary

This PR adds optional filename templating for downloaded media (and enclosure paths) while preserving existing behavior by default.

What’s included

  • New optional feed config key: filename_template
  • Supported tokens: {{id}}, {{title}}, {{pub_date}}, {{feed_id}}
  • Validation for template tokens in config loading
  • Download/output naming now uses template when set
  • RSS enclosure URLs reflect the configured filename format
  • One-time migration tooling:
    • --migrate-filenames
    • --migrate-filenames-dry-run
  • Tests and docs updates (config.toml.example, README)

Backward compatibility

  • No breaking change intended.
  • If filename_template is unset/empty, behavior remains legacy (ID-based naming).

Why

Many users want readable/stable filenames that include publish date/title while retaining deterministic IDs.

Example

Use this in config.toml:

[feeds.myfeed]
url = "https://www.youtube.com/playlist?list=..."
filename_template = "{{pub_date}}_{{title}}_{{id}}"

Migration

For existing downloaded media, users can migrate once:

./bin/podsync --config config.toml --migrate-filenames

Preview only:

./bin/podsync --config config.toml --migrate-filenames --migrate-filenames-dry-run

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional, token-based filename templating for downloaded media and RSS enclosure paths, plus a CLI mode to migrate already-downloaded files from legacy ID-based names to the configured template.

Changes:

  • Introduces filename_template in feed config and validates allowed tokens during config loading.
  • Updates naming logic (download output + RSS enclosure URLs) to use the templated, sanitized episode filename.
  • Adds --migrate-filenames / --migrate-filenames-dry-run flow and a new migration service with tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/migrate/migrate.go Adds filename migration service to rename legacy files to templated names.
services/migrate/migrate_test.go Tests migration behavior (rename + dry-run).
pkg/ytdl/ytdl.go Uses new episode base/name helpers for youtube-dl output naming.
pkg/feed/xml.go Implements templated filename rendering/sanitization and token validation; refactors extension handling.
pkg/feed/xml_test.go Adds tests for enclosure URL formatting and template validation/name generation.
pkg/feed/config.go Adds FilenameTemplate to feed config struct.
config.toml.example Documents filename_template usage and example output.
cmd/podsync/main.go Adds migration CLI flags and executes migration mode before downloader/updater.
cmd/podsync/config.go Validates filename_template during config validation.
cmd/podsync/config_test.go Extends config parsing tests and adds validation failure test for bad tokens.
README.md Documents the fork feature set and the migration CLI usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants