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 Buhric » Fri Feb 04, 2011 3:15 pm

Hi Dutchee,

Dvd file structure i a bit diferent....
since you have a VIDEO_TS inside the movie folder... you will need to have a "VTS_01_0.jpg" inside that folder for "Current folder" trickles to work...
if you are using a "Parent folder" and want to see all the other thumbnails from the other movies...
you actualy need the "Parent's Parent" template since you need to jump 2 folders up and a "folder.jpg" at the same level as the VIDEO_TS and AUDIO_TS folder

Now since you are using some elses template I don't know which script he's using... thus can't tell you what exactly to change...
Buhric
Global Moderator
 
Posts: 616
Joined: Thu Apr 15, 2010 2:49 pm

Re: XSL Support for templates   

Postby Dutchee » Sat Feb 05, 2011 12:15 am

Hi Buhric,

thanks for your reply. I've passed it on to s1l3nc0r. :)

Grtz,
D.
Dutchee
n00b
 
Posts: 3
Joined: Thu Feb 03, 2011 4:05 pm

Re: XSL Support for templates   

Postby s1l3nc0r » Sat Feb 05, 2011 11:40 am

Hi Buhric. I see Dutchee forwarded a problem we are having with the template I created.
Seems when we don't have a mixed structures movies folder, covertrickle works perfectly.

The problem arises in this situation:
movie 1\movie.mkv
movie 2\movie 2.avi
movie 3\movie 3.mkv
movie 4\movie 4.mkv
movie 5\movie\video_ts\video_ts.ifo
movie 6\movie 6.m2ts
movie 7\movie 7.mkv
all movies have folder.jpg in their folder.

when you create covertrickle for it, movies 1-4 get covertrickle on the sheets, skipping the folder.jpg for movie 5, because it resides in the Video_ts folder.
when you create covertrickle for movie 5, you get no covertrickle at all...

