Kodi Community Forum
Template to export all video files of a TV Show - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116)
+---- Forum: TinyMediaManager (https://forum.kodi.tv/forumdisplay.php?fid=204)
+---- Thread: Template to export all video files of a TV Show (/showthread.php?tid=349569)



Template to export all video files of a TV Show - jhoyos - 2019-11-26

Hi, 

I have TV organized in folders, where I can mix several qualities of the same TV show in the same folders.

For example... 

TV Shows
-  Game of thrones
------  Season 1 [1080p BDremux] [DUAL]
------  Season 1 [1080p h264 MicroHD] [DUAL]
------  Season 1 [4K Remux ] [DUAL]
------  Season 2 [1080p BDremux] [DUAL]
------  Season 2 [1080p h264 MicroHD] [DUAL]
------  Season 3 [4K Remux ] [DUAL]

TMM groups perfectly the files so when looking at a specific episode, you can see it has 3 files (one for each version).  See "picture 01.jpg"

Image

What I want is to export all video files with its properties into a template, which is the following one...

Code:

<?xml version="1.0" encoding="utf-8"?>

<tvshows>

<!-- iterate over all TV shows -->
${foreach tvShows show}
${foreach show.episodes episode}

  <tvshow>

    <title>${show.title}</title>
    <year>${show.year}</year>
    <seasons>${show.seasonCount}</seasons>
    <episodes>${show.episodeCount}</episodes>
    <Nombre>${episode.title}</Nombre>
    <season>${episode.season}</season>
    <episode>${episode.episode}</episode>
    <date>${episode.firstAiredFormatted}</date>
    <filesize>${episode.mainVideoFile.filesize}</filesize>
    <extension>${episode.mainVideoFile.extension}</extension>
    <codec>${episode.mainVideoFile.videoCodec}</codec>
    <format>${episode.mainVideoFile.videoFormat}</format>
    <resolution>${episode.mainVideoFile.videoResolution}</resolution>
    <bit>${episode.mainVideoFile.biteRateInKbps}</bit>
    <categoria>${episode.mainVideoFile.videoDefinitionCategory}</categoria>
    <framerate>${episode.mainVideoFile.frameRate}</framerate>
    <aspectratio>${episode.mainVideoFile.aspectRatio}</aspectratio>
    <hdr>${episode.mainVideoFile.HDR}</hdr>
    <duration>${episode.mainVideoFile.duration}</duration>
    <audiocodec>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.codec}, ${end}${end}</audiocodec>
    <audioChannels>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.audioChannels}, ${end}${end}</audioChannels>
    <audiobitrate>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.bitrateInKbps}, ${end}${end}</audiobitrate>
    <subtitle>${episode.mainVideoFile.subtitlesAsString}</subtitle>
    <path>${episode.mainVideoFile.path}</path>
    <filename>${episode.mainVideoFile.filename}</filename>
  </tvshow>
${end}${end}
</tvshows>

My problem is that when exporting, TMM just export one of each episodes, which seem to be ramdon... once it is 4K Remux, others is 1080p Remux and others is 1080p MicroHD.

I have been looking at the template, and there is a field which is "episode.mainVideoFile.videoResolution", so it seems it is just showing one episode info, the "main one".

I was wondering how can I change the template, to be able to list ALL EPISODES (video files) from the TV show, not just the main one.

Thanks in advanced.


RE: Template to export all video files of a TV Show - mlaggner - 2019-11-26

you would have a 1:n relation (from episode to video files), so you would need another loop ${foreach episode.videoFiles video} ...

this way you should get all video files for all episodes


RE: Template to export all video files of a TV Show - jhoyos - 2019-11-26

(2019-11-26, 14:20)mlaggner Wrote: you would have a 1:n relation (from episode to video files), so you would need another loop ${foreach episode.videoFiles video} ...

this way you should get all video files for all episodes

Thanks for your help!  Now... I have 3 entries for each episode, which it is correct, but the problem is that both 3 entries are similar, so it is not writing one entry for each episode, but 3 entries for the same episode.

This is how I put my code.  I guess my loop it is not in a correct place.  Would you be able to tell me where I should put it?

