How to use --replace-in-metadata in Python as an options?


i’ve been searching to this article :youtube-dl/ at master · ytdl-org/youtube-dl · GitHub but no one explained well how to implement --replace-in-metadata in python codes.

Actually my issue is to rename whenever file have title contains “[ brackets ]” such as “Abcd [test].mp4”

i have a code like :

`ydl_opts = {`

`"noplaylist": True,`

`"outtmpl": "./file/folder/downloads" + "/%(title)s.%(ext)s",`

`"restrictfilenames": False,`


If i try it in Command Line using : youtube-dl --replace-in-metadata “title” “[\[\]]” “” “url_link” it’s works.

but how to use --replace-in-metadata with “title” “[\[\]]” “” in youtube-dl options?

i’ve been try using “replaceinmetadata” : “title” “[\[\]]” “”, is not working at all.


Exactly where is this “code”? Is it actually code? Did you try to write a Python program to call youtube-dl? Or is this just a configuration file that youtube-dl will use when you run it from the command line?

If you have your own program (in a file with a .py filename extension, that you run by using the python command on the command line), then there is a programming question; to help, we need to see an actual runnable program, not just “I have something like this” and then a single variable assignment. It sounds like you are trying to use the API in your own code. One option you have is to use '-' for the output template, which tells youtube-dl to put all the video contents on the standard output, and then use your own Python code to redirect the standard output to whichever file (and use your own custom logic to decide the file name).

If it is supposed to be a config file, then there is not a question here about Python, or about writing code; it is a question about how to use the youtube-dl program. It would be better answered by a youtube-dl support forum. What you describe sounds like it will be easier by using a proper config file as described in the documentation you linked, in this section. Otherwise, consider the issue tracker. They may be able to help either way, actually.