1
0

Clean old scripts

This commit is contained in:
ami 2025-01-29 21:49:57 -05:00
parent 526459b399
commit 82e3b84163
No known key found for this signature in database
4 changed files with 0 additions and 191 deletions

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Variables for color print.
GREEN="\e[32m"
CYAN="\e[36m"
END="\e[0m"
# Get filename and extension.
name="${snakemake_input[0]##*/}"
ext="${name##*.}"
printf "%b: %s\r" "${CYAN}[ i ]${END} Encoding file" "${name}"
if [[ "${ext}" != ".flac" ]]
then
ffmpeg \
-i "${snakemake_input[0]}" \
-vn \
-c:a flac \
-hide_banner \
-loglevel error \
"${snakemake_output[0]}"
else
cp "${snakemake_input[0]}" "${snakemake_output[0]}"
fi
printf "%b: %s\r" "${GREEN}[ ✓ ]${END} Finished encoding file" "${name}"

View File

@ -1,47 +0,0 @@
#!/bin/bash
# Variables for color print.
GREEN="\e[32m"
RED="\e[31m"
CYAN="\e[36m"
END="\e[0m"
# Get command line arguments.
while getopts i:o: flag
do
case "${flag}" in
i) input_metadata=${OPTARG};;
o) output_dir=${OPTARG};;
*) printf "%b\n" "${RED}[ ! ]${END} Invalid Argument"
exit 1;;
esac
done
{
# Skip header line of .tsv.
read -r
while IFS=$'\t' read -r code extension track title artist album year disc artwork
do
file_path="${output_dir}/${code}.txt"
printf "%b: %s\r" "${CYAN}[ i ]${END} Processing file" "${code}${extension}"
# Create metadata file.
touch "${file_path}"
# Write metadata to file.
{
printf "%s\t" "${extension}"
printf "%s\t" "${track}"
printf "%s\t" "${title}"
printf "%s\t" "${artist}"
printf "%s\t" "${album}"
printf "%s\t" "${year}"
printf "%s\t" "${disc}"
printf "%s" "${artwork}"
} >> "${file_path}"
printf "%b: %s\n" "${GREEN}[ ✓ ]${END} Generated metadata file for" "${code}${extension}"
done
} < "${input_metadata}"

View File

@ -1,68 +0,0 @@
#!/bin/bash
# Variables for color print.
GREEN="\e[32m"
RED="\e[31m"
CYAN="\e[36m"
END="\e[0m"
# Get command line arguments.
while getopts i:m:a:o: flag
do
case "${flag}" in
i) input_file=${OPTARG};;
m) input_metadata=${OPTARG};;
a) artwork_dir=${OPTARG};;
o) output_file=${OPTARG};;
*) printf "%b\n" "${RED}[ ! ]${END} Invalid Argument"
exit 1;;
esac
done
printf "%b: %s\r" "${CYAN}[ i ]${END} Encoding file" "${input_file}"
# Read file metadata.
IFS=$'\t' read -r extension track title artist album year disc artwork < "${input_metadata}"
if [[ "${extension}" != ".flac" ]]
then
ffmpeg \
-i "${input_file}" \
-vn\
-c:a flac \
-hide_banner \
-loglevel error \
"${output_file}"
else
cp "${input_file}" "${output_file}"
fi
# Remove any exsiting metadata.
metaflac \
--remove-all-tags \
"${output_file}"
# Remove any album artwork.
metaflac \
--remove \
--block-type=PICTURE,PADDING \
--dont-use-padding \
"${output_file}"
metaflac \
--remove-tag=COVERART \
--dont-use-padding \
"${output_file}"
# Write new metadata.
metaflac \
--set-tag=ALBUM="${album}" \
--set-tag=ARTIST="${artist}" \
--set-tag=TITLE="${title}" \
--set-tag=TRACKNUMBER="${track}" \
--set-tag=DATE="${year}" \
--set-tag=DISCNUMBER="${disc}" \
--import-picture-from="${artwork_dir}/${artwork}" \
"${output_file}"
printf "%b: %s\n" "${GREEN}[ ✓ ]${END} Succesfully encoded file" "${input_file}"

View File

@ -1,49 +0,0 @@
#!/bin/bash
# Variables for color print.
GREEN="\e[32m"
RED="\e[31m"
CYAN="\e[36m"
END="\e[0m"
# Get command line arguments.
while getopts r:m:i: flag
do
case "${flag}" in
r) encode_dir=${OPTARG};;
m) metadata_dir=${OPTARG};;
i) install_dir=${OPTARG};;
*) printf "%b\n" "${RED}[ ! ]${END} Invalid Argument"
exit 1;;
esac
done
# Create install directory (if it does not exist).
mkdir -p "${install_dir}"
for file in "${metadata_dir}"/*.txt
do
# Read file metadata.
IFS=$'\t' read -r extension track title artist album year disc artwork < "${file}"
# Get filename without extension.
filename=$(basename "${file}" ".txt")
# Replace any '/' with '-' in the song title.
title="${title//\//-}"
# Add leading zeroes to disc number.
disc_num=$(printf "%02d" "${disc}")
# Add leading zeroes to track number.
track_num=$(printf "%02d" "${track}")
# Create album directory (if it does not exist).
mkdir -p "${install_dir}/${album}"
# Copy file to installation directory and rename.
cp "${encode_dir}/${filename}.flac" \
"${install_dir}/${album}/${disc_num}-${track_num} - ${title}.flac"
printf "%b: %s\n" "${GREEN}[ ✓ ]${END} Succesfully installed file" "${filename}"
done