guanguans / music-dl

Music Searcher and Downloader. - 音乐搜索下载器。
https://guanguans.github.io/music-dl
MIT License
677 stars 65 forks source link

Ability to include music metadata in downloaded file #691

Closed jyyyeung closed 6 months ago

jyyyeung commented 8 months ago

First of all, Thanks a lot for the great program!

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I always have to tag all the downloaded music after downloading, but it is a little uneasy when there are no initial metadata within the downloaded file.

Describe the solution you'd like A clear and concise description of what you want to happen.

It would be great if the downloaded file can include embedded metadata such as title, artist, albumArtist, album, trackNumber, lyrics, album image, etc.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

I have tried to fork this project and include this feature but sadly I am not familiar with PHP, so I don't really understand how to contribute and run this project locally.

Additional context Add any other context or screenshots about the feature request here.

Possibly useful information: https://soundcharts.com/blog/music-metadata

create-issue-branch[bot] commented 8 months ago

Branch issue-691-Ability_to_include_music_metadata_in_downloaded_file created!

guanguans commented 8 months ago

@SheepYY039

I have no time at present to realize this good idea.

These are the local run steps.

  1. Install PHP(>=8.1).
  2. git clone https://github.com/guanguans/music-dl.git && cd music-dl
  3. Just execute the command(...path/php-binary music-dl) in the terminal.

This is the relevant code for the download section.

public function download(string $url, string $savePath): void
{
    $this->createHttpClient()->get($url, [
        'sink' => $savePath,
        'progress' => static function (int $totalDownload, int $downloaded) use (&$progress, $savePath): void {
            if (0 === $totalDownload || 0 === $downloaded || 'submit' === $progress?->state) {
                return;
            }

            if (! $progress instanceof Progress) {
                /** @noinspection PhpVoidFunctionResultUsedInspection */
                $progress = tap(progress($savePath, $totalDownload))->start();
            }

            value(static function (Progress $progress, int $downloaded): void {
                $progress->progress = $downloaded;
                $progress->advance(0);
            }, $progress, $downloaded);

            if ($totalDownload === $downloaded) {
                $progress->finish();
            }
        },
    ]);
}

😃 Looking forward to your code implementation and PR.

GitHub
GitHub - guanguans/music-dl: Music Searcher and Downloader. - 音乐搜索下载器。
Music Searcher and Downloader. - 音乐搜索下载器。. Contribute to guanguans/music-dl development by creating an account on GitHub.
github-actions[bot] commented 6 months ago

Stale issue message