Use ffmpeg for tag script (#1193)
eyeD3 got orphaned in the AUR, so I looked for an alternative. Apparently ffmpeg also supports the ability to tag audio files, so this pull request replaces all the helper applications with ffmpeg
This commit is contained in:
parent
41b729acd3
commit
21e08299b1
1 changed files with 17 additions and 39 deletions
|
@ -13,7 +13,7 @@ Options:
|
||||||
-c: comment
|
-c: comment
|
||||||
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
|
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
|
||||||
|
|
||||||
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
|
while getopts "a:t:A:n:N:d:g:c:" o; do case "${o}" in
|
||||||
a) artist="${OPTARG}" ;;
|
a) artist="${OPTARG}" ;;
|
||||||
t) title="${OPTARG}" ;;
|
t) title="${OPTARG}" ;;
|
||||||
A) album="${OPTARG}" ;;
|
A) album="${OPTARG}" ;;
|
||||||
|
@ -22,7 +22,6 @@ while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
|
||||||
d) date="${OPTARG}" ;;
|
d) date="${OPTARG}" ;;
|
||||||
g) genre="${OPTARG}" ;;
|
g) genre="${OPTARG}" ;;
|
||||||
c) comment="${OPTARG}" ;;
|
c) comment="${OPTARG}" ;;
|
||||||
f) file="${OPTARG}" ;;
|
|
||||||
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
|
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
|
||||||
esac done
|
esac done
|
||||||
|
|
||||||
|
@ -30,42 +29,21 @@ shift $((OPTIND - 1))
|
||||||
|
|
||||||
file="$1"
|
file="$1"
|
||||||
|
|
||||||
[ ! -f "$file" ] && echo "Provide file to tag." && err
|
temp="$(mktemp -p "$(dirname "$file")")"
|
||||||
|
trap 'rm -f $temp' HUP INT QUIT TERM PWR EXIT
|
||||||
|
|
||||||
[ -z "$title" ] && echo "Enter a title." && read -r title
|
[ ! -f "$file" ] && echo 'Provide file to tag.' && err
|
||||||
[ -z "$artist" ] && echo "Enter an artist." && read -r artist
|
|
||||||
[ -z "$album" ] && echo "Enter an album." && read -r album
|
|
||||||
[ -z "$track" ] && echo "Enter a track number." && read -r track
|
|
||||||
|
|
||||||
case "$file" in
|
[ -z "$title" ] && echo 'Enter a title.' && read -r title
|
||||||
*.ogg) echo "Title=$title
|
[ -z "$artist" ] && echo 'Enter an artist.' && read -r artist
|
||||||
Artist=$artist
|
[ -z "$album" ] && echo 'Enter an album.' && read -r album
|
||||||
Album=$album
|
[ -z "$track" ] && echo 'Enter a track number.' && read -r track
|
||||||
Track=$track
|
|
||||||
Total=$total
|
cp -f "$file" "$temp" && ffmpeg -i "$temp" -map 0 -y -codec copy \
|
||||||
Date=$date
|
-metadata title="$title" \
|
||||||
Genre=$genre
|
-metadata album="$album" \
|
||||||
Comment=$comment" | vorbiscomment -w "$file" ;;
|
-metadata artist="$artist" \
|
||||||
*.opus) echo "Title=$title
|
-metadata track="${track}${total:+/"$total"}" \
|
||||||
Artist=$artist
|
${date:+-metadata date="$date"} \
|
||||||
Album=$album
|
${genre:+-metadata genre="$genre"} \
|
||||||
Track=$track
|
${comment:+-metadata comment="$comment"} "$file"
|
||||||
Total=$total
|
|
||||||
Date=$date
|
|
||||||
Genre=$genre
|
|
||||||
Comment=$comment" | opustags -i -S "$file" ;;
|
|
||||||
*.mp3) eyeD3 -Q --remove-all -a "$artist" -t "$title" -A "$album" -n "$track" \
|
|
||||||
${total:+-N "$total"} \
|
|
||||||
${date:+-Y "$date"} \
|
|
||||||
${genre:+-G "$genre"} \
|
|
||||||
${comment:+-c "$comment"} "$file" ;;
|
|
||||||
*.flac) echo "TITLE=$title
|
|
||||||
ARTIST=$artist
|
|
||||||
ALBUM=$album
|
|
||||||
TRACKNUMBER=$track
|
|
||||||
TOTALTRACKS=$total
|
|
||||||
DATE=$date
|
|
||||||
GENRE=$genre
|
|
||||||
DESCRIPTION=$comment" | metaflac --remove-all-tags --import-tags-from=- "$file" ;;
|
|
||||||
*) echo "File type not implemented yet." ;;
|
|
||||||
esac
|
|
||||||
|
|
Loading…
Reference in a new issue