Sign up here and you can log into the forum!

XSL Support for templates

Support forum for the great ThumbGen software

Re: XSL Support for templates   

Postby kanel » Sun Feb 17, 2013 6:06 am

Hi,

I have about 400 movies with info shown from Media Info listed below in the example.

They all have the following in common:

General
Format : MPEG-TS
Video
Format : MPEG Video
Format version : Version 2
Scan type : Interlaced
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2

ThumbGen make these selections:
Resolution = 576p (should be 576i)
Format = mpeg4 (should be mpeg2)
Audio = unknown (should be mp2)

I can trick the program into using 576i logo instead of 576p and mpeg logo instead of mpeg4 by renaming the image files used to generate the sheets.
But since audio is defined as "unknown", I can not do the "rename image file" trick to get audio logo in the sheets.

ThumbGen does not select correct info, so I hope the usage of XSL could do the trick. I have zero knowledge in XSL coding.

Is there someone skilled in XSL who could make a script that choose correct media info values as listed above and select 576i, mpeg2 and mp2 logo images?

Code: Select all
General
ID                                       : 1 (0x1)
Complete name                            : Q:\FILM\-THRILLER-\Arachnophobia\Arachnophobia.ts
Format                                   : MPEG-TS
File size                                : 3.07 GiB
Duration                                 : 1h 44mn
Overall bit rate mode                    : Variable
Overall bit rate                         : 4 193 Kbps

Video
ID                                       : 522 (0x20A)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : Main@Main
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Custom
Codec ID                                 : 2
Duration                                 : 1h 44mn
Bit rate mode                            : Variable
Bit rate                                 : 3 727 Kbps
Maximum bit rate                         : 10 000 Kbps
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 16:9
Active Format Description                : Full frame 16:9 image
Frame rate                               : 25.000 fps
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.359
Stream size                              : 2.73 GiB (89%)

Audio
ID                                       : 664 (0x298)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 2
Codec ID                                 : 3
Duration                                 : 1h 44mn
Bit rate mode                            : Constant
Bit rate                                 : 256 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Delay relative to video                  : 1ms
Stream size                              : 192 MiB (6%)
Language                                 : English
kanel
n00b
 
Posts: 1
Joined: Sun Feb 17, 2013 5:27 am

Re: XSL to show empty.png if the%SUBTITLES4% token is empty   

Postby pityrules » Sun Feb 24, 2013 4:32 am

These are awesome tips, just what I will be looking for once I get more proficient as it mentions thing that I already wish I could alter - eg getting rid of certain fields if no information is displayed.
Thanks for all the good work!
pityrules
WDTVer
 
Posts: 26
Joined: Wed Feb 20, 2013 10:03 am

Re: XSL Support for templates   

Postby leetwanker » Sun Nov 24, 2013 1:01 am

Buhric wrote:Heres some XSLT code to make that Company Logo show up more often...
Some movie have like 3 or 4 companies listed, but you end end without any logo shown...
The reason is, by default, only the 1st capany name will be taken in consideration for the logo
and most of the time theres no PNG for it, or theres some trailing spaces that prevents TG to find the correct logo...

in short, this will scan up to 4 Company names, then check if a PNG logo exist, and return the 1st one it finds...

make sure you sheet template (XML) has the following line in its <Settings> section
for 4 possible values for Studios
Code: Select all
<Studios Seperator=", " MaximumValues="4" />


then add the following 2 functions and 1 global variable in the JavaScript part of the XSLT file
"trim" is to remove white spaces at strat and end of studio name, noticed that many has trailing spaces...
"findStudios" returns the 1st studio found that a .png file existed
Code: Select all
    var Studios = [];

    function trim(oString)
    {
      return oString.replace(/^([\s\t\n]|\&nbsp\;)+|([\s\t\n]|\&nbsp\;)+$/g, '');
    }

    function findStudios(oStudios, oTemplatePath)
    {
      Studios = oStudios.split("/");
      var oFile = new ActiveXObject("Scripting.FileSystemObject");
      var path='';
      for(var i = 0; i < Studios.length; i++)
      {
        path = oTemplatePath + '\\..\\common\\studios\\' + trim(Studios[i]) + '.png';
        if (oFile.FileExists(path))
        {
          return path;
        }
      }
      return '';
    }


You will also need the following variables in the XSLT (on top near the other variables)
Code: Select all
<xsl:variable name="STUDIO" select="string(//tokens/token[@name='%STUDIOS%'])"/>
<xsl:variable name="PATH" select="string(//tokens/token[@name='%PATH%'])"/>


then put the following xsl tag in the XSLT file
This should modify the SourceData for the ImageElement "Studio" pointing to the 1st studio found that a .png exist
Dont forget to change the [@Name='Studio'] for whatever name you have in your template.xml file (some have 'Company')
Code: Select all
  <xsl:template match="//ImageElement[@Name='Studio']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:findStudios($STUDIO,$PATH))"/>
    </xsl:attribute>
  </xsl:template>


Hey Buhric, hoping you can help me out. I'd really like to get this script working but I'm not very experienced with scripts. Trying to learn though.

The problem I'm having is it doesn't find the studio unless it's the first in the list.

Real-world example: Against the Current
Company: Ghost Robot,Ambush Entertainment

If I remove "Ghost Robot," from the list the studio icon appears. Nothing else I've tried has worked. I've messed with "<Studios Separator=", " MaximumValues="4" />" and "Studios = oStudios.split("/");" because I saw thumbgen post to someone else about your script expecting a / and not a , anyway, no luck whatever I tried.

Could you have a look at my code and help me out? Thanks!

