Browse Source

mod

master
dmz 1 week ago
parent
commit
ae40b95760
6 changed files with 10 additions and 214 deletions
  1. 6
    0
      test-02/category.txt
  2. 0
    11
      test-02/make-playlist.sh
  3. 0
    71
      test-02/oggcheck.sh
  4. 0
    115
      test-02/oggfix.sh
  5. 0
    3
      test-02/tag-edit.sh
  6. 4
    14
      test-02/tag.txt

+ 6
- 0
test-02/category.txt View File

@@ -0,0 +1,6 @@
general
business
service
work
system
media

+ 0
- 11
test-02/make-playlist.sh View File

@@ -1,11 +0,0 @@
#!/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

+ 0
- 71
test-02/oggcheck.sh View File

@@ -1,71 +0,0 @@
#!/bin/bash
# This script is designed to use oggz-tools to detect corrupt/invalid OGG files.
# https://trackitweb.com/fix-ogg-files-corrupted-by-easytag

# Check to make sure oggz-tools is installed.
command -v oggz-validate >/dev/null 2>&1 || { echo >&2 "The package oggz-tools is required, but it is not installed. Aborting."; exit 1; }

# Get the path to the current directory.
path=`pwd`/;

# Create your output function to send the output to the terminal or to a file on the Desktop called oggfix_log.txt.
output () {
if [ "$tofile" == 'y' ]; then
echo "$1" >> ~/Desktop/oggcheck.log
else
echo "$1"
fi
}

echo "Do you want to send the results to a file on your Desktop? (y or n, default=n)"
read tofile
if [ -z "$tofile" ]; then
tofile='n'
fi
output "The following songs return errors when tested with oggz-validate:"

# Loop through the artists.
for artist in *;
do
# Set a flag used to determine if you need to output an artist and album or not.
outputartist=false
outputalbum=false

