2025.04.30-20:50

This commit is contained in:
2025-04-30 20:47:57 +02:00
commit 8065685ccb
153 changed files with 6149 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#!/bin/bash
#
# bash script to create playlist files in music subdirectories
#
find . -type d |
while read subdir
do
if [[ -f ./"$subdir"/"${subdir##*/}.m3u" ]]
then
echo "File "$subdir"/*.m3u already exists, skipping"
else
echo would build for $subdir
for filename in "$subdir"/*
do
if [ ${filename: -4} == ".mp3" ] || [ ${filename: -5} == ".flac" ] || [ ${filename: -5} == ".loss" ] || [ ${filename: -5} == ".aiff" ] || [ ${filename: -4} == ".aif" ]
then
echo "${filename##*/}" >> ./"$subdir"/"${subdir##*/}.m3u"
fi
done
fi
done

View File

@ -0,0 +1,91 @@
#!/usr/bin/env bash
#
# --------------------------------------------------------------------------------------------------
#
# Create m3u8 playlists
#
# Created by @hasecilu
# Based on gists: "Eddy-Barraud/playlist-all.sh" and "scarlson/playlist.sh"
#
# --------------------------------------------------------------------------------------------------
v=1 # verbosity, 0/1
function playlists() {
# First argument is the mode (recursive, single)
# Second argument is the path of the directory
cd "$2" || exit
[ "$v" -eq 1 ] && echo "${PWD##*/}" | figlet -f small | lolcat
# Delete old m3u and m3u8 playlists
find . -type f -name "*.m3u*" -delete # If "-delete" didn't work use: "-exec rm {} \;"
# Create new playlists
find ~+ -type d | sort |
while read -r subdir; do
for filename in "$subdir"/*; do
if [[ $filename =~ \.(acc|aif|aiff|flac|m4a|mp3|ogg|wav|wma)$ ]]; then
if [ "$1" == "-r" ]; then
echo "${filename##*/}" >>"$subdir/${subdir##*/}.m3u8"
[ "$v" -eq 1 ] && echo -e "${subdir##*/}.m3u8\t\t${filename##*/}" | lolcat
elif [ "$1" == "-s" ]; then
relative_path=${subdir#"$PWD"} # Remove common path
relative_path=${relative_path:1} # Remove leading '/' character
[ "$PWD" == "$subdir" ] && slash="" || slash="/"
echo "$relative_path$slash${filename##*/}" >>"$PWD/${PWD##*/}.m3u8"
[ "$v" -eq 1 ] && echo -e "${PWD##*/}.m3u8\t\t$relative_path$slash${filename##*/}" | lolcat
elif [ "$1" == "-cd" ]; then
album=$(dirname "$subdir")
# Join album and CD directory
album_cd=$(basename "$album")/$(basename "$subdir")
album_cd=${album_cd//\// } # Replace '/' for space ' '
echo "${filename##*/}" >>"$subdir/$album_cd.m3u8"
[ "$v" -eq 1 ] && echo -e "$album_cd.m3u8\t\t${filename##*/}" | lolcat
fi
fi
done
done
}
function default() {
# Create one playlist for every directory that has at least one audio file
playlists -r $HOME/Music
# For specific directories that have several nested directories
# create a single playlist that includes all subdirectories
playlists -s $HOME/Music/VeryObscureGenre
# For directory-albums that contains various CDs subdirectories
# create one playlist for every CD preserving the album name
playlists -cd $HOME/Music/Album
}
function help() {
echo -e "\nDescription :"
echo -e "\tThis script creates music playlist(s) for a given directory."
echo -e "\nArguments :"
echo -e "\t-r recursively create playlists"
echo -e "\t-s create a single playlist"
echo -e "\t-cd recursively create playlists of a album directory that contains CDs as subdirectories"
echo -e "\t-h show help"
}
# --------------------------------------------------------------------------------------------------
# Main code
if [ $# -eq 0 ]; then
default
elif [ $# -eq 2 ]; then
if [[ "$1" == "-r" ]]; then
playlists -r "$2"
elif [[ "$1" == "-s" ]]; then
playlists -s "$2"
elif [[ "$1" == "-cd" ]]; then
playlists -cd "$2"
else
help
fi
else
help
fi

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# bash script to create playlist files in music subdirectories
#
# Steve Carlson (stevengcarlson@gmail.com)
find . -type d |
while read subdir
do
rm -f "$subdir"/*.m3u
for filename in "$subdir"/*
do
if [ ${filename: -4} == ".mp3" ] || [ ${filename: -5} == ".flac" ] || [ ${filename: -5} == ".loss" ] || [ ${filename: -5} == ".aiff" ] || [ ${filename: -4} == ".aif" ]
then
echo "${filename##*/}" >> ./"$subdir"/"${subdir##*/}.m3u"
fi
done
done

View File

@ -0,0 +1,12 @@
#!/bin/bash
touch ${PWD##*/}.m3u
export IFS=$'\n'
for i in $(find $1 -name "*.mp3" -type f)
do
echo "$i" |sed 's/..\(.*\)/\1/' >> ${PWD##*/}.m3u
done
shuf ${PWD##*/}.m3u > ${PWD##*/}2.m3u
shuf ${PWD##*/}2.m3u > ${PWD##*/}.m3u
rm ${PWD##*/}2.m3u
exit 0

View File

@ -0,0 +1,3 @@
#!/bin/bash
ls -d * | grep .mp3 > "${PWD##*/}.m3u"
exit 0