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.