Kodi Community Forum

Full Version: Last Watched Movie/Item
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

In researching options for retrieving the metadata for the movie item or the tv show item that was last watched, the closest I got was this:
http://wiki.xbmc.org/index.php?title=Add...ecentItems

But this shows the items that were last added to the library.
Is there a script or a method that lets me get the items that I watched last?
Thanks MassIV, I read that the .xsp has to be placed in the userdata folder, outside of the skin folder.
Just trying to understand that if I am to build in functionality in my skin, where do I put the .xsp?

Thanks again!
It doesn't matter all that much really. You reference the playlist using the special protocol.

As an example my built in playlists are laid out like this:

Code:
special://skin/playlists/mediatype/playlistname.xsp

Basically anything after skin is your choice. You place the .xsp files into a subfolder of the skin folder.
Thanks Jeroen, sorry for stalking the forums like a hawk on a feeding frenzy.

I created a playlist to give me movies played in the last 2 weeks:
PHP Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
    <name>Movies watched in the last 20 days</name>
    <match>all</match>
    <rule field="lastplayed" operator="inthelast">
        <value>2 weeks</value>
    </rule>

    <limit>4</limit>
    <order direction="descending">playcount</order>
</smartplaylist> 

My question is how to get the results of this playlist?
Couldn't find any infolabel that does that.

Is there an addon that is able to take the results and expose them via InfoLabels?
I take it you want to show only one item?

I guess you could use Gotham's new list filling feature:
http://forum.xbmc.org/showthread.php?tid=176864

to pull the data from the playlist into a list, set the list to be invisible, and then make an infolabel to reference the most recent item in the list.

In short you create a static list, and supply it with your playlist as a data source:

PHP Code:
<content>special://skin/playlists/playlistname.xsp</content> 

and use:

PHP Code:
Container(ID).ListItem(0).Label 

to get the first result in the playlist
Thanks Jeroen!

I implemented a list, however I had to set it to visible for the listitem to show up.

Here's my list control:
PHP Code:
<control type="list" id="939">
            <
visible>true</visible>
            <
width>400</width>
            <
height>80</height>
            <
orientation>vertical</orientation>

        <!-- 
itemlayout and focusedlayout necessary? -->
            <
content>special://skin/SmartPlaylists/LastPlayedMovie.xsp</content>
           
        
</control

and the actual label control that shows the latest movie:
PHP Code:
<control type="label">
            <
width>700</width>
            <
height>90</height>
            <
posx></posx>
            <
posy></posy>
            <
font>XSmall</font>
            <
label>$INFO[Container(939).ListItem(0).Label]</label>
        </
control

Question: the list doesn't update in real-time or maybe I am doing something wrong.
I am running Gotham rc1...
Nevermind. I realized that I was retrieving 4 items from the smart playlist and displaying the latest.

Thanks for the solve!!
A follow-up question:

If I watch a single movie, the list will populate the name of the movie 4 times.
Why?

Here's the code I am using:
PHP Code:
<control type="list" id="939">
            <
visible>true</visible>
            <
width>400</width>
            <
height>80</height>
            <
orientation>vertical</orientation>
            <!-- 
populate list from a playlist? -->
            <
content>special://skin/SmartPlaylists/LastPlayedMovie.xsp</content>
        
</control

The list for recently watched movies:
PHP Code:
<control type="label">
            <
width>700</width>
            <
height>30</height>
            <
font>XSmall</font>
            <
label>$INFO[Container(939).ListItem(0).Label]</label>
        </
control>

        <
control type="label">
            <
width>700</width>
            <
height>30</height>
            <
font>XSmall</font>
            <
label>$INFO[Container(939).ListItem(1).Label]</label>
        </
control>

        <
control type="label">
            <
width>700</width>
            <
height>30</height>
            <
font>XSmall</font>
            <
label>$INFO[Container(939).ListItem(2).Label]</label>
        </
control>

        <
control type="label">
            <
width>700</width>
            <
height>30</height>
            <
font>XSmall</font>
            <
label>$INFO[Container(939).ListItem(3).Label]</label>
        </
control

This is what I get using the code above:
https://www.dropbox.com/s/asbz1n66r2xxak....38.07.png
If I set the smart playlist to return 4 results, how do the results get repeated?

Shouldn't the list be just 2 items and worst case, 2 "undefined" items?
Because it's wrapping the result.

Use this instead -

PHP Code:
<control type="label">
    <
width>700</width>
    <
height>30</height>
    <
font>XSmall</font>
    <
label>$INFO[Container(939).ListItemNoWrap(0).Label]</label>
</
control>

<
control type="label">
    <
width>700</width>
    <
height>30</height>
    <
font>XSmall</font>
    <
label>$INFO[Container(939).ListItemNoWrap(1).Label]</label>
</
control>

<
control type="label">
    <
width>700</width>
    <
height>30</height>
    <
font>XSmall</font>
    <
label>$INFO[Container(939).ListItemNoWrap(2).Label]</label>
</
control>

<
control type="label">
    <
width>700</width>
    <
height>30</height>
    <
font>XSmall</font>
    <
label>$INFO[Container(939).ListItemNoWrap(3).Label]</label>
</
control
Hitcher, you are amazing.