From 5c916d69d457101326803eb076a746060e3618cf Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Thu, 21 Nov 2024 13:30:52 +0530 Subject: Moved from github --- .local/bin/web/ytplaylist | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 .local/bin/web/ytplaylist (limited to '.local/bin/web/ytplaylist') diff --git a/.local/bin/web/ytplaylist b/.local/bin/web/ytplaylist new file mode 100755 index 0000000..7bc9026 --- /dev/null +++ b/.local/bin/web/ytplaylist @@ -0,0 +1,34 @@ +#!/bin/sh + +# Useful when creating a directory of videos sequenced as per a youtube +# playlist. +# Run this script from from the root of a directory that contains all the media +# and metadata files. +# The playlist file is expected to be in 'playlist' directory within the root +# with .pl.txt extension. (playlist/PLAYLIST_NAME.pl.txt) +# The new playlist directory will be created in the current directory i.e. the +# root if no other destination is passed as the second argument. + +case "$1" in + '') echo "ytplaylist - build a directory of sequenced videos using a playlist file\n +USAGE:\n\tytplaylist [DESTINATION_DIR] " >&2; exit ;; + playlist/*.pl.txt) ;; + *) + printf "%s" "Unconventional file path, contniue? [y/N] " + read -r ans + case "$ans" in y) ;; *) exit 1 ;; esac + ;; +esac + +playlist="$(readlink -f $1)" +i=1 +fpl "$playlist" | while read -r file; do + if [ -z "$file" ]; then + i=$(( $i + 1 )) + continue + fi + dir="$(dirname "$file")" + base="$(basename "$file")" + rsync -Pru --mkpath "$file" \ + "${2:-$(basename "${playlist%.pl.txt}")}/${dir#$(readlink -f "$PWD")}/$(printf "%02d" "$i") $base" +done -- cgit v1.2.3