Kodi Community Forum
[RELEASE] RecentlyAdded Script (RecentlyAdded.py) Recently Added for Skins / Skinners - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
+---- Forum: Skin helper addons (https://forum.kodi.tv/forumdisplay.php?fid=300)
+---- Thread: [RELEASE] RecentlyAdded Script (RecentlyAdded.py) Recently Added for Skins / Skinners (/showthread.php?tid=55907)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14


- Nuka1195 - 2009-08-13

avigrace, that's a bug in xbmc.

for the tv shows error. it is now fixed in svn.

you can show the last played video for movies. if skinners want to use this, i can add it to tv shows also.

Image


- Hitcher - 2009-08-13

Thanks for the TV Shows fix.


- CF2009 - 2009-08-13

hey Nuke
I have added 1 more option to the script i am useing for my aeon mod "random", i use it as i do not add movies/episodes all the time so i get to see a list random unplayed movies/episodes which is nicer then seeing the same movies/episodes all the time. i was just thinking you may like to add it to your script to as a optionSmile

PHP Code:
sql_movies "select * from movieview %sorder by RANDOM() limit %d" % ( unplayedself.LIMIT, ) 
PHP Code:
sql_episodes "select * from episodeview %sorder by RANDOM() limit %d" % ( unplayedself.LIMIT, ) 



- CF2009 - 2009-08-14

one more thing i have just added to my script is the ability to play full albums from the Recently Added script (extras.py).

i'm not using unplayed or songs like yours but you can see how it works...

PHP Code:
# Current Working Directory
CWD os.getcwd() 
PHP Code:
def _fetch_music_infoself ):
        
# sql statement
        
if ( self.RANDOM_ORDER ):
            
sql_music "select * from albumview order by RANDOM() limit %d" % ( self.LIMIT, )
        else:
            
sql_music "select * from albumview order by idAlbum desc limit %d" % ( self.LIMIT, )
        
# query the database for recently added albums
        
music_xml xbmc.executehttpapi"QueryMusicDatabase(%s)" quote_plussql_music ), )
        
# separate the records
        
items re.findall"<record>(.+?)</record>"music_xmlre.DOTALL )
        
# enumerate thru our records and set our properties
        
for countitem in enumerateitems ):
            
# separate individual fields
            
fields re.findall"<field>(.*?)</field>"itemre.DOTALL )
            
# set properties
            
self.WINDOW.setProperty"LatestSong.%d.Genre" % ( count 1, ), fields] )
            
self.WINDOW.setProperty"LatestSong.%d.Year" % ( count 1, ), fields] )
            
self.WINDOW.setProperty"LatestSong.%d.Artist" % ( count 1, ), fields] )
            
self.WINDOW.setProperty"LatestSong.%d.Album" % ( count 1, ), fields] )
            
self.WINDOW.setProperty"LatestSong.%d.Plot" % ( count 1, ), fields14 ] )
            
# Album Path  (ID)
            
path 'XBMC.RunScript(' CWD 'extras.py,albumid=' fields] + ')'
            
self.WINDOW.setProperty"LatestSong.%d.Path" % ( count 1, ), path )
            
# get cache name of path to use for fanart
            
cache_name xbmc.getCacheThumbNamefields] )
            
self.WINDOW.setProperty"LatestSong.%d.Fanart" % ( count 1, ), "special://profile/Thumbnails/Music/%s/%s" % ( "Fanart"cache_name, ) )
            
self.WINDOW.setProperty"LatestSong.%d.Thumb" % ( count 1, ), fields] )

    
def _Play_AlbumselfID ):
        
playlist=xbmc.PlayList(0)
        
playlist.clear()
        
# sql statements
        
sql_song "select * from songview where idAlbum='%s' order by iTrack " % ( ID )
        
# query the databases
        
songs_xml xbmc.executehttpapi"QueryMusicDatabase(%s)" quote_plussql_song ), )
        
# separate the records
        
songs re.findall"<record>(.+?)</record>"songs_xmlre.DOTALL )
        
# enumerate thru our records and set our properties
        
for countmovie in enumeratesongs ):
            
# separate individual fields
            
fields re.findall"<field>(.*?)</field>"moviere.DOTALL )
            
# set album name
            
path fields22 ] + fields]
            
listitem ListItemfields] )
            
xbmc.PlayList(0).add (pathlistitem )
        
xbmc.Player().play(playlist)
        
