You are not logged in.

#1 2022-11-06 11:01:36

linuxscoop
Member
Registered: 2022-08-09
Posts: 26

Download playlist with youtube-dl

Download playlist with youtube-dl. Saving all data including the archive file into the uploader's folder for each video

This can't be done just with arguments as it says here: Set download-archive path with args

I want to make two similar scripts. One that downloads the videos and archive file in the uploader's folder for each video. And another script that also downloads the metadata.

The only way I can think of getting the uploader is to download the metadata with the output %(uploader)s.

Then create a folder with the uploader name, remove the file, and download again the files with the correct name from the created folder.

I have a few functions defined already that may help with this.

This is what I've tried. Are there any obvious mistakes?

# Video Playlist saving archive file to uploader's folder
ytp() {
  # Download metadata
  local opts=(
    ${opts[@]}
    --skip-download
    --write-info-json
  )
  # Get ten random characters
  local rand=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1 )
  LOG_NAME=$( get_log_name "$(${paste[@]})" )

  $yt_dl ${opts[@]} --output "%(uploader|Anon-%(id)s)s.%(ext)s" "$(${paste[@]})" >> "/tmp/$LOG_NAME" 2>&1

  for f in *.info.json; do
    local name="${f%.*}"
    if [[ $name == Anon* ]]; then
      name="Anon"
    fi
    mkdir -p "$name"
    rm "$f"
    cd "$name" || exit

    # Download media
    ytv

    cd .. || exit
  done
}

Last edited by linuxscoop (2022-11-06 11:07:11)

Offline

Board footer

Powered by FluxBB