code used inside covertrickle.xslt inside common\scripts folder:
Code: Select all
    /*****************************************************************************/
    /* Trim leading and trailing white spaces from a string                      */
    /*****************************************************************************/
    function trim(oString)
    {
      return oString.replace(/^([\s\t\n]|\&nbsp\;)+|([\s\t\n]|\&nbsp\;)+$/g, '');
    }
   
   
    /*****************************************************************************/
    /* getFolderPathLevel                                                        */
    /* Returns different levels paths for the path provided                      */
    /*****************************************************************************/
    function getFolderPathLevel(oFilePath, Level)
    {
      //Level descripttion
      //example:         oFilePath  =  X:\Level1\Level2\Level3\Level4
      //0=current folder           --> X:\Level1\Level2\Level3\Level4
      //1=Parent folder            --> X:\Level1\Level2\Level3
      //2=Parent's Parent Folder   --> X:\Level1\Level2
      //3=...                      --> X:\Level1
      var oFile = new ActiveXObject("Scripting.FileSystemObject");

      var oPath = ' ';
      if (Level == 0)
      {
        oPath = oFilePath;
      }
      if (Level == 1)
      {
         oPath = oFile.GetParentFolderName(oFilePath);
      }
      if (Level == 2)
      {
        oPath = oFile.GetParentFolderName(oFile.GetParentFolderName(oFilePath));
      }
      if (Level == 3)
      {
        oPath = oFile.GetParentFolderName(oFile.GetParentFolderName(oFile.GetParentFolderName(oFilePath)));
      }
      return oPath;
    }
   
    /*****************************************************************************/
    /* alphabetical                                                              */
    /* Sorts values depending on the Sorting Index                               */
    /*****************************************************************************/
    function alphabetical(a, b){
      var A = a.toLowerCase();
      var B = b.toLowerCase();
      for (var i=0 ; i < A.length ; i++){
        if (i >= B.length)
        {
          return 1;
        }
        if (mySortIndex.indexOf(A.charAt(i)) < mySortIndex.IndexOf(B.charAt(i)))
        {
          return -1;
        }
        if (mySortIndex.indexOf(A.charAt(i)) > mySortIndex.IndexOf(B.charAt(i)))
        {
          return 1;
        }
      }
      return 0;
    }
   
    /*****************************************************************************/
    /* getImagePath                                                              */
    /* Returns the path to the file at the corresponding index                   */
    /* Will return an empty string if index is out of bounds                     */
    /*****************************************************************************/
    function getImagePath(i)
    {
      if((i >= 0) && (i < foundImages.length))
      {
        return foundImages[i];
      }
      else
      {
        return '';
      }
    }
   
    /*****************************************************************************/
    /* getImageByPos                                                             */
    /* Returns the image at the specified thumbnail position in the sheet        */
    /* Will do a Thumbnail rollover if "ThumbsRollOver" = 1                      */
    /* Will only rollover if theres at least "TotalThumbsShown" files detected   */
    /*****************************************************************************/
    function getImageByPos(i)
    {
      if ((myPos+i < foundImages.length) && (myPos+i >= 0))
      {
        return getImagePath(myPos+i);
      }
      else if ((myPos+i >= foundImages.length) && (foundImages.length >= TotalThumbsShown) && (ThumbsRollOver))
      {
        return getImagePath(myPos+i-(foundImages.length*Math.floor((myPos+i)/foundImages.length)));
      }
      else if ((myPos+i < 0) && (foundImages.length >= TotalThumbsShown) && (ThumbsRollOver))
      {
        return getImagePath(myPos+i+(foundImages.length*(1+(Math.floor((Math.abs(myPos+i+1))/foundImages.length)))));
      }
      else
      {
        return '';
      }
    }
   
    /*****************************************************************************/
    /* processSubFolders                                                         */
    /* Detect the "folder.jpg" files at the corresponding folder depth           */
    /* and stores paths into array "foundImages"                                 */
    /* then sorts that array using the WDTV sort index                           */
    /* then detect the position of the current file within the sorted array      */
    /* Trying to merge this function with "processCurrentFolder", so that same   */
    /* function can be called regardless if you are processing a subfolder or a  */
    /* current folder                                                            */
    /*****************************************************************************/
    function processSubFolders(oFilePath, folderJpgName, depth)
    {
      myPath = oFilePath;
      if(oFilePath != '')
      {
        var folderPath = getFolderPathLevel(oFilePath, depth);
        if(folderPath != '')
        {
          var oFile = new ActiveXObject("Scripting.FileSystemObject");
          var oFolder = oFile.GetFolder(folderPath);
          var oSubFolders = oFolder.SubFolders;
          var _result = '';
          if(oSubFolders.Count != 0)
          {
            for(var e= new Enumerator(oSubFolders); !e.atEnd(); e.moveNext())
            {
              if (folderPath.length == 3)
              {
                var _folderJpgPath = folderPath + e.item().Name + '\\' + folderJpgName;
              }
              else
              {
                var _folderJpgPath = folderPath + '\\' + e.item().Name + '\\' + folderJpgName;
              }
              if(oFile.FileExists(_folderJpgPath))
              {
                foundImages.push(_folderJpgPath.toLowerCase());
              }
            }
          }
          foundImages.sort(alphabetical);
          for (var i=0 ; i <= foundImages.length-1; i++)
          {
              if (foundImages[i] == (getFolderPathLevel(myPath,depth-1) + '\\' + 'folder.jpg').toLowerCase())
              {
                myPos = i;
                break;
              }
          }
          return foundImages.toString();
        }
      }
      else
      {
        return 'no reference movie found';
      }
    }