Template.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<Template>
  <Settings>
    <Directors Separator=", " MaximumValues="1" ImagesFolder="" DefaultImage="" />
    <Actors Separator=", " MaximumValues="8" ImagesFolder="" DefaultImage="" />
    <Genres Separator=", " MaximumValues="5" ImagesFolder="" DefaultImage="" />
    <Countries Separator=", " MaximumValues="1" ImagesFolder="" DefaultImage="" />
    <Rating FileName="%PATH%\star_1_18x18.png" />
    <Studios Separator=", " MaximumValues="4" />
    <GuestStars Separator=", " MaximumValues="13" ImagesFolder="" DefaultImage="" />
    <Writers Separator=", " MaximumValues="13" ImagesFolder="" DefaultImage="" />
    <Subtitles Separator=", " MaximumValues="5" ImagesFolder="" DefaultImage="" />
    <Episodes Separator=", " MaximumValues="25" ImagesFolder="" DefaultImage="" />
    <EpisodesNames Separator=", " MaximumValues="25" ImagesFolder="" DefaultImage="" />
    <Languages Separator=", " MaximumValues="5" ImagesFolder="" DefaultImage="" />
    <LanguageCodes Separator=", " MaximumValues="5" ImagesFolder="" DefaultImage="" />
  </Settings>
  <SoundFormats>
    <SoundFormat Name="AAC" Text="AAC Unknown" Image="%PATH%\..\Common\sound_format\aac.png" />
    <SoundFormat Name="AAC10" Text="AAC 1.0" Image="%PATH%\..\Common\sound_format\aac10.png" />
    <SoundFormat Name="AAC20" Text="AAC 2.0" Image="%PATH%\..\Common\sound_format\aac20.png" />
    <SoundFormat Name="AAC21" Text="AAC 2.1" Image="%PATH%\..\Common\sound_format\aac21.png" />
    <SoundFormat Name="AAC40" Text="AAC 4.0" Image="%PATH%\..\Common\sound_format\aac40.png" />
    <SoundFormat Name="AAC41" Text="AAC 4.1" Image="%PATH%\..\Common\sound_format\aac41.png" />
    <SoundFormat Name="AAC51" Text="AAC 5.1" Image="%PATH%\..\Common\sound_format\aac51.png" />
    <SoundFormat Name="AAC70" Text="AAC 7.0" Image="%PATH%\..\Common\sound_format\aac70.png" />
    <SoundFormat Name="AAC71" Text="AAC 7.1" Image="%PATH%\..\Common\sound_format\aac71.png" />
    <SoundFormat Name="DD" Text="DD Unknown" Image="%PATH%\..\Common\sound_format\dd.png" />
    <SoundFormat Name="DD20" Text="Dolby Digital 2.0" Image="%PATH%\..\Common\sound_format\dd20.png" />
    <SoundFormat Name="DD21" Text="Dolby Digital 2.1" Image="%PATH%\..\Common\sound_format\dd21.png" />
    <SoundFormat Name="DD40" Text="Dolby Digital 4.0" Image="%PATH%\..\Common\sound_format\dd40.png" />
    <SoundFormat Name="DD41" Text="Dolby Digital 4.1" Image="%PATH%\..\Common\sound_format\dd41.png" />
    <SoundFormat Name="DD51" Text="Dolby Digital 5.1" Image="%PATH%\..\Common\sound_format\dd51.png" />
    <SoundFormat Name="DD70" Text="Dolby Digital 7.0" Image="%PATH%\..\Common\sound_format\dd70.png" />
    <SoundFormat Name="DD71" Text="Dolby Digital 7.1" Image="%PATH%\..\Common\sound_format\dd71.png" />
    <SoundFormat Name="DDPLUS" Text="Dolby Digital Plus" Image="%PATH%\..\Common\sound_format\ddplus.png" />
    <SoundFormat Name="DTRUEHD" Text="Dolby True HD" Image="%PATH%\..\Common\sound_format\dtruehd.png" />
    <SoundFormat Name="DTS" Text="DTS Unknown" Image="%PATH%\..\Common\sound_format\dts.png" />
    <SoundFormat Name="DTS20" Text="DTS 2.0" Image="%PATH%\..\Common\sound_format\dts20.png" />
    <SoundFormat Name="DTS21" Text="DTS 2.1" Image="%PATH%\..\Common\sound_format\dts21.png" />
    <SoundFormat Name="DTS40" Text="DTS 4.0" Image="%PATH%\..\Common\sound_format\dts40.png" />
    <SoundFormat Name="DTS41" Text="DTS 4.1" Image="%PATH%\..\Common\sound_format\dts41.png" />
    <SoundFormat Name="DTS51" Text="DTS 5.1" Image="%PATH%\..\Common\sound_format\dts51.png" />
    <SoundFormat Name="DTS70" Text="DTS 7.0" Image="%PATH%\..\Common\sound_format\dts70.png" />
    <SoundFormat Name="DTS71" Text="DTS 7.1" Image="%PATH%\..\Common\sound_format\dts71.png" />
    <SoundFormat Name="DTSES" Text="DTS ES" Image="%PATH%\..\Common\sound_format\dtses.png" />
    <SoundFormat Name="DTSHD" Text="DTS HD" Image="%PATH%\..\Common\sound_format\dtshd.png" />
    <SoundFormat Name="FLAC" Text="Flac" Image="%PATH%\..\Common\sound_format\flac.png" />
    <SoundFormat Name="FLAC20" Text="Flac 2.0" Image="%PATH%\..\Common\sound_format\flac20.png" />
    <SoundFormat Name="FLAC21" Text="Flac 2.1" Image="%PATH%\..\Common\sound_format\flac21.png" />
    <SoundFormat Name="FLAC40" Text="Flac 4.0" Image="%PATH%\..\Common\sound_format\flac40.png" />
    <SoundFormat Name="FLAC41" Text="Flac 4.1" Image="%PATH%\..\Common\sound_format\flac41.png" />
    <SoundFormat Name="FLAC51" Text="Flac 5.1" Image="%PATH%\..\Common\sound_format\flac51.png" />
    <SoundFormat Name="FLAC70" Text="Flac 7.0" Image="%PATH%\..\Common\sound_format\flac70.png" />
    <SoundFormat Name="FLAC71" Text="Flac 7.1" Image="%PATH%\..\Common\sound_format\flac71.png" />
    <SoundFormat Name="MLP" Text="MLP" Image="%PATH%\..\Common\sound_format\mlp.png" />
    <SoundFormat Name="MP3" Text="All Mpeg" Image="%PATH%\..\Common\sound_format\mp3.png" />
    <SoundFormat Name="MP310" Text="MP3 1.0" Image="%PATH%\..\Common\sound_format\mp310.png" />
    <SoundFormat Name="MP320" Text="MP3 2.0" Image="%PATH%\..\Common\sound_format\mp320.png" />
    <SoundFormat Name="OGG" Text="Ogg" Image="%PATH%\..\Common\sound_format\ogg.png" />
    <SoundFormat Name="OGG20" Text="Ogg 2.0" Image="%PATH%\..\Common\sound_format\ogg20.png" />
    <SoundFormat Name="OGG21" Text="Ogg 2.1" Image="%PATH%\..\Common\sound_format\ogg21.png" />
    <SoundFormat Name="OGG40" Text="Ogg 4.0" Image="%PATH%\..\Common\sound_format\ogg40.png" />
    <SoundFormat Name="OGG41" Text="Ogg 4.1" Image="%PATH%\..\Common\sound_format\ogg41.png" />
    <SoundFormat Name="OGG51" Text="Ogg 5.1" Image="%PATH%\..\Common\sound_format\ogg51.png" />
    <SoundFormat Name="OGG70" Text="Ogg 7.0" Image="%PATH%\..\Common\sound_format\ogg70.png" />
    <SoundFormat Name="OGG71" Text="Ogg 7.1" Image="%PATH%\..\Common\sound_format\ogg71.png" />
    <SoundFormat Name="VORBIS" Text="vorbis" Image="" />
    <SoundFormat Name="WMA" Text="WMA" Image="" />
  </SoundFormats>
  <MediaFormats>
    <MediaFormat Name="AVCHD" Text="AVCHD" Image="%PATH%\..\Common\media_format\avchd.png" />
    <MediaFormat Name="BLURAY" Text="Blu-Ray" Image="%PATH%\..\Common\media_format\bluray.png" />
    <MediaFormat Name="DVD" Text="DVD" Image="%PATH%\..\Common\media_format\dvd.png" />
    <MediaFormat Name="flv" Text="FLV" Image="%PATH%\..\Common\video_format\flv.png" />
    <MediaFormat Name="HDDVD" Text="HD DVD" Image="%PATH%\..\Common\media_format\hddvd.png" />
    <MediaFormat Name="mov" Text="MOV" Image="%PATH%\..\Common\video_format\mov.png" />
    <MediaFormat Name="mpeg" Text="MPEG" Image="%PATH%\..\Common\media_format\mpeg.png" />
    <MediaFormat Name="mpeg2" Text="MPEG-2" Image="%PATH%\..\Common\media_format\mpeg.png" />
    <MediaFormat Name="mpeg4" Text="MPEG-4" Image="%PATH%\..\Common\media_format\mpeg.png" />
    <MediaFormat Name="MKV" Text="MKV" Image="%PATH%\..\Common\media_format\mkv.png" />
    <MediaFormat Name="rm" Text="RM" Image="%PATH%\..\Common\video_format\rm.png" />
    <MediaFormat Name="rmvb" Text="RMVB" Image="%PATH%\..\Common\video_format\rmvb.png" />
  </MediaFormats>
  <VideoFormats>
    <VideoFormat Name="avc" Text="AVC" Image="%PATH%\..\Common\video_format\h264.png" />
    <VideoFormat Name="divx" Text="Divx" Image="%PATH%\..\Common\video_format\divx.png" />
    <VideoFormat Name="wmv" Text="WMV" Image="%PATH%\..\Common\video_format\wmv.png" />
    <VideoFormat Name="xvid" Text="XviD" Image="%PATH%\..\Common\video_format\xvid.png" />
    <VideoFormat Name="mpeg" Text="MPEG-4" Image="" />
  </VideoFormats>
  <Resolutions>
    <Resolution Name="288P" Text="288p" Image="%PATH%\..\Common\image_resolution\288p.png" />
    <Resolution Name="480I" Text="480I" Image="%PATH%\..\Common\image_resolution\480i.png" />
    <Resolution Name="480P" Text="480p" Image="%PATH%\..\Common\image_resolution\480.png" />
    <Resolution Name="576I" Text="576I" Image="%PATH%\..\Common\image_resolution\576i.png" />
    <Resolution Name="576P" Text="576p" Image="%PATH%\..\Common\image_resolution\576.png" />
    <Resolution Name="720I" Text="720I" Image="%PATH%\..\Common\image_resolution\720i.png" />
    <Resolution Name="720P" Text="720p" Image="%PATH%\..\Common\image_resolution\720.png" />
    <Resolution Name="1080I" Text="1080I" Image="%PATH%\..\Common\image_resolution\1080i.png" />
    <Resolution Name="1080P" Text="1080p" Image="%PATH%\..\Common\image_resolution\1080.png" />
  </Resolutions>
  <ImageDrawTemplate SDKVersion="3.0">
    <OutputImageSettings ColorDepth="Format32bppAlpha" ImageFormat="Jpeg" JpegCompressionLevel="80" Dpi="96" />
    <Canvas AutoSize="False" CenterElements="False" Height="470" Width="1280" Fill="Solid,16777215,-16777216,BackwardDiagonal,-1,-16777216,0,,Tile,None,50,100,,,,0,0,0,0,Line,True" />
    <Elements>
      <ImageElement Name="Fanback" X="0" Y="0" Width="1280" Height="720" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%BACKGROUND%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Foreground" X="0" Y="0" Width="1280" Height="720" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%\..\Common\Images\Background.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <Fade Shape="Rectangle" ShapeFill="Gradient,-1,-16777216,BackwardDiagonal,16777215,-16777216,180,,Tile,None,50,100,,,,0,0,0,0,Line,True" Sizing="Fit" Width="1280" Height="720" PathPoints="" PolygonSides="5" StarPoints="5" StarInnerRadiusPercentage="50" Roundness="0" Location="Custom" X="0" Y="0" TGD_IsVisible="True" />
          <ConvertToSepia TGD_IsVisible="True" />
        </Actions>
      </ImageElement>
      <TextElement Name="Show Title" X="801" Y="33" Width="325" Height="30" AutoSize="False" Multiline="False" Font="Arial,18,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%TITLE%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="Year" X="1190" Y="41" Width="50" Height="22" AutoSize="False" Multiline="False" Font="Arial,12,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%YEAR%" TextAlignment="TopRight" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="Tagline" X="807" Y="64" Width="367" Height="15" AutoSize="True" Multiline="False" Font="Arial,8,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%TAGLINE%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <ImageElement Name="Fanart 1" X="807" Y="84" Width="433" Height="254" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%FANART1%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Certification" X="1204" Y="281" Width="30" Height="30" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%\..\common\lstarcertifications\%CERTIFICATION%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </ImageElement>
      <TextElement Name="MPAA" X="807" Y="348" Width="433" Height="14" AutoSize="False" Multiline="False" Font="Arial,10,Point,,0" ForeColor="-1" StrokeColor="-16777216" StrokeWidth="0" Text="%MPAA%" TextAlignment="MiddleCenter" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="StudioText" X="799" Y="380" Width="1" Height="1" AutoSize="False" Multiline="True" Font="Arial,7,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="" TextAlignment="MiddleCenter" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Resolution" X="900" Y="380" Width="59" Height="40" Source="Base64String" Offset="0" MultiPageIndex="-1" SourceData="%RESOLUTION%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Studios" X="807" Y="380" Width="59" Height="40" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%\..\Common\studios\%STUDIOS%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="VCodec" X="994" Y="380" Width="59" Height="40" Source="Base64String" Offset="0" MultiPageIndex="-1" SourceData="%VIDEOFORMAT%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Media" X="1088" Y="380" Width="59" Height="40" Source="Base64String" Offset="0" MultiPageIndex="-1" SourceData="%MEDIAFORMAT%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Sound" X="1181" Y="380" Width="59" Height="40" Source="Base64String" Offset="0" MultiPageIndex="-1" SourceData="%SOUNDFORMAT%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="PlotTEXT" X="807" Y="447" Width="409" Height="14" AutoSize="True" Multiline="False" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="Plot:" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="Plot" X="807" Y="466" Width="433" Height="110" AutoSize="False" Multiline="True" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%PLOT%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="CastTEXT" X="807" Y="585" Width="277" Height="14" AutoSize="True" Multiline="False" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="Starring:" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="Cast" X="807" Y="605" Width="285" Height="49" AutoSize="False" Multiline="True" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%ACTORS%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="DirectorTEXT" X="1111" Y="585" Width="127" Height="14" AutoSize="True" Multiline="False" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="Directed by:" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="Director" X="1111" Y="605" Width="127" Height="49" AutoSize="False" Multiline="True" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%DIRECTORS%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <TextElement Name="IMDBTEXT" X="808" Y="670" Width="40" Height="14" AutoSize="False" Multiline="False" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="IMDb" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <ImageElement Name="Starmask" X="852" Y="670" Width="177" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%\starmask.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Stars" X="852" Y="670" Width="177" Height="18" Source="Base64String" Offset="0" MultiPageIndex="-1" SourceData="%RATINGSTARS%" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="IMDB Rating" X="1035" Y="670" Width="60" Height="14" AutoSize="False" Multiline="False" Font="Arial,10,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%RATING%" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="HourNumber" X="1090" Y="670" Width="50" Height="40" AutoSize="False" Multiline="False" Font="Aeon Player CAPS,30,Point,,0" ForeColor="-4144960" StrokeColor="-16777216" StrokeWidth="0" Text="23" TextAlignment="MiddleRight" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="TextBelow" X="1133" Y="684" Width="81" Height="18" AutoSize="False" Multiline="False" Font="Aeon Player CAPS,15,Point,,0" ForeColor="-4144960" StrokeColor="-16777216" StrokeWidth="0" Text="24 MINUTES" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="TextAbove" X="1135" Y="672" Width="81" Height="13" AutoSize="True" Multiline="False" Font="Square721 BdEx BT,13,Point,,0" ForeColor="-4144960" StrokeColor="-16777216" StrokeWidth="0" Text="HOUR" TextAlignment="TopLeft" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Highlight" X="0" Y="0" Width="1280" Height="720" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%\Highlight2.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <TextElement Name="Genre" X="807" Y="318" Width="428" Height="20" AutoSize="False" Multiline="False" Font="Arial,11,True,False,False,False,Point,,0" ForeColor="-2500135" StrokeColor="-16777216" StrokeWidth="0" Text="%GENRES%" TextAlignment="MiddleCenter" TextQuality="AntiAlias" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <DropShadow Angle="320" Color="-16777216" Distance="3" Opacity="100" Softness="2" TGD_IsVisible="True" />
        </Actions>
      </TextElement>
      <ImageElement Name="AudioPNG" X="1080" Y="435" Width="18" Height="14" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/images/audio.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Audio" X="1106" Y="433" Width="18" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/countries/%LANGUAGE%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="SubtitlesPNG" X="1137" Y="435" Width="18" Height="15" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/images/subtitles.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True">
        <Actions>
          <AdjustOpacity Opacity="10" TGD_IsVisible="True" />
        </Actions>
      </ImageElement>
      <ImageElement Name="Subtitle1" X="1163" Y="433" Width="18" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/countries/%SUBTITLES1%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Subtitle2" X="1182" Y="433" Width="18" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/countries/%SUBTITLES2%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="Subtitle3" X="1201" Y="433" Width="18" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/countries/%EXTERNALSUBTITLES1%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
      <ImageElement Name="ExternalSub1" X="1220" Y="433" Width="18" Height="18" Source="File" Offset="0" MultiPageIndex="-1" SourceData="%PATH%/../Common/countries/%EXTERNALSUBTITLES2%.png" NullImageUrl="" PreserveMetaData="True" TGD_IsLocked="False" TGD_IsVisible="True" />
    </Elements>
  </ImageDrawTemplate>
