Skip to content

Export Templates

Myron edited this page Jun 13, 2017 · 8 revisions

Export Templates

tinyMediaManager uses the Java Minimal Template Engine (JMTE) to construct the exported page. You will find the JMTE Language reference at http://htmlpreview.github.io/?https://github.com/DJCordhose/jmte/blob/master/doc/index.html

Creating templates

If you want to edit or create a new template make a copy of the template folder you would like to build upon. Do NOT edit the default templates as they will be overwritten each time you start tMM and you will lose your changes!

If you create a nice template and want us to ship it to all users, contact us and we will review it for distribution with the program.
You can also send plain HTML templates; we would integrate the functionality for you ;)

Template setup

Templates rely on three files to export successfully. All other files you create will also be exported, retaining their directory structure, when the page is built by tMM; this allows for the inclusion of style sheets, images and scripts.

  • template.conf - This configuration file tells tMM where to find the other required files.
  • list.jmte - Template for creating a list of your movies/shows (maybe with links to detail pages)
  • detail.jmte - Template for detailed information of one movie or show. detail.jmte is required only if you want tMM to build individual .xxx files for inclusion into index.html either through an .ajax() call or iframe.
  • episode.jmte - episode.jmte is required only if you want tMM to build individual .xxx files for inclusion into index.html/detail.html either through an .ajax() call or iframe.

Each template must be in its own directory and include a template.conf file. The contents of template.conf must include:

  • name=<name of template> - The name that will display to the user when exporting through the UI.
  • type={movie, tv_show} - Currently only movie/tv show templates are supported.
  • list=<path to list.jmte> - (default: list.jmte) This is the template which will be used to build index.html or movielist.xml/csv.
  • detail=<path to detail.jmte> - (default: detail.jmte) Remove this line if you do not require individual <movie>.html pages.
  • episode - (default: episode.jmte) Only for TV show exporting! This is the template for episode data export.
  • extension={html|xml|csv} - (default: html) This is the format tMM will export.
  • description=<text> - Write a short description that will print in the tMM exporter UI. Newlines (\n) should be used to insert paragraph breaks.
  • url=<url to homepage> - The URL to the page that hosts this template or to the author's homepage. Remove this line if you have neither.

Using the above information write your template.conf file. It may resemble this example:

    name=Jelly is Delicious
    type=movie
    list=list.jmte
    detail=detail.jmte
    extension=html
    description=Created by William Shatner\n\nThis template has jelly in its gears.
    url=https://github.com/TheShatner/jelly_template

list.jmte and detail.jmte are HTML pages. The JMTE syntax is used to insert variables like movie name, cast, genre and file information. All of the variables are stored in the list array movies. To access each movies' variables you must itterate over the entire list array.

Accessing data

In the following code the list array movies is iterated over. For each movie entry we assign the variable movie to hold its details and append the name of a variable to print individual attributes.

    <div class="movie details">
    ${foreach movies movie}
        <span class="bold">Title</span>: ${movie.name}
        <span class="bold">Year</span>: ${movie.year}
    ${end}
    </div>

As you can see, the name variable in ${movie.name} tells JMTE to print the name of the movie. The variable name is a string, but some movie variables are also list arrays. Print the list array genres with the following code:

    ${foreach movies movie}
        ${movie.name}
        <span class="genreList">
        ${foreach movie.genres genre , } // " , " comma is used here as genre seperator
            ${genre}
        ${end}
        </span>
    ${end}

In this example we iterated over the movies list array like in the previous example. Then, from within the first foreach loop, we iterated over the genres list array and printed them. We told JMTE to separate each entry with a comma by putting a comma at the end of the foreach instance.

To access values in a map, you can simply use map key like the variable (to access a key from type enum, you have to use upper case notation)

    ${foreach movies movie}
        <img src="${movie.artworkUrls.POSTER(../nopicture.gif)}" />
    ${end}     

In this example we exported the url of the first poster with jmte and also provided a fallback (../nopicture.gif) if there is no poster.

