0

In a directory I have about 80 directories; in each there is a file containing a link to a YouTube playlist which corresponds to the directory name. I simply want to extract the links to the videos that are in each playlist and put them in a file in the corresponding directory.

To extract links from a playlist:

youtube-dl -j --flat-playlist" URL "| jq -r '.id' | sed 's _ ^ _ https: //youtu.be/_'> Lplaylist

The result of this command is assigned to the Lplaylist file.

The URL is contained in a file in each directory. I simply want to replace it with a command that takes the first line of it (I used the command cut but it does not work: youtube-dl -j --flat-playlist <cat playlist | head -n 1| jq -r '.id' | sed 's _ ^ _ https://youtu.be/_'> Lplaylist && sed 's / $ /" /' Lplaylist> temp && sed -e's / ^ / youtube-dl "/ 'temp> file.sh : /)

My goal is:

  • In each directory labeled by playlist name, take the first line of the file named ** playlist ** that has the same name in all the directories, and run the command to extract the links from the playlist videos.

Thank you so much and I hope that I was not very long.

My last attempt was as follows:

youtube-dl -j --flat-playlist < `cat playlist | head -n 1` | jq -r '.id' | sed 's_^_https://youtu.be/_' > Lplaylist && sed 's/$/"/' Lplaylist > temp && sed -e 's/^/youtube-dl "/' temp > file.sh

(Translated with Google translate. The original text is viewable in the revision history)

  • merci j'ai trouve un solition : for d in ./*/ ; do (cd "$d" && youtube-dl -j --flat-playlist head -1 playlist | jq -r '.id' | sed 's_^_youtube-dl "youtu.be/_' > file && sed 's/$/"/' file > file.sh && rm file); done – user946855 Apr 20 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.