Code used in template.xslt:
Code: Select all
  <xsl:template match="@*|node()">
      <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>
   <xsl:template match="//Elements">
      <xsl:copy>
        <TextElementHidden Name="Debug">
          <xsl:attribute name="Text">
            <xsl:value-of select="string(myjs:processSubFolders($TITLEPATH, $FolderJpgName,1))"/>
          </xsl:attribute>
        </TextElementHidden>
        <TextElementHidden Name="Debug2">
          <xsl:attribute name="Text">
            <xsl:value-of select="''"/>
          </xsl:attribute>
        </TextElementHidden>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>

  <xsl:template match="//ImageElement[@Name='Folder2']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getImageByPos(2))"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='Folder1']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getImageByPos(1))"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='Folder0']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getImageByPos(0))"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='Folder-1']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getImageByPos(-1))"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="//ImageElement[@Name='Folder-2']/@SourceData">
    <xsl:attribute name="SourceData">
      <xsl:value-of select="string(myjs:getImageByPos(-2))"/>
    </xsl:attribute>
  </xsl:template>



The entire template can be downloaded here: http://www.wdtvlive.net/showthread.php?386
s1l3nc0r
WDTVer
 
Posts: 29
Joined: Tue Aug 24, 2010 5:02 am

Re: XSL Support for templates   

Postby Buhric » Sat Feb 05, 2011 2:27 pm

I understand the problem perfectly.

to remedy this you can do the following....
make it so that
movie 5\movie\video_ts\video_ts.ifo

looks more like this
movie 5\video_ts\video_ts.ifo

then manual put a "folder.jpg" inside
movie 5\

This will make movie 5 thumbnail show up in the sheets of the other movies...


then to create the sheet for movie 5 only, you have 2 options....
1. create a "dummy" video_ts.ifo inside folder
movie 5\
and process has usual, skipping the video_ts.ifo inside the VIDEO_TS folder

OR

2. create a new .XSLT which will have this line
Code: Select all
<xsl:value-of select="string(myjs:processSubFolders($TITLEPATH, $FolderJpgName,1))"/>
replaced by this
Code: Select all
<xsl:value-of select="string(myjs:processSubFolders($TITLEPATH, $FolderJpgName,2))"/>

and select this new template for the DVD movies file structure only... but you will still need the "folder.jpg" in the "movie 5\" folder, not inside the VIDEO_TS


I'm pretty sure the script can be modified so that when it detects a VIDEO_TS folder in the movies path name, it goes 1 extra folder up...
but lately, I'm to busy, i'll see if I can fix this up a more "permanent' way....
Buhric
Global Moderator
 
Posts: 616
Joined: Thu Apr 15, 2010 2:49 pm

Re: XSL Support for templates   

Postby Dutchee » Sun Feb 06, 2011 1:58 am

Hi Buhric,

thanks for that. I'll have a go at those options.

Grtz,
D.
Dutchee
n00b
 
Posts: 3
Joined: Thu Feb 03, 2011 4:05 pm

Re: XSL Support for templates   

Postby s1l3nc0r » Wed Mar 02, 2011 7:02 am

Hi everybody, i am currently using the following script to set studio and certification for my tv-show collections (By alucard89):

Functions.xslt:
Code: Select all
var movieName  = ['event','misfits','community','pushing daisies'];
var movieNameS = ['nbc','e4','nbc',''];
var movieNameC = ['','18','tv-pg','12']

    function getStudio(oTemplatePath,oTITLE)
    {
      var Output = '';
      for (var i = 0; i < movieName.length ; i++)
      {
        if (oTITLE.toLowerCase().indexOf(movieName[i]) != -1)
        {
          Output = movieNameS[i] + '.png';
        }
      }
      return Output;
    }


template.xslt:
Code: Select all
  <xsl:template match="//ImageElement[@Name='Studio']/@SourceData">
   <xsl:variable name="Studio1" select="myjs:findStudios($Studios,$TemplatePath)"/>
    <xsl:attribute name="SourceData">
         <xsl:value-of select="($Studio1)"/>      
    </xsl:attribute>
  </xsl:template>
 
   <xsl:template match="//ImageElement[@Name='Studio2']/@SourceData">
   <xsl:variable name="Studio1" select="myjs:findStudios($Studios,$TemplatePath)"/>
   <xsl:variable name="Studio2" select="myjs:getStudio($TemplatePath,$TITLE)"/>
    <xsl:attribute name="SourceData">
      <xsl:if test="not(contains(string($Studio1),'.png'))">
         <xsl:value-of select="concat($TemplatePath,$Common,'studios\',string($Studio2))"/>   
      </xsl:if>      
    </xsl:attribute>
  </xsl:template>