</Template>


template.xslt
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:myjs="urn:custom-javascript" exclude-result-prefixes="msxsl myjs">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:variable name="FolderJpgName" select="string('folder.jpg')"/>
  <xsl:variable name="FilePath" select="string(//tokens/token[@name='%TITLEPATH%'])"/>
  <xsl:variable name="FileName" select="string(//tokens/token[@name='%MOVIEFILENAME%'])"/>
  <xsl:variable name="TemplatePath" select="string(//tokens/token[@name='%PATH%'])"/>
  <xsl:variable name="RATING" select="string(//tokens/token[@name='%RATING%'])"/>
  <xsl:variable name="Runtime" select="string(//tokens/token[@name='%RUNTIME%'] * 60)"/>
  <xsl:variable name="STUDIO" select="string(//tokens/token[@name='%STUDIOS%'])"/>
  <xsl:variable name="Studios" select="string(//tokens/token[@name='%STUDIOS%'])"/>
  <xsl:variable name="PATH" select="string(//tokens/token[@name='%PATH%'])"/>
  <xsl:variable name="DurationSec" select="string(//tokens/token[@name='%DURATIONSEC%'])"/>
  <!--xsl:variable name="Runtime" select="string(21 * 60)"/>
  <xsl:variable name="DurationSec" select="string('1265')"/-->
  <msxsl:script language="JavaScript" implements-prefix="myjs">
    <![CDATA[

     function getSourceFlags(oTemplatePath, oFilePath, oFileName)
    {
      var path='';
      var name = oFilePath.toLowerCase() + '\\' + oFileName.toLowerCase();
      if (name.indexOf("bluray") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_bluray.png';
      }
      else if (name.indexOf("bdrip") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_bluray.png';
       }
      else if (name.indexOf("dvd") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_dvd.png';
      }
      else if (name.indexOf("web-dl") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_webdl.png';
      }
      else if (name.indexOf("r5") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_r5.png';
      }
      else if (name.indexOf("dvdrip") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_dvd.png';
      }
      else if (name.indexOf("dvdscr") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_dvdscr.png';
      }
      else if (name.indexOf("hdtv") != -1)
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\source_hdtv.png';
      }
      else
      {
        path = oTemplatePath + '\\..\\Common\\SourceFlags\\generic.png';
      }
      return path;
    }
   
     function getTime(oDurationSec, oRuntime, oReq)
    {
      var hours=0;
      var minutes=0;
      var seconds=0;
      var output=0;
     
      if (oDurationSec == 0)
      {
        hours = Math.floor(oRuntime/3600);
        minutes = Math.floor((oRuntime%3600)/60);
        seconds = Math.floor((oRuntime%3600)%60);
      }
      else
      {
        hours = Math.floor(oDurationSec/3600);
        minutes = Math.floor((oDurationSec%3600)/60);
        seconds = Math.floor((oDurationSec%3600)%60);
      }
     
      if(oReq == "hours")
      {
        output = hours;
      }
      else if (oReq == "minutes")
      {
        output = minutes;
      }
      else if (oReq == "seconds")
      {
        output = seconds;
      }
     
      return output;
    }
   

   var Studios = [];

    function trim(oString)
    {
      return oString.replace(/^([\s\t\n]|\&nbsp\;)+|([\s\t\n]|\&nbsp\;)+$/g, '');
    }

    function findStudios(oStudios, oTemplatePath)
    {
      Studios = oStudios.split("/");
      var oFile = new ActiveXObject("Scripting.FileSystemObject");
      var path='';
      for(var i = 0; i < Studios.length; i++)
      {
        path = oTemplatePath + '\\..\\common\\studios\\' + trim(Studios[i]) + '.png';
        if (oFile.FileExists(path))
        {
          return path;
        }
      }
      return '';
    }

   
   function getRatingPercent(oRatingText)
    {
      var numbers = [];
      numbers = oRatingText.split("/");
      return Math.round(100*parseFloat(numbers[0])/parseFloat(numbers[1]));
    }
   
    ]]>

  </msxsl:script>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="//Elements">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <!-- if the value of the %SUBTITLES1% token is not empty-->
      <xsl:if test="//tokens/token[@name='%SUBTITLES1%'] != '' ">
        <ImageElement Name="SubtitlePNG" X="1137" Y="435" Width="18" Height="15" Source="File" Offset="0" MultiPageIndex="-1" NullImageUrl="" UseSourceDpi="False">
          <xsl:attribute name="SourceData">
            <xsl:value-of select="concat($TemplatePath, string('\..\common\images\subtitles.png'))"/>
          </xsl:attribute>
        </ImageElement>
      </xsl:if>
      <xsl:if test="//tokens/token[@name='%EXTERNALSUBTITLES%'] != '' ">
        <ImageElement Name="SubtitlePNG" X="1137" Y="435" Width="18" Height="15" Source="File" Offset="0" MultiPageIndex="-1" NullImageUrl="" UseSourceDpi="False">
          <xsl:attribute name="SourceData">
            <xsl:value-of select="concat($TemplatePath, string('\..\common\images\subtitles.png'))"/>
           </xsl:attribute>
        </ImageElement>
      </xsl:if>
    </xsl:copy>
  </xsl:template>
 
  <xsl:template match="TextElement[@Name='TextAbove']/@Text">
    <xsl:variable name="hours" select="myjs:getTime($DurationSec, $Runtime,'hours')"/>
    <xsl:variable name="minutes" select="myjs:getTime($DurationSec, $Runtime,'minutes')"/>
    <xsl:variable name="seconds" select="myjs:getTime($DurationSec, $Runtime,'seconds')"/>
    <xsl:choose>
      <xsl:when test="($hours > 1)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('HOURS','')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="$hours > 0">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('HOUR','')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="$minutes > 2">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('MINUTES','')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('MINUTE','')"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="TextElement[@Name='HourNumber']/@Text">
    <xsl:variable name="hours" select="myjs:getTime($DurationSec, $Runtime,'hours')"/>
    <xsl:variable name="minutes" select="myjs:getTime($DurationSec, $Runtime,'minutes')"/>
    <xsl:variable name="seconds" select="myjs:getTime($DurationSec, $Runtime,'seconds')"/>
    <xsl:choose>
      <xsl:when test="$hours > 0">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat(string($hours),'')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="Text">
          <xsl:value-of select="concat(string($minutes),'')"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="TextElement[@Name='TextBelow']/@Text">
    <xsl:variable name="hours" select="myjs:getTime($DurationSec, $Runtime,'hours')"/>
    <xsl:variable name="minutes" select="myjs:getTime($DurationSec, $Runtime,'minutes')"/>
    <xsl:variable name="seconds" select="myjs:getTime($DurationSec, $Runtime,'seconds')"/>
    <xsl:choose>
     <xsl:when test="($hours > 0) and ($minutes >= 10)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat($minutes,' ','MINUTES')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="($hours > 0) and ($minutes > 1)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('0',$minutes,' ','MINUTES')"/>
        </xsl:attribute>
      </xsl:when>
     <xsl:when test="($hours > 0) and ($minutes = 1)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('0',$minutes,' ','MINUTE')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="($hours > 0) and ($minutes >= 0)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat($minutes,' ','MINUTE')"/>
        </xsl:attribute>
      </xsl:when>
     <xsl:when test="($hours = 0) and ($seconds >= 10)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat($seconds,' ','SECONDS')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="($hours = 0) and ($seconds > 1)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('0',$seconds,' ','SECONDS')"/>
        </xsl:attribute>
      </xsl:when>
     <xsl:when test="($hours = 0) and ($seconds = 1)">
        <xsl:attribute name="Text">
          <xsl:value-of select="concat('0',$seconds,' ','SECOND')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="Text">
          <xsl:value-of select="concat($seconds,' ','SECOND')"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="TextElement[@Name='TextBelow']">
    <xsl:variable name="hours" select="myjs:getTime($DurationSec, $Runtime,'hours')"/>
    <xsl:variable name="minutes" select="myjs:getTime($DurationSec, $Runtime,'minutes')"/>
    <xsl:variable name="seconds" select="myjs:getTime($DurationSec, $Runtime,'seconds')"/>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <xsl:choose>
        <xsl:when test="$hours >= 1">
          <xsl:choose>
            <xsl:when test="$minutes >= 10">
              <Actions>
                <Stretch Height="18" Width="81" />
              </Actions> 
            </xsl:when>
            <xsl:when test="$minutes >= 2">
              <Actions>
                <Stretch Height="18" Width="81" />
              </Actions>
            </xsl:when>
         <xsl:when test="$minutes = 1">
              <Actions>
                <Stretch Height="18" Width="89" />
              </Actions>
            </xsl:when>
            <xsl:when test="$minutes >= 0">
              <Actions>
                <Stretch Height="18" Width="102" />
              </Actions>
            </xsl:when>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$hours = 0">
          <xsl:choose>
            <xsl:when test="$seconds >= 10">
              <Actions>
                <Stretch Height="18" Width="81" />
              </Actions>
            </xsl:when>
            <xsl:when test="$seconds >= 2">
              <Actions>
                <Stretch Height="18" Width="81" />
              </Actions>
            </xsl:when>
          <xsl:when test="$seconds = 1">
              <Actions>
                <Stretch Height="18" Width="91" />
              </Actions>
            </xsl:when>
            <xsl:when test="$seconds >= 0">
              <Actions>
                <Stretch Height="18" Width="103" />
              </Actions>
            </xsl:when>
          </xsl:choose>
        </xsl:when>
      </xsl:choose>
    </xsl:copy>
  </xsl:template>
 
  <xsl:template match="TextElement[@Name='TextAbove']">
    <xsl:variable name="hours" select="myjs:getTime($DurationSec, $Runtime,'hours')"/>
    <xsl:variable name="minutes" select="myjs:getTime($DurationSec, $Runtime,'minutes')"/>
    <xsl:variable name="seconds" select="myjs:getTime($DurationSec, $Runtime,'seconds')"/>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <xsl:choose>
      <xsl:when test="($hours = 1)">
          <Actions>
            <Stretch Height="13" Width="73" />
          </Actions>
        </xsl:when>
      <xsl:when test="($hours > 1)">
          <Actions>
            <Stretch Height="13" Width="74" />
          </Actions>
        </xsl:when>
        <xsl:when test="($minutes > 0)">
          <Actions>
            <Stretch Height="13" Width="75" />
          </Actions>
        </xsl:when>
      </xsl:choose>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='Subtitle1']/@SourceData">
    <xsl:variable name="Sub1" select="string(//tokens/token[@name='%SUBTITLES1%'])"/>
    <xsl:variable name="ExtSub1" select="string(//tokens/token[@name='%EXTERNALSUBTITLES1%'])"/>
    <xsl:choose>
      <xsl:when test="$Sub1 = '' ">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$ExtSub1,string('.png'))"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$Sub1,string('.png'))"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
 
  <xsl:template match="//ImageElement[@Name='Subtitle2']/@SourceData">
    <xsl:variable name="Sub1" select="string(//tokens/token[@name='%SUBTITLES1%'])"/>
    <xsl:variable name="Sub2" select="string(//tokens/token[@name='%SUBTITLES2%'])"/>
    <xsl:variable name="ExtSub1" select="string(//tokens/token[@name='%EXTERNALSUBTITLES1%'])"/>
    <xsl:variable name="ExtSub2" select="string(//tokens/token[@name='%EXTERNALSUBTITLES2%'])"/>
    <xsl:choose>
      <xsl:when test="($Sub1 = '') and ($ExtSub1 != '') ">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="string('')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="($Sub1 != '') and ($Sub2 = '') and ($ExtSub1 != '') ">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$ExtSub1,string('.png'))"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$Sub2,string('.png'))"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
 
      <xsl:template match="//ImageElement[@Name='Subtitle3']/@SourceData">
    <xsl:variable name="Sub2" select="string(//tokens/token[@name='%SUBTITLES2%'])"/>
    <xsl:variable name="Sub3" select="string(//tokens/token[@name='%SUBTITLES3%'])"/>
    <xsl:variable name="ExtSub1" select="string(//tokens/token[@name='%EXTERNALSUBTITLES1%'])"/>
    <xsl:variable name="ExtSub2" select="string(//tokens/token[@name='%EXTERNALSUBTITLES2%'])"/>
    <xsl:choose>
      <xsl:when test="($Sub2 = '') and ($ExtSub1 != '') ">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="string('')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="($Sub2 != '') and ($Sub3 = '') and ($ExtSub1 != '') ">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$ExtSub1,string('.png'))"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$Sub3,string('.png'))"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='ExternalSub1']/@SourceData">
    <xsl:variable name="Sub1" select="string(//tokens/token[@name='%SUBTITLES1%'])"/>
    <xsl:variable name="Sub2" select="string(//tokens/token[@name='%SUBTITLES2%'])"/>
   <xsl:variable name="Sub3" select="string(//tokens/token[@name='%SUBTITLES3%'])"/>
    <xsl:variable name="ExtSub1" select="string(//tokens/token[@name='%EXTERNALSUBTITLES1%'])"/>
    <xsl:choose>
      <xsl:when test="($Sub1 = '') or ($Sub2 = '')">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="string('')"/>
        </xsl:attribute>
      </xsl:when>
     <xsl:when test="($Sub2 = '') or ($Sub3 = '')">
        <xsl:attribute name="SourceData">
          <xsl:value-of select="string('')"/>
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="SourceData">
          <xsl:value-of select="concat($TemplatePath,string('\..\common\countries\'),$ExtSub1,string('.png'))"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <xsl:template match="//ImageElement[@Name='SourceFlags']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getSourceFlags($TemplatePath,$FilePath,$FileName))"/>
    </xsl:attribute>
  </xsl:template>

 
    <xsl:template match="//ImageElement[@Name='Studio']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:findStudios($STUDIO,$PATH))"/>
    </xsl:attribute>
  </xsl:template>
 
    <xsl:template match="//TextElement[@Name='StudioText']/@Text">
    <xsl:attribute name="Text">
      <xsl:if test="not(contains(string(myjs:findStudios($Studios,$TemplatePath)),'.png'))">
        <xsl:value-of select="string(myjs:findStudios($Studios,$TemplatePath))"/>
      </xsl:if>
    </xsl:attribute>
  </xsl:template>
 
  <xsl:template match="//TextElement[@Name='IMDB Rating']">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <xsl:choose>
        <xsl:when test="myjs:getRatingPercent($RATING) >= 80">
          <xsl:attribute name="StrokeColor">-256</xsl:attribute>
          <xsl:attribute name="ForeColor">-256</xsl:attribute>
        </xsl:when>
        <xsl:when test="myjs:getRatingPercent($RATING) >= 50">
          <xsl:attribute name="StrokeColor">-16777216</xsl:attribute>
          <xsl:attribute name="ForeColor">-2500135</xsl:attribute>
        </xsl:when>
       <xsl:when test="myjs:getRatingPercent($RATING) >= 0">
          <xsl:attribute name="StrokeColor">-1</xsl:attribute>
          <xsl:attribute name="ForeColor">-65536</xsl:attribute>
        </xsl:when>
      </xsl:choose>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>