Thanks in advanced.

Code:

<?xml version="1.0" encoding="utf-8"?>

<tvshows>

<!-- iterate over all TV shows -->
${foreach tvShows show}
${foreach show.episodes episode}
${foreach episode.videoFiles video}

  <tvshow>

    <title>${show.title}</title>
    <year>${show.year}</year>
    <seasons>${show.seasonCount}</seasons>
    <episodes>${show.episodeCount}</episodes>
    <Nombre>${episode.title}</Nombre>
    <season>${episode.season}</season>
    <episode>${episode.episode}</episode>
    <date>${episode.firstAiredFormatted}</date>
    <filesize>${episode.mainVideoFile.filesize}</filesize>
    <extension>${episode.mainVideoFile.extension}</extension>
    <codec>${episode.mainVideoFile.videoCodec}</codec>
    <format>${episode.mainVideoFile.videoFormat}</format>
    <resolution>${episode.mainVideoFile.videoResolution}</resolution>
    <bit>${episode.mainVideoFile.biteRateInKbps}</bit>
    <categoria>${episode.mainVideoFile.videoDefinitionCategory}</categoria>
    <framerate>${episode.mainVideoFile.frameRate}</framerate>
    <aspectratio>${episode.mainVideoFile.aspectRatio}</aspectratio>
    <hdr>${episode.mainVideoFile.HDR}</hdr>
    <duration>${episode.mainVideoFile.duration}</duration>
    <audiocodec>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.codec}, ${end}${end}</audiocodec>
    <audioChannels>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.audioChannels}, ${end}${end}</audioChannels>
    <audiobitrate>${foreach episode.videoFiles videofile} ${foreach videofile.audioStreams audio} ${audio.bitrateInKbps}, ${end}${end}</audiobitrate>
    <subtitle>${episode.mainVideoFile.subtitlesAsString}</subtitle>
    <path>${episode.mainVideoFile.path}</path>
    <filename>${episode.mainVideoFile.filename}</filename>
  </tvshow>

${end}${end}${end}
</tvshows>




RE: Template to export all video files of a TV Show - mlaggner - 2019-12-04

this completely depends WHAT you want to achieve. If you want a clean XML, you are wrong by putting both (or all three) loops outside the <tshow> tag.
But I suppose you want a <tsvhow> entry per episode with all episodes beneath it.

I'd suggest you to try this one

 
Code:
<?xml version="1.0" encoding="utf-8"?>

<tvshows>

<!-- iterate over all TV shows -->
${foreach tvShows show}
${foreach show.episodes episode}

  <tvshow>

    <title>${show.title}</title>
    <year>${show.year}</year>
    <seasons>${show.seasonCount}</seasons>
    <episodes>${show.episodeCount}</episodes>
    <Nombre>${episode.title}</Nombre>
    <season>${episode.season}</season>
    <episode>${episode.episode}</episode>
    <date>${episode.firstAiredFormatted}</date>
    <files>
      ${foreach episode.videoFiles video}
      <file>
        <filesize>${video.filesize}</filesize>
        <extension>${video.extension}</extension>
        <codec>${video.videoCodec}</codec>
        <format>${video.videoFormat}</format>
        <resolution>${video.videoResolution}</resolution>
        <bit>${video.biteRateInKbps}</bit>
        <categoria>${video.videoDefinitionCategory}</categoria>
        <framerate>${video.frameRate}</framerate>
        <aspectratio>${video.aspectRatio}</aspectratio>
        <hdr>${video.HDR}</hdr>
        <duration>${video.duration}</duration>
        <audiocodec> ${foreach video.audioStreams audio} ${audio.codec}, ${end}</audiocodec>
        <audioChannels>${foreach video.audioStreams audio} ${audio.audioChannels}, ${end}</audioChannels>
        <audiobitrate>${foreach video.audioStreams audio} ${audio.bitrateInKbps}, ${end}</audiobitrate>
        <subtitle>${video.subtitlesAsString}</subtitle>
        <path>${video.path}</path>
        <filename>${video.filename}</filename>
      <file>
     ${end}
    </files>
  </tvshow>

${end}${end}
</tvshows>