Exporting images

You can either embed image urls (see the example above) into your templates or export the images from your library.

Be aware: Image urls are not always available. Whenever you scrape a movie/episode in tinyMediaManager we store the image url in our internal database. But if you import existing objects into tinyMediaManager (via NFOs), there are no more urls available and your export template could get incomplete.

We've added a feature to trigger an export of images (with or without scaling) along the meta data export. In the following example you see how a movie poster can be exported via the template:

    ${foreach movies movie}
        <img src="../${movie;copyArtwork(type=POSTER, thumb=true, width=180, destination=images, fallback=../nopicture.gif)}" />
    ${end}    

To initiate the export process you only need ${movie;copyArtwork(type=...)}. All other options are optional.

As you see there are some options for exporting available:

  • type=...: select which artwork type you want to export:
    • POSTER
    • FANART
    • BANNER
    • CLEARART
    • DISCART
    • LOGO
    • THUMB
    • SEASON_POSTER
  • thumb=...: rescale the image to a thumbnail? Valid options are true and false. Default is false
  • width=...: scale to the desired width when creating a thumbnail. Valid is any number. Default: 150
  • destination=...: the destination folder where to export the images to. This name is relative to the chosen export folder (e.g. you want to export to H:\export and have img as destination, all images will be exported to H:\export\img). Default: images
  • default=../nopicture.gif: this image will be taken if the desired image can not be exported for this movie

Available data

Following variables can be used:

Movies

Movies
UUID dbId
String title
String originalTitle
String sortTitle
String tagline
String year
String plot
String path
String dataSource
HashMap<String, Object> ids
String imdbId
int tmdbId
int traktId
int top250
String titleForUi
String titleSortable
MovieSet movieSet
String movieSetTitle
Certification certification
String country
String spokenLanguages
String director
String writer
String productionCompany
float rating
int votes
Date releaseDate
String releaseDateAsString
String releaseDateFormatted
Date dateAdded
String dateAddedAsString
String genresAsString
String tagsAsString
MovieEdition edition
String editionAsString
MediaSource mediaSource
String mediaInfoAudioCodecAndChannels
int mediaInfoVideoBitrate
String mediaInfoVideoCodec
String mediaInfoVideoFormat
String mediaInfoVideoResolution
int runtime
int runtimeFromMediaFiles
int runtimeFromMediaFilesInMinutes
List<MovieActor> actors
List<MediaFile> mediaFiles
Map<MediaFileType, MediaFile> artworkMap
Map<MediaFileType, String> artworkUrls
List<String> extraFanarts
List<String> extraThumbs
List<MediaGenres> genres
List<MovieProducer> producers
List<String> tags
List<MovieTrailer> trailer
List<MediaFile> videoFiles
boolean disc
boolean duplicate
boolean hasImages
boolean hasMetadata
boolean hasNfoFile
boolean hasRating
boolean hasTrailer
boolean multiMovieDir
boolean offline
boolean scraped
boolean videoIn3D
boolean watched
MovieActor
String character
String name
String role
String thumbUrl
MovieProducer
String name
String role
String thumbUrl
MediaFile
MediaFileType type
String path
String filename
String basename
String extension
String filenameWithoutStacking
long filedate
long filesize
String filesizeInMegabytes
List<MediaFileAudioStream> audioStreams
List<MediaFileSubtitle> subtitles
Float aspectRatio
String audioChannels
String audioCodec
String audioLanguage
String biteRateInKbps
String combinedCodecs
String containerFormat
int duration
String durationHHMMSS
String durationHM
int durationInMinutes
String durationShort
String exactVideoFormat
int overallBitRate
String subtitlesAsString
String video3DFormat
String videoCodec
String videoDefinitionCategory
String videoFormat
String videoResolution
int videoHeight
int videoWidth
boolean discFile
boolean graphic
boolean packed
boolean video
MediaFileAudioStream
int bitrate
String bitrateInKbps
String channels
int channelsAsInt
String codec
String language
MediaFileSubtitle
String codec
boolean forced
String language
MovieTrailer
String date
String downloadUrl
Boolean inNfo
String name
String provider
String quality
String url
MediaFileType
VIDEO main video files
VIDEO_EXTRA bonus/extra videos
TRAILER trailer
SAMPLE sample != trailer
AUDIO audio files
SUBTITLE subtitle files
NFO NFO files
POSTER poster
FANART fanart
BANNER banner
CLEARART clearart
DISCART disc art
LOGO logo
CLEARLOGO clear logo
THUMB thumb
SEASON_POSTER season poster
EXTRAFANART extra fanart
EXTRATHUMB extra thumb
GRAPHIC generic graphic
TEXT various text infos, like BDinfo.txt or others...
UNKNOWN

