custom filename templates #420

Closed
opened 2025-11-09 09:49:03 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @ascpixi on GitHub (Sep 7, 2024).

describe the feature you'd like to see

A custom filename format feature would be useful for e.g. those that like to have a consistent naming scheme when archiving videos or audio. For example, if cobalt were to support an arbitrary JavaScript snippet, one could specify the following template:

`[${service.toUpperCase()}] ${name} (${id})`

...where the variables are defined as follows:

service = "YouTube"
name = "Rick Astley - Never Gonna Give You Up (Official Music Video)"
id = "dQw4w9WgXcQ"

...cobalt would download the file as [YOUTUBE] Rick Astley - Never Gonna Give You Up (Official Music Video) (dQw4w9WgXcQ).mp4. As audio and video files have different parameters, the user would be able to specify a different template for videos and audio.

As I have not contributed to cobalt, I'm not sure if eval would be a security risk (I don't know if the filename is determined client-side or server-side). If it is, a simple token replacement would also be great, e.g. [$service] $name ($id), where cobalt would simply do:

filenameTemplate
  .replaceAll("$service", serviceName)
  .replaceAll("$name", mediaName)
  .replaceAll("$id", mediaId);
Originally created by @ascpixi on GitHub (Sep 7, 2024). ### describe the feature you'd like to see A custom filename format feature would be useful for e.g. those that like to have a consistent naming scheme when archiving videos or audio. For example, if cobalt were to support an arbitrary JavaScript snippet, one could specify the following template: ```js `[${service.toUpperCase()}] ${name} (${id})` ``` ...where the variables are defined as follows: ```js service = "YouTube" name = "Rick Astley - Never Gonna Give You Up (Official Music Video)" id = "dQw4w9WgXcQ" ``` ...cobalt would download the file as `[YOUTUBE] Rick Astley - Never Gonna Give You Up (Official Music Video) (dQw4w9WgXcQ).mp4`. As audio and video files have different parameters, the user would be able to specify a different template for videos and audio. As I have not contributed to cobalt, I'm not sure if `eval` would be a security risk (I don't know if the filename is determined client-side or server-side). If it is, a simple token replacement would also be great, e.g. `[$service] $name ($id)`, where cobalt would simply do: ```js filenameTemplate .replaceAll("$service", serviceName) .replaceAll("$name", mediaName) .replaceAll("$id", mediaId); ```
GiteaMirror added the feature request label 2025-11-09 09:49:03 -06:00
Author
Owner

@KwiatekMiki commented on GitHub (Sep 7, 2024):

#228

@KwiatekMiki commented on GitHub (Sep 7, 2024): #228
Author
Owner

@ascpixi commented on GitHub (Sep 7, 2024):

#228

Ah, I see, thanks. Closing as a duplicate.

@ascpixi commented on GitHub (Sep 7, 2024): > #228 Ah, I see, thanks. Closing as a duplicate.
Sign in to join this conversation.