Skip to content

File names contain array formatting when downloading songs with multiple artists #268

@mattiasghodsian

Description

@mattiasghodsian

When downloading songs using yt-dlp, artist names are being saved with array formatting characters in the filename (tried different templates but still same result).

  • Example: ['Artist'] - Song Name.flac
  • Example: ['Artist', 'Artist2'] - Song Name.flac

Expected Behavior

Files should be saved with clean artist names, without array formatting:

  • Example: Artist - Song Name.flac
  • Example: Artist & Artist2 - Song Name.flac

Code

$collection = $this->youtubeDl->download(
            Options::create()
                ->downloadPath($downloadPath)
                ->extractAudio(true)
                ->audioFormat($format)
                ->audioQuality('0')
                ->output('%(artists)s - %(title)s.%(ext)s')
                // ->output('%(artist//&)s - %(title)s.%(ext)s')
                // ->output('%(artist).1s - %(title)s.%(ext)s')
                // ->output('%(title)s.%(ext)s')
                ->url($url)
        );

        foreach ($collection->getVideos() as $video) {
            if ($video->getError() !== null) {
                $result['error'] = $video->getError();
            } else {
                $result = [
                    'file'      => $video->getFile(),
                    'title'     => $video->getTitle(),
                    'directory' => $path,
                ];
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions