Author Topic: Watched Stats for DVD Profiler Collection  (Read 5609 times)

Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Watched Stats for DVD Profiler Collection
« on: April 13, 2009, 08:41:54 PM »
Based on a question by xyrano and my reply here, I created the following little XSLT script that analyzes your watched history and groups the profiles by the number of times you have watched them.

In order to use it, you must have recorded a Watched event in DVD Profiler, each time you have watched a DVD. The script supports multiple users and displays the results separately for each user.

Quote from: Sample

User: Myself

# Profiles
% of Owned
Owned
416
100%
Unwatched
7
2%
Watched Once
138
33%
Watched Twice
162
39%
Watched 3+
109
26%

Unlike my own results I posted in the other thread, this script does not distinguish between movies and TV seasons; it is strictly profile-based. If you have made heavy use of boxsets and child profiles, the results may be a little off.

Please note that this is just a quick-shot. You have to do a little work yourself in order to get it working.

  • Save the code below in a file named WatchedStats.xslt.
  • Export your DVD Profiler collection into an XML file. You can omit cast, crew and all other extra stuff to keep the file smaller.
  • Open the XML file with a text editor and insert a <xml-stylesheet> tag referring WatchedStats.xslt right before the <Collection> root tag.
  • Open the modified XML file with IE.

File WatchedStats.xslt:
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:key name="keyUser"
  match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
  use="concat(@FirstName, '|', @LastName)"
/>

<xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/>

<xsl:template match="/">
  <html>
    <head>
      <title>Watched Stats</title>
    </head>
    <body>
      <h1>Watched Statistics</h1>
      <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p>
      <p>Please note: These stats are strictly profile-based.
        If you have made heavy use of boxsets and child profiles, results may be off.</p>
      <xsl:apply-templates
        select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
      />
    </body>
  </html>
</xsl:template>

<xsl:template match="User">
  <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])">
    <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2>
    <table border="1" cellpadding="5">
      <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup>
      <tr>
        <th>&#160;</th>
        <th># Profiles</th>
        <th>% of Owned</th>
      </tr>
      <tr>
        <td>Owned</td>
        <td><xsl:value-of select="$gTotalCount" /></td>
        <td>100%</td>
      </tr>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Unwatched'"/>
        <xsl:with-param name="pMin" select="0"/>
        <xsl:with-param name="pMax" select="0"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Once'"/>
        <xsl:with-param name="pMin" select="1"/>
        <xsl:with-param name="pMax" select="1"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Twice'"/>
        <xsl:with-param name="pMin" select="2"/>
        <xsl:with-param name="pMax" select="2"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched 3+'"/>
        <xsl:with-param name="pMin" select="3"/>
        <xsl:with-param name="pMax" select="999999"/>
      </xsl:call-template>
    </table>
  </xsl:if>
</xsl:template>

<xsl:template name="doCount">
  <xsl:param name="pUserFN"/>
  <xsl:param name="pUserLN"/>
  <xsl:param name="pDisplay"/>
  <xsl:param name="pMin"/>
  <xsl:param name="pMax"/>

  <xsl:variable name="n" select="
    count(/Collection/DVD[CollectionType='Owned' and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &gt;= $pMin and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &lt;=$pMax])
    "/>
  <tr>
    <td><xsl:value-of select="$pDisplay" /></td>
    <td><xsl:value-of select="$n" /></td>
    <td><xsl:value-of select="round($n div $gTotalCount * 100)" />%</td>
  </tr>
</xsl:template>

</xsl:stylesheet>

Insert this line into the exported XML collection file, right before the <Collection> tag. Replace the sample path with your real file path:

Code: [Select]
<?xml-stylesheet type="text/xsl" href="C:\Sample\WatchedStats.xslt"?>

Open the modified XML file with IE.
« Last Edit: April 13, 2009, 11:02:11 PM by goodguy »
Matthias

richierich

  • Guest
Re: Watched Stats for DVD Profiler Collection
« Reply #1 on: April 13, 2009, 09:08:20 PM »
Can you explain
"and insert a <xml-stylesheet> tag referring WatchedStats.xslt"

I got lost at that point

cheers
Rich

Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #2 on: April 13, 2009, 09:22:50 PM »
Can you explain
"and insert a <xml-stylesheet> tag referring WatchedStats.xslt"

I got lost at that point

It is explained in detail at the end of the post.
Matthias

richierich

  • Guest
Re: Watched Stats for DVD Profiler Collection
« Reply #3 on: April 13, 2009, 10:05:09 PM »
Probably just me Matthias, I got this error message

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'file:///C:/Documents and Settings/richard.taylor/My Do...

