norkunas / youtube-dl-php

A PHP wrapper for youtube-dl or yt-dlp.
MIT License
459 stars 158 forks source link

metadataFromTitle not working? #252

Open mostafa-norouzi opened 2 weeks ago

mostafa-norouzi commented 2 weeks ago

Hi,

Anyone tested metadataFromTitle switch? I'm using below pattern :

->metadataFromTitle('%(artist)s - %(title)s')

but output mp3 has no metadata! https://github.com/ytdl-org/youtube-dl/blob/master/README.md#post-processing-options

Also :

->postProcessorArgs("-metadata title={$title} ") is working but I want to fill title automatically from video.

norkunas commented 2 weeks ago

Hey. Which yt library you are using, yt-dl or yt-dlp? Looking at the yt-dlp parse-metadata should be used which is not implemented here, but PR's are welcome. Could you check if that option works for you in terminal?

mostafa-norouzi commented 2 weeks ago

I mentioned the URL, It's youtube-dl. Also I checked the code and metadataFromTitle implemented in PHP. you are right, I should check it in terminal first.

norkunas commented 2 weeks ago

youtube-dl has no releases since 2021, so I'd suggest to switch to yt-dlp

mostafa-norouzi commented 2 weeks ago

I used below command:

youtube-dl -x -R 3 -r 500K --audio-quality 128K --metadata-from-title "%(artist)s - %(title)s" --user-agent "Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0" --audio-format mp3 -o "%(id)s - %(title)s.%(ext)s" https://www.youtube.com/watch?v=b8I-7Wk_Vbc

And metadata is empty! So it's not related to the wrapper

norkunas commented 2 weeks ago

Where do you check if it's empty? I haven't used this option never

mostafa-norouzi commented 2 weeks ago

Simply in Winamp (windows). It shows complete metadata (with hotkey alt+3) like title, artist, cover and .... This option of youtube-dl can save user time (no need adding data manually). These days most of software check and shows meta-info like Telegram, Media player, cars audio player and ...

Also there is a tiny app that shows and modifies it : https://www.malavida.com/en/soft/creevity-mp3-cover-downloader/

norkunas commented 2 weeks ago

Maybe that option is not for the ID3v1/ID3v2 ? Will check this someday,but no promises

mostafa-norouzi commented 1 week ago

Finally I found the reason! The right pattern has two % sign and should be like this :

->metadataFromTitle('%%(artist)s - %%(title)s')

norkunas commented 6 days ago

Cool! Maybe you could add a section in readme file about this for others :)