diff --git a/mediatomb/config.xml b/mediatomb/config.xml new file mode 100644 index 0000000..2eaf185 --- /dev/null +++ b/mediatomb/config.xml @@ -0,0 +1,117 @@ + + + + + + + + + MediaTomb + uuid:53d0c857-20ef-426d-a180-026e7a2885c6 + /var/lib/mediatomb + /usr/share/mediatomb/web + + + mediatomb.db + + + localhost + mediatomb + mediatomb + + + + + + + 128 + 5 + no + no + + + * + + video + + + + + + + /usr/share/mediatomb/js/common.js + /usr/share/mediatomb/js/playlists.js + + /etc/mediatomb/import-custom.js + /usr/share/mediatomb/js/import-dvd.js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + video/mpeg + no + yes + yes + + + + + + diff --git a/mediatomb/import-custom.js b/mediatomb/import-custom.js new file mode 100644 index 0000000..cb67f2a --- /dev/null +++ b/mediatomb/import-custom.js @@ -0,0 +1,159 @@ +/*jslint indent: 4, maxerr: 50, sloppy: true */ + +function addAudio(obj) { + var desc = '', track = '', temp = '', artist_full, album_full, + title = obj.meta[M_TITLE], artist = obj.meta[M_ARTIST], + album = obj.meta[M_ALBUM], date = obj.meta[M_DATE], + genre = obj.meta[M_GENRE], description = obj.meta[M_DESCRIPTION]; + + // first gather data + if (!title) { + title = obj.title; + } + + if (!artist) { + artist = 'Unknown'; + artist_full = null; + } else { + artist_full = artist; + desc = artist; + } + + if (!album) { + album = 'Unknown'; + album_full = null; + } else { + desc = desc + ', ' + album; + album_full = album; + } + + if (desc) { + desc = desc + ', '; + } + desc = desc + title; + + if (!date) { + date = 'Unknown'; + } else { + date = getYear(date); + desc = desc + ', ' + date; + } + + if (!genre) { + genre = 'Unknown'; + } else { + desc = desc + ', ' + genre; + } + + if (!description) { + obj.meta[M_DESCRIPTION] = desc; + } + + obj.title = title; + addCdsObject(obj, createContainerChain(['Audio', 'All Audio'])); + addCdsObject(obj, createContainerChain(['Audio', 'Artists', artist, 'All Songs'])); + + if (artist_full) { + temp = artist_full; + } + + if (album_full) { + temp = temp + ' - ' + album_full + ' - '; + } else { + temp = temp + ' - '; + } + + obj.title = temp + title; + addCdsObject(obj, createContainerChain(['Audio', 'All - full name'])); + addCdsObject(obj, createContainerChain(['Audio', 'Artists', artist, 'All - full name'])); + + obj.title = track + title; + addCdsObject(obj, createContainerChain(['Audio', 'Artists', artist, album]), UPNP_CLASS_CONTAINER_MUSIC_ALBUM); + addCdsObject(obj, createContainerChain(['Audio', 'Albums', album]), UPNP_CLASS_CONTAINER_MUSIC_ALBUM); + addCdsObject(obj, createContainerChain(['Audio', 'Genres', genre]), UPNP_CLASS_CONTAINER_MUSIC_GENRE); + addCdsObject(obj, createContainerChain(['Audio', 'Year', date])); +} + +function getEp(obj) { + var ep = ''; + + // Flexget Renamer Format + var regex = /(.*) - S(\d\d)E(\d\d) - (.*)/, ep = ''; + var match = regex.exec(obj.title); + if (match) { + return 'Episode ' + match[3] + ' - ' + match[4]; + } + + // Neighbours Format + var regex = /(.*) - Episode (\d\d\d\d) - (.*)/, ep = ''; + var match = regex.exec(obj.title); + if (match) { + return 'Episode ' + match[2] + ' - ' + match[3]; + } + return ep; +} + +function addVideo(obj) { + var chain = [], location = obj.location.split('/'), epname = ''; + + var root = location[3], series = location[4]; + if (location.length > 5) { + var season = location[5]; + } else + var season = null; + + // Check if the file is a TV Show + if (root === "TV") { + chain.push("TV Shows"); //genre name (Series, Movies) + chain.push(series); //series name (MySeries) + if (series != 'Neighbours') { + print('Found TV: ' + series + " - " + season); + chain.push(season); //season (Series 1, 2, ...) + } else { + print('Found TV: ' + location[location.length-3]); + } + + // Parse the title into a useful name + epname = getEp(obj); + if (epname) { + obj.title = epname; + } + + } else if (root === "Recent") { + chain.push("Recent"); + + } else if (root === "Movies") { + print("Found Movie: " + obj.title); + chain.push("Movies"); + } else { + chain.push("Other"); + } + addCdsObject(obj, createContainerChain(chain)); +} + +// main script part +if (getPlaylistType(orig.mimetype) === '') { + var arr = orig.mimetype.split('/'); + var mime = arr[0]; + + print("Importing: " + orig.title + " - MIME: " + mime); + + var obj = orig; + obj.refID = orig.id; + + if (mime === 'audio') { + addAudio(obj); + } + + if (mime === 'video') { + addVideo(obj); + } + + if (orig.mimetype === 'application/ogg') { + if (orig.theora === 1) { + addVideo(obj); + } else { + addAudio(obj); + } + } +} diff --git a/mediatomb/mediatomb-transcode b/mediatomb/mediatomb-transcode new file mode 100755 index 0000000..c20bfa4 --- /dev/null +++ b/mediatomb/mediatomb-transcode @@ -0,0 +1,118 @@ +#!/bin/bash +# +# This script is used by MediaTomb for transcoding support. +# +# Basic function that will transcode any input file into the target type +# 'dvd' ffmpeg supports +video_common() { + local input="$1" + local output="$2" + exec ffmpeg -i "$input" -t dvd -y "$output" +} + +# Basic function that will transcode any input file into the wav format +audio_common() { + local input="$1" + local output="$2" + exec ffmpeg -i "$input" -f s16be -y "$output" +} + +transcode_matroska() { + local input="$1" + local output="$2" + local alang="$3" + local slang="$4" + + audiofmt=`mediainfo --Inform="Audio;%Format%" "$1"` + vidfmt=`mediainfo --Inform="Video;%Format%" "$1"` + + echo "Format: $vidfmt/$audiofmt" + + if [ "$vidfmt" = "AVC" ]; then + # Already MP4, use it + outvidfmt="copy -bsf h264_mp4toannexb" + #outvidfmt="libx264 -level 41 -vpre normal" + else + outvidfmt="avc" + fi + + if [ "$audiofmt" = "AAC" ]; then + outaudfmt="copy" + else + outaudfmt="libmp3lame -ab 192k" + fi + exec ffmpeg -i "$1" -vcodec $outvidfmt -acodec $outaudfmt -copyts -sameq -f mpegts -y "$2" +} + +# Our "main" function below. + +USAGE=" +This script is used by MediaTomb for transcoding support. It can also serve as +a script to transcode various files in a format suitable for streaming directly. + +Synopsis: + mediatomb-transcode [TRANSCODE FUNCTION OPTION] [GENERIC OPTIONS] + +Generic Options: + -h, --help Display this help message. + -i, --input Input file that is meant to be transcoded. + -o, --output Output file that will be read back by MediaTomb. + --audio-lang Specify ISO 639 language code to use for audio. + --subtitle-lang Specify ISO 639 language code to use for subtitles. + +Transcode Function Options (one is required): + --video-common Perform generic video transcoding. + --audio-common Perform generic audio transcoding. + --transcode-matroska Used in transcoding matroska files. +" + +while [ "$#" -gt "0" ] +do + case "$1" in + -i|--input) + INPUT="$2" + shift; shift; + ;; + -o|--output) + OUTPUT="$2" + shift; shift; + ;; + --video-common) + USE_VIDEO_COMMON=1 + shift + ;; + --audio-common) + USE_AUDIO_COMMON=1 + shift + ;; + --transcode-matroska) + USE_TRANSCODE_MATROSKA=1 + shift + ;; + --audio-lang) + ALANG="$2" + shift; shift; + ;; + --subtitle-lang) + SLANG="$2" + shift; shift; + ;; + -h|--help|*) + echo "${USAGE}" + exit 1 + ;; + esac +done + +# Perform specified function +if [ $USE_VIDEO_COMMON ]; then + video_common "$INPUT" "$OUTPUT" +elif [ $USE_AUDIO_COMMON ]; then + audio_common "$INPUT" "$OUTPUT" +elif [ $USE_TRANSCODE_MATROSKA ]; then + transcode_matroska "$INPUT" "$OUTPUT" "$ALANG" "$SLANG" +else + # Must specify one transcoding function + echo "${USAGE}" + exit 1 +fi