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
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)