[RELEASE] RecentlyAdded Script (RecentlyAdded.py) Recently Added for Skins / Skinners

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #16
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: lastplayed.jpg]

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Hitcher Offline
Skilled Skinner
Posts: 10,641
Joined: Aug 2007
Reputation: 92
Location: Eastleigh, UK
Post: #17
Thanks for the TV Shows fix.
find quote
CF2009 Offline
Alaska Group
Posts: 289
Joined: Mar 2009
Location: UK
Post: #18
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, ) 

[Image: problem_solved.png]
find quote
CF2009 Offline
Alaska Group
Posts: 289
Joined: Mar 2009
Location: UK
Post: #19
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)'

[Image: problem_solved.png]
(This post was last modified: 2009-08-14 15:16 by CF2009.)
find quote
andyblac Offline
Posting Freak
Posts: 768
Joined: Feb 2009
Reputation: 0
Post: #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.
find quote
ronie Offline
Team-XBMC Member
Posts: 9,097
Joined: Jan 2009
Reputation: 157
Post: #21
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.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not PM or e-mail Team-XBMC members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
(This post was last modified: 2009-08-30 21:55 by ronie.)
find quote
Hitcher Offline
Skilled Skinner
Posts: 10,641
Joined: Aug 2007
Reputation: 92
Location: Eastleigh, UK
Post: #22
Sounds a much better way of running it, thanks Ronie I'll give it a go.
find quote
CF2009 Offline
Alaska Group
Posts: 289
Joined: Mar 2009
Location: UK
Post: #23
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

[Image: problem_solved.png]
find quote
ronie Offline
Team-XBMC Member
Posts: 9,097
Joined: Jan 2009
Reputation: 157
Post: #24
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. ;-)

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not PM or e-mail Team-XBMC members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
(This post was last modified: 2009-08-30 21:56 by ronie.)
find quote
mnegrisoli Offline
Junior Member
Posts: 29
Joined: Jul 2009
Reputation: 0
Location: Brasil / SC
Post: #25
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 !
find quote
Hitcher Offline
Skilled Skinner
Posts: 10,641
Joined: Aug 2007
Reputation: 92
Location: Eastleigh, UK
Post: #26
Cheers for bumping this, I'll add it to Alaska.
find quote
Hitcher Offline
Skilled Skinner
Posts: 10,641
Joined: Aug 2007
Reputation: 92
Location: Eastleigh, UK
Post: #27
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.
find quote
mnegrisoli Offline
Junior Member
Posts: 29
Joined: Jul 2009
Reputation: 0
Location: Brasil / SC
Post: #28
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
find quote
Hitcher Offline
Skilled Skinner
Posts: 10,641
Joined: Aug 2007
Reputation: 92
Location: Eastleigh, UK
Post: #29
That looks like the one.

Just change Thumb to Fanart.
find quote
mnegrisoli Offline
Junior Member
Posts: 29
Joined: Jul 2009
Reputation: 0
Location: Brasil / SC
Post: #30
Cool !

I´m try when in home ....

Thanks again Hitcher !

Hitcher Wrote:That looks like the one.

Just change Thumb to Fanart.
find quote
Post Reply