The problem is, that it confuses series with each other, for example:
House -> Bad Hat Harry Productions -> tv-14
Dollhouse -> 20th Century Fox -> TV-MA

When you add these, house will be displayed correctly, but dollhouse will contain the studio and certification provided for house, since it has (doll)house in its name. The same goes for series as criminal intent, csi, ncis, etc.

The script doesn't limit itself to strict full series names, but I really don't have any clue how to fix this...

I hope someone else does...
s1l3nc0r
WDTVer
 
Posts: 29
Joined: Tue Aug 24, 2010 5:02 am

Re: XSL Support for templates   

Postby Buhric » Sun Mar 06, 2011 8:18 am

cahnge your movieName array so that he more "complicated" name come before the "simple" one
like, make sure that DollHouse, come before House

Also you will need to include a break statement in the IF (right after the "Output = ")so that when a match is found it exits out of the For loop

in this case when it going to compare
DollHouse will contain Dollhouse....so it will stop there...
but House will not contain DollHouse... so it will go on searching...
Buhric
Global Moderator
 
Posts: 616
Joined: Thu Apr 15, 2010 2:49 pm

Re: XSL Support for templates   

Postby s1l3nc0r » Mon Mar 07, 2011 9:27 am

Code: Select all
var movieName  = ['event','misfits','community','pushing daisies'];
var movieNameS = ['nbc','e4','nbc',''];
var movieNameC = ['','18','tv-pg','12']

    function getStudio(oTemplatePath,oTITLE)
    {
      var Output = '';
      for (var i = 0; i < movieName.length ; i++)
      {
        if (oTITLE.toLowerCase().indexOf(movieName[i]) != -1)
        {
          Output = movieNameS[i] + '.png';
        }
      }
      return Output;
    }


How would that be added into this script ?
s1l3nc0r
WDTVer
 
Posts: 29
Joined: Tue Aug 24, 2010 5:02 am

Re: XSL Support for templates   

Postby Buhric » Mon Mar 07, 2011 3:23 pm

Buhric wrote:cahnge your movieName array so that he more "complicated" name come before the "simple" one
like, make sure that DollHouse, come before House

Also you will need to include a break statement in the IF (right after the "Output = ")so that when a match is found it exits out of the For loop

can't be more straight forward that this....
here's the code
Code: Select all
var movieName  = ['dollhouse','house','event','misfits','community','pushing daisies'];
var movieNameS = ['whatever for dh','whatever for house','nbc','e4','nbc',''];
var movieNameC = ['wahtever for dh','whateverfor house','','18','tv-pg','12'];

    function getStudio(oTemplatePath,oTITLE)
    {
      var Output = '';
      for (var i = 0; i < movieName.length ; i++)
      {
        if (oTITLE.toLowerCase().indexOf(movieName[i]) != -1)
        {
          Output = movieNameS[i] + '.png';
          break;
        }
      }
      return Output;
    }
Buhric
Global Moderator
 
Posts: 616
Joined: Thu Apr 15, 2010 2:49 pm

Re: XSL Support for templates   

Postby s1l3nc0r » Thu Mar 10, 2011 12:28 pm

Thanks for the explanation Buhric.

Another question (if U don't mind):
Would it be possible to alter the same formula in a way so it takes the exact, complete series name ? Because the formula is still giving problems with series containing characters like ':' or '&'. F.E. in series like NCIS: Los Angeles or Law & Order: Los Angeles. If that would be possible , one could make an alphabetic list (and one wouldn't have to keep in mind that more complicated names have to come before simple names), containing complete names, thus ruling out wrong studio or certification...

Hope to hear from you soon...

Regards S1l3nc0r
s1l3nc0r
WDTVer
 
Posts: 29
Joined: Tue Aug 24, 2010 5:02 am

PreviousNext

Return to ThumbGen

Who is online

Users browsing this forum: No registered users and 1 guest