</xsl:stylesheet>


Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #4 on: April 13, 2009, 10:29:37 PM »
You may have inserted the line at the wrong position. The top of your XML file has to look like below (except that you use your path instead of "C:\Sample"). The question marks are intentional. Also, make sure that you have copied the code exactly as given into the file WatchedStats.xslt.

Code: [Select]
<?xml version="1.0" encoding="windows-1252"?>
<!--DVD Profiler Collection Export-->
<?xml-stylesheet type="text/xsl" href="C:\Sample\WatchedStats.xslt"?>
<Collection>
Matthias

xyrano

  • Guest
Re: Watched Stats for DVD Profiler Collection
« Reply #5 on: April 13, 2009, 10:35:02 PM »
Works great!  :yahoo:  :clap:

Thank you!

Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #6 on: April 13, 2009, 10:40:01 PM »
Works great!  :yahoo:  :clap:

Thank you!

Forgot to mention it in my initial post: You have to post your results of course.  ;D
Matthias

xyrano

  • Guest
Re: Watched Stats for DVD Profiler Collection
« Reply #7 on: April 13, 2009, 10:50:08 PM »
 :hysterical:

... working on it! :)

[edit]
Done!
« Last Edit: April 13, 2009, 11:03:06 PM by xyrano »

Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #8 on: April 13, 2009, 11:00:02 PM »
I already made the first bugfix. The value for "Watched 3+" was calculated wrong and only showed the profiles watched exactly 3 times. This is now corrected.

Please save the updated code for WatchedStats.xslt again to get the (hopefully) correct results.
Matthias

richierich

  • Guest
Re: Watched Stats for DVD Profiler Collection
« Reply #9 on: April 14, 2009, 12:36:39 AM »
All working now, thanks Matthias +1 :thumbup:

Offline Achim

  • Mega Heavy Poster
  • *******
  • Posts: 7179
  • Country: 00
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #10 on: April 16, 2009, 09:09:48 AM »
User: ya_shin

# Profiles
% of Owned
Owned
1630
100%
Unwatched
632
39%
Watched Once
919
56%
Watched Twice
79
5%
Watched 3+
3
0.2%
[/quote]

XML always scares me a bit, so I used Mark's "Database Query" plugin instead...

The count includes parent profiles that "cannot be watched". I use child profiles for TV series (to have better watched-tracking) which increases the unwatched number slightly unproportional.

Yes, I do think I should have rented more and purchased less :P

Offline goodguy

  • Heavy Poster
  • *****
  • Posts: 1464
  • Colleen West never liked the first light of day.
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #11 on: April 16, 2009, 08:08:12 PM »
XML always scares me a bit, so I used Mark's "Database Query" plugin instead...

Huh? I didn't know Mark's program could do that. And the description on his website doesn't indicate it. Could you explain a little?

Yes, I do think I should have rented more and purchased less :P

I do find these numbers a bit surprising. Same with the ones that posted on the other forum. The number of DVDs watched more than once is staggering low.
Matthias

Offline Jimmy

  • Mega Heavy Poster
  • *******
  • Posts: 6756
  • Country: ca
  • Yes this is me...
    • View Profile
Re: Watched Stats for DVD Profiler Collection
« Reply #12 on: April 16, 2009, 08:39:21 PM »
User: Jimmy Simard

# Profiles
% of Owned
Owned
1367
100%
Unwatched
966
71%
Watched Once
382
28%
Watched Twice
17
1%
Watched 3+
2
0%

I watch my movies :laugh:
It's just that I enter the watch info only since december 2007. So the results don't represent at all what I've really watch...

Offline DJ Doena

  • Administrator
  • Mega Heavy Poster
  • *****
  • Posts: 6722
  • Country: de
  • Battle Troll
    • View Profile
    • My Blog
Re: Watched Stats for DVD Profiler Collection
« Reply #13 on: April 16, 2009, 10:20:30 PM »
# Profiles% of Owned
Owned2294100%
Unwatched62527%
Watched Once148065%
Watched Twice1406%
Watched 3+492%
Karsten

Abraham Lincoln once said The trouble with quotes from the internet is that you never know if they're genuine.

my Blog | my DVD Profiler Tools


Offline DJ Doena

  • Administrator
  • Mega Heavy Poster
  • *****
  • Posts: 6722
  • Country: de
  • Battle Troll
    • View Profile
    • My Blog
Re: Watched Stats for DVD Profiler Collection
« Reply #14 on: April 16, 2009, 10:21:31 PM »
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:key name="keyUser"
  match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
  use="concat(@FirstName, '|', @LastName)"
/>

<xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/>

<xsl:template match="/">
  <html>
    <head>
      <title>Watched Stats</title>
    </head>
    <body>
      <h1>Watched Statistics</h1>
      <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p>
      <p>Please note: These stats are strictly profile-based.
        If you have made heavy use of boxsets and child profiles, results may be off.</p>
      <xsl:apply-templates
        select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
      />
    </body>
  </html>
