1

In Youtube-dl, i need path for download one playlist with one folder for one different video! and every video need to start name with his number (1 for first and his name; 8 for eighth and his name... )

1
#!/bin/bash
echo "Downloading playlist...(results.log)"
youtube-dl -j --flat-playlist "$1" | jq -r '.id' | sed 's_^_https://youtu.be/_' > results.log
num=1
total="$(wc -l < results.log)"
echo "Total videos: $total"
while [ "$num" -le "$total" ]; do
   echo "Processing video #$num Thank you for Patience"
   url="$(sed -n "$num"p results.log)"
   title=$(youtube-dl -f mp4 -o '%(id)s.%(ext)s' --print-json --no-warnings "$url" | jq -r .title)
   echo "Title is $title"
   title="$num. $title"
   fly='"'
   title=$fly"$title"$fly
   echo "New title is $title"
   echo "URL is $url"
   sleep 5
   file_name="$(youtube-dl --get-filename --simulate $url)"
   ext="${file_name##*.}"
   echo "ext is $ext"
   youtube-dl -f best --output  $num.$ext $url
   sleep 5
   mkdir "$title"
   mv $num.$ext ./"$title"
   echo "please wait"
   sleep 1 
   num=$(( num+1 ))
done
#some Housekeeping !!
for i in *; do  mv "$i" "`echo $i | sed 's/"/ /'`" 2>/dev/null; done
for i in *; do  mv "$i" "`echo $i | sed 's/"/ /'`" 2>/dev/null; done
for i in *; do  mv "$i" "`echo $i | sed 's/  / /'`" 2>/dev/null; done
  • Pass your playlist as a argument to this, preferably in quotes)". – puneet Mar 7 at 20:21
0
#!/bin/bash
#Download playlist
youtube-dl -j --flat-playlist "https://<yourYoutubePlaylist>" | jq -r '.id' | sed 's_^_https://youtu.be/_' > result.log
#set video count=1    
num=1
total="$(wc -l result.log)"
while ( $num -le $total)
do
url="$(sed -n "$num"p result.log)"
#%(title)s should give video title
youtube-dl -f 18 --output  $num_"%(title)s.%(ext)s" $url

References:- 1.radiolondra: https://superuser.com/questions/1341684/youtube-dl-how-download-only-the-playlist-not-the-files-therein 2.maythux: How to specify a filename while extracting audio using youtube-dl?

  • 5
    Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work? – iBooot Mar 7 at 11:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.