3 Fixing audio tags on uploaded shows
Dave Morriss edited this page 2023-12-18 22:34:14 +00:00

The problem

  • We have a number of shows which did not get the audio tags. This was due to a fault on Ken's laptop where fix_tags stopped working after a Fedora update. Looking at how to fix this problem.

  • The shows missing tags are: 3993 - 3999, 4001 - 4006

  • The plan is to:

    • Download all the audio files to a local machine
    • Use fix_tags to add the tags
    • Re-upload the changed files

Downloads

  • The downloads were done like this (in an empty directory):
for e in {3993..3999} {4001..4006}; do echo ia download "hpr$e" hpr$e.{flac,mp3,ogg,opus,spx,wav}; done
  • The files were placed in directories with show names in the following manner:
├── hpr3993
│   ├── hpr3993.flac
│   ├── hpr3993.mp3
│   ├── hpr3993.ogg
│   ├── hpr3993.opus
│   ├── hpr3993.spx
│   └── hpr3993.wav
├── hpr3994
│   ├── hpr3994.flac
│   ├── hpr3994.mp3
│   ├── hpr3994.ogg
│   ├── hpr3994.opus
│   ├── hpr3994.spx
│   └── hpr3994.wav
  • The downloads were slow!

Adding tags

  • The necessary fix_tags commands were built from the MySQL database :
$ query2tt2 -config=../.hpr_livedb.cfg \
    -query=query_fix_tags.sql \
    -template=$HOME/HPR/InternetArchive/repair/query2tt2_fix_tags.tpl > fixes.sh

The script query2tt2 is a Perl script that runs a query from the command line or a file and feeds it to a TT² template which prints it in the desired format. The -config option refers to a file that causes the script to connect to the database on the HPR server which needs an SSH tunnel to be connected first.

  • The SQL query in query_fix_tags.sql was:
SELECT
    e.id,
    h.host as artist,
    e.title,
    concat('https://hackerpublicradio.org ',
        CASE e.explicit
            WHEN 1 THEN 'Explicit'
            ELSE 'Clean'
        END,
        '; ',
        e.summary,
        ' The license is ',
        e.license
    ) as comment
FROM eps e
JOIN hosts h ON (e.hostid = h.hostid)
WHERE e.id in (3993, 3994, 3995, 3996, 3997, 3998, 3999, 4001, 4002, 4003, 4004, 4005, 4006);
  • The TT² template in query2tt2_fix_tags.tpl was:
[% FOREACH row IN result -%]
echo "hpr[% row.id %]"
fix_tags -album="Hacker Public Radio" \
    -track="[% row.id %]" \
    -artist="[% row.artist %]" \
    -comment="[% row.comment %]" \
    -genre="Podcast" \
    -title="[% row.title %]" \
    -year="2023" \
    hpr[% row.id %]/hpr[% row.id %].{flac,mp3,ogg,opus,spx,wav}

[% END -%]
  • An example of the resulting commands written to fixes.sh is:
echo "hpr3993"
fix_tags -album="Hacker Public Radio" \
    -track="3993" \
    -artist="Brian in Ohio" \
    -comment="https://hackerpublicradio.org Clean; review of a kit The license is CC-BY-SA" \
    -genre="Podcast" \
    -title="z80 membership card" \
    -year="2023" \
    hpr3993/hpr3993.{flac,mp3,ogg,opus,spx,wav}

Uploads

  • Created the file Upload.sh containing the Upload Bash function used by make_metadata. This a way of simplifying the interface to ia upload and allowing files to be written to the top-level IA directory or to a child directory and for options to be provided to control whether backups are kept or derivatives are generated:
Upload () {
    local id=${1}
    local file=${2}
    local remote=${3:-}
    local options=${4:-}

    if [[ -e $file ]]; then
        if [[ -z $remote ]]; then
            ia upload ${id} ${file} ${options}
        else
            ia upload ${id} ${file} --remote-name=${remote} ${options}
        fi
    else
        echo "File missing: $file"
    fi
}
  • By simply sourcing this file a test upload could be performed thus:
Upload hpr3993 $HOME/HPR/IA/repair/hpr3993/hpr3993.flac 'hpr3993.flac' \
    '--retries=5 --no-derive -H x-archive-keep-old-version:0'
  • Checked the IA and the file was correctly uploaded.

  • Constructed some Bash loops to do this (written all on one line but laid out better here):

options='--retries=5 --no-derive -H x-archive-keep-old-version:0'
for e in {3994..3999} {4001..4006}; do
    for x in flac mp3 ogg opus spx wav; do
        Upload hpr${e} $HOME/HPR/IA/repair/hpr${e}/hpr${e}.${x} "hpr${e}.${x}" "$options"
    done
done

Inserted echo at the start of the main Upload command to begin with, then copied and pasted the uploads for 3993 by hand to check all was working. Then adjusted the show numbers to start with 3994 and let the loop run.

  • The uploads took less long than the downloads, but the process was not rapid!

  • All done!