</xsl:template>

<xsl:template match="User">
  <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])">
    <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2>
    <table border="1" cellpadding="5">
      <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup>
      <tr>
        <th>&#160;</th>
        <th># Profiles</th>
        <th>% of Owned</th>
      </tr>
      <tr>
        <td>Owned</td>
        <td><xsl:value-of select="$gTotalCount" /></td>
        <td>100%</td>
      </tr>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Unwatched'"/>
        <xsl:with-param name="pMin" select="0"/>
        <xsl:with-param name="pMax" select="0"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Once'"/>
        <xsl:with-param name="pMin" select="1"/>
        <xsl:with-param name="pMax" select="1"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Twice'"/>
        <xsl:with-param name="pMin" select="2"/>
        <xsl:with-param name="pMax" select="2"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched 3+'"/>
        <xsl:with-param name="pMin" select="3"/>
        <xsl:with-param name="pMax" select="999999"/>
      </xsl:call-template>
    </table>
  </xsl:if>
</xsl:template>

<xsl:template name="doCount">
  <xsl:param name="pUserFN"/>
  <xsl:param name="pUserLN"/>
  <xsl:param name="pDisplay"/>
  <xsl:param name="pMin"/>
  <xsl:param name="pMax"/>

  <xsl:variable name="n" select="
    count(/Collection/DVD[CollectionType='Owned' and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &gt;= $pMin and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &lt;=$pMax])
    "/>
  <tr>
    <td><xsl:value-of select="$pDisplay" /></td>
    <td><xsl:value-of select="$n" /></td>
    <td><xsl:value-of select="round($n div $gTotalCount * 100)" />%</td>
  </tr>
</xsl:template>

</xsl:stylesheet>

I modified it slightly for the BBCode of this forum:

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:key name="keyUser"
  match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
  use="concat(@FirstName, '|', @LastName)"
/>

<xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/>

<xsl:template match="/">
  <html>
    <head>
      <title>Watched Stats</title>
    </head>
    <body>
      <h1>Watched Statistics</h1>
      <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p>
      <p>Please note: These stats are strictly profile-based.
        If you have made heavy use of boxsets and child profiles, results may be off.</p>
      <xsl:apply-templates
        select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User"
      />
    </body>
  </html>
</xsl:template>

<xsl:template match="User">
  <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])">
    <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2>
    [table]
      <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup>
      [tr]
        [td][b]&#160;[/b][/td]
        [td][b]# Profiles[/b][/td]
        [td][b]% of Owned[/b][/td]
      [/tr]
      [tr]
        [td]Owned[/td]
        [td]<xsl:value-of select="$gTotalCount" />[/td]
        [td]100%[/td]
      [/tr]
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Unwatched'"/>
        <xsl:with-param name="pMin" select="0"/>
        <xsl:with-param name="pMax" select="0"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Once'"/>
        <xsl:with-param name="pMin" select="1"/>
        <xsl:with-param name="pMax" select="1"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched Twice'"/>
        <xsl:with-param name="pMin" select="2"/>
        <xsl:with-param name="pMax" select="2"/>
      </xsl:call-template>
      <xsl:call-template name="doCount">
        <xsl:with-param name="pUserFN" select="@FirstName"/>
        <xsl:with-param name="pUserLN" select="@LastName"/>
        <xsl:with-param name="pDisplay" select="'Watched 3+'"/>
        <xsl:with-param name="pMin" select="3"/>
        <xsl:with-param name="pMax" select="999999"/>
      </xsl:call-template>
    [/table]
  </xsl:if>
</xsl:template>

<xsl:template name="doCount">
  <xsl:param name="pUserFN"/>
  <xsl:param name="pUserLN"/>
  <xsl:param name="pDisplay"/>
  <xsl:param name="pMin"/>
  <xsl:param name="pMax"/>

  <xsl:variable name="n" select="
    count(/Collection/DVD[CollectionType='Owned' and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &gt;= $pMin and
      count(Events/Event[EventType='Watched' and
            User/@FirstName=$pUserFN and
            User/@LastName=$pUserLN])
        &lt;=$pMax])
    "/>
  [tr]
    [td]<xsl:value-of select="$pDisplay" />[/td]
    [td]<xsl:value-of select="$n" />[/td]
    [td]<xsl:value-of select="round($n div $gTotalCount * 100)" />%[/td]
  [/tr]
</xsl:template>
</xsl:stylesheet>
Karsten

Abraham Lincoln once said The trouble with quotes from the internet is that you never know if they're genuine.

my Blog | my DVD Profiler Tools