Skip to content

Transcoder shell script

markbaaijens edited this page Dec 18, 2020 · 3 revisions

Todo:

  • variable $music_folder
  • execute subsequent commands such as chmod after transcoding only when transcoding has taking place
    • by scanning log-file, search for 'transcoded to mp3: 0' or 'transcoded to ogg: 0'
  • execute dr14tool; always, also when no transcoding has been done

#!/bin/bash

#
# Check progress:
# tail -f /var/log/transcoder/mtranscoder.log
# /etc/crontab:
# 20 * * * * root transcode # Transcode every hour
# 52 6 1 * * root rm /var/log/transcoder/mtranscoder.log # Remove log every month
#

# Exit whenever any process (such as transcoder) fails
set -e

# Must be run as root
if [ -z "$(whoami | grep root)" ]
then
  echo "Not running as root. Exiting"
  exit 1
fi

# Installing (auto-update) and executing transcoder; logging to /var/log/transcoder
mkdir -p /var/log/transcoder # No error if exists
wget https://raw.githubusercontent.com/markbaaijens/transcoder/master/transcoder.py -O /usr/local/bin/transcoder.py -q
python3 /usr/local/bin/transcoder.py /media/usbdata/data/Muziek/flac --mp3folder /media/usbdata/data/Muziek/mp3/transcoded/ --oggfolder /media/usbdata/data/Muziek/ogg --logfolder /var/log/transcoder

# Files created by transcoder may *not* have the correct rights for proper file handling by samba
chmod 777 /media/usbdata/data/Muziek/mp3/* -R -f
chmod 777 /media/usbdata/data/Muziek/ogg/* -R -f

Clone this wiki locally