Youtube-dl dans un script bash ne retourne une erreur
Bonjour, j'espère être au bon endroit.
Je dev un petit script bash dont le but c'est d'utiliser youtube-dl:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #!/bin/bash
for db in ./urls/*.txt
do
echo fichier $db
echo ""
titre=$(cat $db | jq '.titre')
url=$(cat $db | jq .url)
echo "titre:"
echo $titre
echo "url:"
echo $url
youtube-dl -4 -x --audio-format mp3 $url
done |
Bon, c'est basique pour le moment, le but c'est que quand j'appelle le script qu'il boucle sur chaque fichier qui contient un json de se genre:
Code:
{"auteur":"Moi","titre":"(71) Guns N' Roses - Sweet Child O' Mine - YouTube","url":"https:\/\/www.youtube.com\/watch?v=1w7OgIMMRc4"}
On peut voir avec les echo qu'il affiche:
Code:
1 2 3 4
| titre:
"(71) Guns N' Roses - Sweet Child O' Mine - YouTube"
url:
"https://www.youtube.com/watch?v=1w7OgIMMRc4" |
Pourtant quand je le lance avec la commande youtube-dl j'ai le droit a:
Code:
1 2 3 4 5 6
| WARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.
WARNING: The url doesn't specify the protocol, trying with http
[generic] watch?v=1w7OgIMMRc4": Requesting header
WARNING: Could not send HEAD request to http://"https://www.youtube.com/watch?v=1w7OgIMMRc4": <urlopen error [Errno -2] Name or service not known>
[generic] watch?v=1w7OgIMMRc4": Downloading webpage
ERROR: Unable to download webpage: <urlopen error [Errno -2] Name or service not known> (caused by URLError(gaierror(-2, 'Name or service not known'),)) |
On peut voir qu'il rajoute un http:// avant l'url qui est dans des guillemets. Ce qui est étrange c'est que quand je mets la commande a la main cela fonctionne. Quelqu'un sait il pourquoi pour résoudre mon problème ?