if [[ -d "$artist" ]]; then
# List the artist name.
#output "$artist"
for album in $path"$artist"/*/; do
#output "$album"
# Check to make sure there are OGGs in the album.
#output "$album"
count=`ls -1 "$album"*.ogg 2>/dev/null | wc -l`
if [ $count != 0 ]; then
if [[ -d "$album" ]]; then
# Go through the OGG files.
for fname in "$album"*.ogg; do
# Check each OGG file, and only include them in output if they are invalid. You suppressed the output of the oggz-validate command and set it to a variable "validate" to check.
validate="$((oggz-validate "$fname") 2>&1)"
# Only output the song if it is invalid.
if [ -n "$validate" ]; then
# Only output the artist and album if they haven't been output yet.
if [ "$outputartist" = false ]; then
output "$artist"
outputartist=true
fi
if [ "$outputalbum" = false ]; then
# List the album name.
string=' '$(basename "$album")
output "$string"
outputalbum=true
fi
string=' '$(basename "$fname")
output "$string"
fi
done
fi
fi
outputalbum=false
done
fi
done
echo "Done."

+ 0
- 115
test-02/oggfix.sh View File

@@ -1,115 +0,0 @@
#!/bin/bash
# This script is designed to use oggz-tools to detect corrupt/invalid OGG files and to fix them by saving the tags--if any--decoding, then re-encoding the file, and writing the tags back to the file.
# https://trackitweb.com/fix-ogg-files-corrupted-by-easytag

# Make sure they know what they're doing.
echo "Make sure you have a backup! This script will delete the original files after re-encoding them. Are you sure you want to continue? (y or n, default=n)"
read doit
if [ -z "$doit" ]; then
doit='n'
fi
if [ "$doit" != 'y' ]; then
echo "Aborting script...no files altered."
exit 1
fi

# Get the path to the current directory.
path=`pwd`/;

# Create your output function to send the output to the terminal or to a file on the Desktop called oggfix_log.txt.
output () {
printf "%s\n" "$1"
}

# Check to make sure the required packages are installed.
output "Checking for required packages..."
command -v oggz-validate >/dev/null 2>&1 || { echo >&2 "The package oggz-tools is required, but it is not installed. Aborting."; exit 1; }
command -v oggdec >/dev/null 2>&1 || { echo >&2 "The package vorbis-tools or a package containing oggdec is required, but is not installed. Aborting."; exit 1; }
command -v oggenc >/dev/null 2>&1 || { echo >&2 "The package vorbis-tools or a package containing oggenc is required, but is not installed. Aborting."; exit 1; }
command -v vorbiscomment >/dev/null 2>&1 || { echo >&2 "The package vorbis-tools or a package containing vorbiscomment is required, but is not installed. Aborting."; exit 1; }
output "All required packages found, beginning search for invalid OGG files..."

# Loop through the artists.
for artist in *;
do
# Set a flag used to determine if you need to output an artist and album or not.
outputartist=false
outputalbum=false

if [[ -d "$artist" ]]; then
# List the artist name.
#output "$artist"
for album in $path"$artist"/*/; do
#output "$album"
# Check to make sure there are OGGs in the album.
#output "$album"
count=`ls -1 "$album"*.ogg 2>/dev/null | wc -l`
if [ $count != 0 ]; then
if [[ -d "$album" ]]; then
# Go through the OGG files.
for fname in "$album"*.ogg; do
# Check each OGG file, and only include them in output if they are invalid. You suppressed the output of the oggz-validate command and set it to a variable "validate" to check.
validate="$((oggz-validate "$fname") 2>&1)"
# Only output the song if it is invalid.
if [ -n "$validate" ]; then
# Only output the artist and album if they haven't been output yet.
if [ "$outputartist" = false ]; then
output "=============================="
output "$artist"
output "=============================="
outputartist=true
fi
if [ "$outputalbum" = false ]; then
# List the album name.
string=$(basename "$album")
output "---------------------------------------"
output "$string"
output "---------------------------------------"
outputalbum=true
fi
# Get the song name for use in output.
oggname=$(basename "$fname")
# First, save the tags from the original file:
output "Saving metadata from: $oggname..."
vorbiscomment -l "$fname" >> "$album"tags
# Try to get the bitrate of the original file. Note that this depends on ogginfo not changing the way it outputs the "Nominal bitrate". If it fails, that might be the cause.
info=$((ogginfo "$fname") 2>&1)
# Get the next-to-last field on the line with "Nominal bitrate" on it, which should give you the number without the units.
bitrate=$(echo "$info" | awk '/^Nominal bitrate/{print $(NF - 1)}')
# Round off the bitrate to a whole number.
bitrate=$(printf '%.0f\n' $bitrate)
# Next, decode the original ogg file, creating a wav file, and in the process, losing all the tags.
oggdec "$fname"
# Save the name of the wav to a new variable.
wav="${fname%.*}.wav"
wavname=$(basename "$wav")
# Delete the original ogg file.
output "Deleting $oggname..."
rm "$fname"
# Now, re-encode the wav file as an ogg, using the bitrate of the original file, if you got one.
# Set a regular expression to check for integer values.
re='^[0-9]+$'
if ! [[ $bitrate =~ $re ]]; then
# In this case, bitrate is not an integer, so set a default.
bitrate=160
fi
oggenc -b $bitrate "$wav"
# Delete the wav file.
output "Deleting $wavname..."
rm "$wav"
# Next, write the tags back to the new ogg file.
vorbiscomment -w -c "$album"tags "$fname"
# Delete the tags file.
output "Deleting the tags file..."
rm "$album"tags
output "Done processing $oggname."
fi
done
output "---------------------------------------"
fi
fi
outputalbum=false
done
fi
done
echo "Done."

+ 0
- 3
test-02/tag-edit.sh View File

@@ -1,3 +0,0 @@
#!/bin/bash

for nam in *.ogg ; do vorbiscomment -l "$nam" -c "$nam".txt ; vim "$nam".txt ; vorbiscomment -w "$nam" -c "$nam".txt ; rm "$nam".txt ; done

+ 4
- 14
test-02/tag.txt View File

@@ -1,34 +1,24 @@
[!] [?] [*] [+] [-]
[-] [+] [*] [?] [!]
-
[!] important
[!] priority
[?] option
[*] favorite
[+] add
[-] remove
[!] important
[!] priority
[?] option
[*] favorite
[+] add
[-] remove
[!] important
[?] option
[*] favorite
[+] add
[-] remove
-
[!] important
[!] priority
[?] option
[*] favorite
[+] add
[-] remove
[!] important
[!] priority
[?] option
[*] favorite
[+] add
[-] remove
[!] important
[?] option
[*] favorite
[+] add
[-] remove

Loading…
Cancel
Save