Search code examples
pythongoogle-colaboratoryyoutube-dl

Is there way to use parameters to run ! commands in Colab?


I was wondering, if there is a way to pass parameters to commands with !, like

source_url = 'https://www.youtube.com/watch?v=lLtaI9-3qfs' #@param {type:"string"}
!youtube-dl source_url -o 'video.mp4'

In this case is throws out a syntax error. Is there even a way to do it?

For those, who are sceptic, this it the right syntax for youtube-dl

!youtube-dl 'https://www.youtube.com/watch?v=lLtaI9-3qfs' -o 'video.mp4'

Solution

  • You can use {} to pass the variables

    !youtube-dl {source_url} -o 'video.mp4'