#!/bin/sh # Copyright (c) 2023 Emmma Tebibyte # SPDX-License-Identifier: AGPL-3.0-or-later # Cramo is free software: you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # Cramo is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see https://www.gnu.org/licenses/. argv0="$0" logfile="log" case "$1" in "-c" ) while true; do shift case "$1" in "*.opus" ) for i in *.opus; do ffmpeg -v 40 -i "$i" -c:a mp3 "${i%.*}.mp3" >> $logfile 2>&1 done ;; "*.wav" ) for i in *.wav; do ffmpeg -v 40 -i "$i" -c:a flac "${i%.*}.flac" >> $logfile 2>&1 done ;; false ) break ;; esac done exit 0 ;; "sc" ) if test -z "$2"; then while true; do shift case "$1" in "*" ) scdl --original-name --debug -l $1 >> $logfile 2>&1 ;; false ) exit 0 ;; esac done else printf "Usage: %s [-c] [sc/yt]\n" "$argv0" 1>&2 exit 64 # sysexits(3) EX_USAGE fi exit 0 ;; "yt" ) yt-dlp -vx --split-chapters -o \ "chapter:%(fulltitle)s - %(section_number)s %(section_title)s.%(ext)s" \ $1 --audio-quality 0 >> $logfile 2>&1 exit 0 ;; false ) printf "Usage: %s [-c] [sc/yt]\n" "$argv0" 1>&2 exit 64 # sysexits(3) EX_USAGE ;; esac