I just read through this whole thread and couldn't find anything wrong with my scripts. One odd thing though... If I don't define both STUDIOS and Studios at the top of the xlst file Thumbgen gives me errors about undefined variables. I see everyone else just defining it one way or another and I assume it's working for them. Also I see almost everyone with the <Studios Separator=", " MaximumValues="5" /> separator line with the comma not the slash and their .xlst looks like mine.

Why am I having trouble where others aren't??

edit: When there's anything else in the Company field, ie. "Ambush Entertainment, 20th Century Fox", no logo will appear. Alone either will show their logo.

edit2:
Step 1: Open a working Template in Thumbgen Designer
Step 2: Delete a : and save Template
Step 3: Replace the : and save Template
Step 4: YOU GET NO STEP 4! YOU JUST BROKE YOUR TEMPLATE!
Step 5: /suicide

note: when I say the template is broken, I mean that the Studio Search is now broken for that Template.
1.02.21_V.WDLXTV_LIVE-0.5.2.0
leetwanker
DLX'er
 
Posts: 101
Joined: Sat Dec 08, 2012 7:52 am

Re: XSL Support for templates   

Postby leetwanker » Sun Nov 24, 2013 4:52 am

Well, I figured it out. Upon first saving a Template.xml file Thumbgen Designer makes lots of changes to that file. Unfortunately this is one of them:

Code: Select all
   
<Studios Seperator=", " MaximumValues="5" />
                                       TO
<Studios Separator="" MaximumValues="5" ImagesFolder="" DefaultImage="" />
1.02.21_V.WDLXTV_LIVE-0.5.2.0
leetwanker
DLX'er
 
Posts: 101
Joined: Sat Dec 08, 2012 7:52 am

Re: XSL Support for templates   

Postby DevXen » Fri Oct 31, 2014 3:49 am

Wow it looks like this forum has been inactive for quite awhile. which is sad. cause I just recently found thumbGen a few days ago, and it seems great

anyhow, Maybe someone out there will be able to help me.
What i'm trying to get Pics of the actors and possibly their names for my layout.
I read that, that isn't possible. Then I got this great Idea to save all the actors pics into their own folder
and use xsl to match the actor names to the filenames to pull them in.

Then as luck would have it, I found this:
https://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?referrer=http://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?referrer=http://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?referrer=http://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?referrer=http://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?referrer=http://social.msdn.microsoft.com/Forums/en-US/f83fa128-2d0d-4bdc-bfe1-26fbaf6159c7/xsl-and-xml-with-thumbgen?forum=xmlandnetfx


which says:
Code: Select all
I have very little knowledge of xml or xsl sheets. I have been experimenting with a program called Thumbgen to generate movie graphics with pictures of actors. The movie data is 'scraped' by Thumbgen and can then be manipulated by a style sheet and/or an xml document. This first section is a bit of the style sheet where actors names areextracted from a string of names separated by "/" symbols


