TVtunes pre-2.0.0 batch download program
#1
Well, if you're using linux, then your in luck. I wrote a bash script that will go into every sub-directory in a given path/location. It takes the first episode, extracts the first 30 seconds of audio from it and saves it as a theme.mp3 file in that folder, and repeats this for every subfolder.

It won't overwrite an existing theme.mp3 you've manually downloaded.

Usage: 1) copy and paste code into a file named 'xbmc-theme-mp3-creator', 2) mark that file as executable 'chmod +x', 3) run the file with the path to your TV folder: xbmc-theme-mp3-creator "/media/USB-Drive/Television"

So if you have episodes from 500 different TV shows, this will only take a minute to get the theme.mp3 files for all those shows, instead of spending hours downloading them manually.

# known issue #1: doesn't work with episodes that have a date inside of brackets '[2012-01-01]', yet it does work with bracketed anime absolute numbering '[09]'... the string editor is doing something weird there...

# known issue #2: only grabs 30 seconds, doesn't validate it is the theme. Someday I might improve upon this (or someone else go ahead). It could take an audio sample from multiple episodes, look for a match. A match would verify it is the theme and not some random opening skit.

# known issue #3: sometimes it cuts abruptly, as not all tunes end after 30 seconds. someone should add the ability to fade out the last few seconds in the theme.mp3 file it creates. My ability to google that for you, feels broken right now. :p

Code:
#!/bin/bash
#
# FILENAME: xbmc-theme-mp3-creator
# XBMC Theme MP3 Creator v0.44
# Author: Kissell
#
# Purpose: Create theme.mp3 in every video folder.
#

LOCATION="/path/to/television"

VIDEO_EXTENSIONS="avi mkv mp4 divx"

if [ ! -s "/usr/bin/ffmpeg" ]; then
  sudo apt-get -y install ffmpeg
fi

if [ "$1" ]; then
  LOCATION="$1"
fi

if [ -d "$LOCATION" ]; then
  FOLDERS=`ls "$LOCATION"|sed 's: :#:g'`
  for NEXT_FOLDER in ${FOLDERS[@]}; do  
    FOLDER_LOCATION="$LOCATION"/"$NEXT_FOLDER"
    FOLDER_LOCATION=$(echo "$FOLDER_LOCATION"|sed 's:#: :g')
    for EXT in ${VIDEO_EXTENSIONS[@]}; do
      SOURCE_FILE=`find "$FOLDER_LOCATION" -type f|sort|grep -m1 ".$EXT"`
      if [ "$SOURCE_FILE" ]; then
        FILE_NAME=${SOURCE_FILE##*/}
        FOLDER=$(echo "$SOURCE_FILE"|sed -e s:"$FILE_NAME"::g)
        NEXT_FOLDER=$(echo "$NEXT_FOLDER"|sed 's:#: :g')
        if [ ! -s "$FOLDER_LOCATION"/"theme.mp3" ]; then
          echo "Theme generated for $NEXT_FOLDER."
          /usr/bin/ffmpeg -ss 0 -t 45 -i "$SOURCE_FILE" -f mp3 "$FOLDER_LOCATION"/"theme.mp3" > /dev/null 2>&1
        fi
        /usr/bin/find "$LOCATION" -empty -type f -delete
      fi
    done
  done
else
  echo "Directory does not exist: $LOCATION"
fi
Reply

Logout Mark Read Team Forum Stats Members Help
TVtunes pre-2.0.0 batch download program0