xbmc.executebuiltin('XBMC.ActivateWindow(10500)'



- andyblac - 2009-08-20

@Nuka1195,

i have managed to get the fanart working for recent episodes. but it relies on the fanart being cached. i remember the the thumbs used to be the same (sometimes thumb not showing up, when no cached thumb exists) is there a anything you can you do with your script so it does the same for fanart.


Andy.


please review this code - ronie - 2009-08-30

i've been looking for a way to run the RecentlyAdded script in a more 'intelligent' way.
Running it everytime you enter the Home Screen if far from ideal, since many users are complaining it temporary locks up xbmc.
Using the new timer function to run the script every 30 minutes might also be overkill, since i only update my library once every few weeks.

Ideally, the script should only run once at startup and for the rest it should only run if the library has been updated.

To accomplish this, i've made the following changes to DialogMusicScan.xml and DialogVideoScan.xml:
[HTML]
<defaultcontrol>1111</defaultcontrol>
....
<control type="button" id="1111">
<posx>-10</posx>
<posy>-10</posy>
<height>1</height>
<width>1</width>
<texturefocus></texturefocus>
<texturenofocus></texturenofocus>
<onfocus>Skin.SetBool(LibraryUpdated)</onfocus>
</control>
[/HTML]

Next, in Startup.xml add a button to set a 'Startup' boolean:
[HTML]
<defaultcontrol always="true">10</defaultcontrol>
....
<control type="button" id="10">
<onfocus>Skin.SetBool(Startup)</onfocus>
<onfocus>ReplaceWindow(Home)</onfocus>
<texturenofocus>-</texturenofocus>
<texturefocus>-</texturefocus>
</control>
[/HTML]

Finally, in Home.xml add three buttons:
[HTML]
<defaultcontrol always="true">5043</defaultcontrol>
....
<control type="button" id="5043">
<description>visible at startup</description>
<posx>-20</posx>
<posy>-20</posy>
<width>1</width>
<height>1</height>
<texturenofocus>-</texturenofocus>
<texturefocus>-</texturefocus>
<onfocus>XBMC.RunScript(special://skin/scripts/RecentlyAdded.py)</onfocus>
<onfocus>Skin.Reset(Startup)</onfocus>
<onfocus>SetFocus(9000)</onfocus>
<visible>Skin.HasSetting(Startup)</visible>
</control>
<control type="button" id="5043">
<description>visible after library update has finished</description>
<posx>-20</posx>
<posy>-20</posy>
<width>1</width>
<height>1</height>
<texturenofocus>-</texturenofocus>
<texturefocus>-</texturefocus>
<onfocus>XBMC.RunScript(special://skin/scripts/RecentlyAdded.py)</onfocus>
<onfocus>Skin.Reset(LibraryUpdated)</onfocus>
<onfocus>SetFocus(9000)</onfocus>
<visible>!Skin.HasSetting(Startup) + Skin.HasSetting(LibraryUpdated) + !Window.IsVisible(112) + !Window.IsVisible(133)</visible>
</control>
<control type="button" id="5043">
<description>visible in all other cases</description>
<posx>-20</posx>
<posy>-20</posy>
<width>1</width>
<height>1</height>
<texturenofocus>-</texturenofocus>
<texturefocus>-</texturefocus>
<onfocus>SetFocus(9000)</onfocus>
<visible>!Skin.HasSetting(Startup) + [!Skin.HasSetting(LibraryUpdated) | [Skin.HasSetting(LibraryUpdated) + [Window.IsVisible(112) | Window.IsVisible(133)]]]</visible>
</control>
[/HTML]

As far as i can tell this works like a charm, but maybe i've missed something?
Any feedback is appreciated.


- Hitcher - 2009-08-30

Sounds a much better way of running it, thanks Ronie I'll give it a go.


- CF2009 - 2009-08-30

nice i did not think of using DialogMusicScan.xml and DialogVideoScan.xml like that...

Will this work if i use suspend as i do not shutdown my MC?
one thing to note is that the watched totals will not update unto you restart


- ronie - 2009-08-30

ronie Wrote:but maybe i've missed something?

i've obviously forgot a way to reset the 'NotStartup' boolean when you quit xbmc. this can by done by adding <onclick>Skin.Reset(NotStartup)</onclick>
to the appropriate buttons (exit/shutdown/restart/reboot) in DialogButtonMenu.xml.....but this won't work for users who bypass the shutdown menu by mapping these functions to their remote.

So, maybe it's better to use something like this instead:
[HTML]<onfocus>SetProperty(NotStartup,1)</onfocus>

<visible>IsEmpty(Window(Home).Property(NotStartup))</visible>[/HTML]

I'll have to do some more testing to check if this would work as expected.

edit:
the easiest way to clear the 'NotStartup' boolean, is doing it at startup.
add this to Startup.xml:

[HTML]
<defaultcontrol always="true">10</defaultcontrol>
....
<control type="button" id="10">
<onfocus>Skin.Reset(NotStartup)</onfocus>
<onfocus>ReplaceWindow(Home)</onfocus>
<texturenofocus>-</texturenofocus>
<texturefocus>-</texturefocus>
</control>
[/HTML]

i've updated the previous post to include this change.



CF2009 Wrote:Will this work if i use suspend as i do not shutdown my MC?

I can't think of any reason why it shouldn't, but there's only one way to find out. ;-)


- mnegrisoli - 2009-11-09

Hi everybody !

I´ve tried to change this script for show in recently added tv show backdrop a Fanart from parent show instead of "stretched" thumb.

How can I do this ?
I suspect that this is the line for this change ....

Code:
self.WINDOW.setProperty( "LatestEpisode.%d.Fanart" % ( count + 1, ), "special://profile/Thumbnails/Video/%s/%s" % ( "Fanart", fanart_cache, ) )

Thanks !


- Hitcher - 2009-11-09

Cheers for bumping this, I'll add it to Alaska.


- Hitcher - 2009-11-09

mnegrisoli Wrote:Hi everybody !

I´ve tried to change this script for show in recently added tv show backdrop a Fanart from parent show instead of "stretched" thumb.

How can I do this ?
I suspect that this is the line for this change ....

Code:
self.WINDOW.setProperty( "LatestEpisode.%d.Fanart" % ( count + 1, ), "special://profile/Thumbnails/Video/%s/%s" % ( "Fanart", fanart_cache, ) )

Thanks !
You'll have to change the skin not the script to get fanart to show.


- mnegrisoli - 2009-11-10

Thanks Hitcher ...

Is the file Includes_Latest_Added.xml ?

Maybe in this line ?

Code:
<control type="image">
    <texture diffuse="home/home_latestaddedtv_small_mask.png">$INFO[Window.Property(LatestEpisode.1.Thumb)]</texture>
                <include>coverVarsTV</include>
    </control>

I´m using Aeon Hiched Wink

Thanks


- Hitcher - 2009-11-10

That looks like the one.

Just change Thumb to Fanart.


- mnegrisoli - 2009-11-10

Cool !

I´m try when in home ....

Thanks again Hitcher !

Hitcher Wrote:That looks like the one.

Just change Thumb to Fanart.