<xsl:variable name="actorsext" select="string('.jpg')"/>
  <xsl:variable name="actorstext" select="string('')"/>
  <xsl:variable name="lista1" select="//tokens/token[@name='%ACTORS%']"/>
  <xsl:variable name="actor1" select="substring-before($lista1, '/')" /> 
  <xsl:variable name="resto1" select="substring-after($lista1, '/')" />
  <xsl:variable name="lista2" select="$resto1"/>
  <xsl:variable name="actor2" select="substring-before($lista2, '/')" /> 

This second bit is further down the style sheet where the actor image related to the actor name is found in a folder full of jpg's



<xsl:template match="ImageElement[@Name='Actor1']">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
            <xsl:choose>
                <xsl:when test="$actor1 != '' ">
                    <xsl:attribute name="SourceData"><xsl:value-of select="concat($pathvalue,$folderactors,$actor1,$actorsext)"/></xsl:attribute>
                </xsl:when>
            </xsl:choose>
        </xsl:copy>
    </xsl:template>


This is a small bit of the xml sheet where the actor jpg is 'placed' in a larger jpg (1280 x 720)


      <ImageElement Name="Actor1" X="980" Y="44" Width="93" Height="123" Source="File" Offset="0" MultiPageIndex="-1" SourceData="" NullImageUrl="%PATH%\..\Common\cast\NoPhotoAvailable.jpg">

<Actions>
          <Rotate Angle="3" InterpolationMode="HighQualityBicubic" />
        </Actions>

Everything works fine except if I add the last bit - the rotate angle action. When I do that it produces an error message:
"Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added." Is there any way around this problem?



The solution was to change the top part to:
Code: Select all
<xsl:template match="ImageElement[@Name='Actor1']">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>

            <xsl:choose>
                <xsl:when test="$actor1 != '' ">
                    <xsl:attribute name="SourceData"><xsl:value-of select="concat($pathvalue,$folderactors,$actor1,$actorsext)"/></xsl:attribute>
                </xsl:when>
            </xsl:choose>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>



Unfortunately that's all it has in the post, So I don't know what it's missing. or how to setup the $folderactors, or $Pathvalue, or even make it so it pulls pics of Several actors say 10 or 8. and display them next to each other with a space between them.

I've never heard of XSL before i saw it here, and I have some XML experience, though in that regard i usually deal with JSON as far as Web programing goes.

So if anyone is out there that could help me get this working, I would appreciate it.

thank you,
-Dev
DevXen
n00b
 
Posts: 1
Joined: Fri Oct 31, 2014 3:43 am

Previous

Return to ThumbGen

Who is online

Users browsing this forum: No registered users and 1 guest

cron