TV shows

TvShow
UUID dbId
String path
String title
String titleSortable
String year
String plot
Map<String, Object> ids
String tvdbId
String imdbId
int traktId
float rating
int votes
Certification certification
String dataSource
Date dateAdded
String dateAddedAsString
int runtime
int seasonCount
int episodeCount
Date firstAired
String firstAiredAsString
String genresAsString
String productionCompany
String status
String tagAsString
List<TvShowActor> actors
Map<MediaFileType, MediaFile> artworkMap
Map<MediaFileType, String> artworkUrls
List<MediaFile> mediaFiles
List<TvShowSeason> seasons
List<TvShowEpisode> episodes
List<MediaFile> episodesMediaFiles
List<MediaGenres> genres
List<String> tags
boolean hasImages
boolean hasNfoFile
boolean scraped
TvShowSeason
int season
String poster
String posterUrl
List<TvShowEpisode> episodes
List<MediaFile> mediaFiles
TvShow tvShow
TvShowEpisode
UUID dbId
String path
int episode
int season
int displayEpisode
int displaySeason
int dvdEpisode
int dvdSeason
int airedEpisode
int airedSeason
String title
String titleForUi
String year
String plot
String director
String writer
float rating
Date firstAired
String firstAiredAsString
String firstAiredFormatted
String mediaInfoAudioCodecAndChannels
String mediaInfoVideoCodec
String mediaInfoVideoFormat
TvShow tvShow
UUID tvShowDbId
TvShowSeason tvShowSeason
String tvdbId
String productionCompany
int votes
MediaSource mediaSource
int runtimeFromMediaFiles
int runtimeFromMediaFilesInMinutes
String tagAsString
List<String> tags
Map<String, Object> ids
List<MediaFile> mediaFiles
List<MediaFile> videoFiles
List<TvShowActor> actors
List<TvShowActor> guests
Map<MediaFileType, MediaFile> artworkMap
Map<MediaFileType, String> artworkUrls
Date dateAdded
String dateAddedAsString
boolean disc
boolean dvdOrder
boolean hasImages
boolean hasNfoFile
boolean multiEpisode
boolean scraped
boolean watched
TvShowActor
String character
String name
String role
String thumbUrl
MediaFile
MediaFileType type
String path
String filename
String basename
String extension
String filenameWithoutStacking
long filedate
long filesize
String filesizeInMegabytes
List<MediaFileAudioStream> audioStreams
List<MediaFileSubtitle> subtitles
Float aspectRatio
String audioChannels
String audioCodec
String audioLanguage
String biteRateInKbps
String combinedCodecs
String containerFormat
int duration
String durationHHMMSS
String durationHM
int durationInMinutes
String durationShort
String exactVideoFormat
int overallBitRate
String subtitlesAsString
String video3DFormat
String videoCodec
String videoDefinitionCategory
String videoFormat
String videoResolution
int videoHeight
int videoWidth
boolean discFile
boolean graphic
boolean packed
boolean video
MediaFileAudioStream
int bitrate
String bitrateInKbps
String channels
int channelsAsInt
String codec
String language
MediaFileSubtitle
String codec
boolean forced
String language
You can’t perform that action at this time.