RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-12
(2014-02-11, 18:45)mikebzh44 Wrote: Sorry but I don't have time to explain all the modifications you have to make.
So, you have to learn about python, look the differences between this script and skin widgets, read JSON wiki or use this script "has is".
Sorry.
No problem Mike, you've helped me alot already..
Thanks for the hints though,
But i have to admit programming pyhton is rather difficult for beginners like me :p
So i decided to open a freelancer project to optimize this script,
https://www.freelancer.com/projects/Python-XML/XBMC-Optimize-randomandlastitems-script.html
If anyone is interested please PM me or go straight to freelancer
thanks
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-12
[quote='denywinarto' pid='1624997' dateline='1392132310']
https://github.com/CutSickAss/skin.ace.val/blob/master/720p/Home.xml
Could you just try this modded python code :
https://www.dropbox.com/s/0cxa6aeqt09gahf/randomandlastitems.py
And edit home.xml to add a new parameter :
Before :
RunScript(script.randomandlastitems,limit=12,method=Last,playlist=$INFO[Skin.String(vpl1.path)],menu=Menu31)
After :
RunScript(script.randomandlastitems,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl1.path)],menu=Menu31)
You have to edit each line in home.xml where the script is called.
Then run XBMC and look if widgets are faster to populate. Statistics will be wrong as number of items will be set to 12, according to limit=12 parameter.
Don't have many time to test this modification as I'm at the office
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-12
Thanks mike but the script won't load, and the log doesn't say anything
I still don't understand what you mean by wrong statistics...
Does it mean the script won't read the entire list ?
Btw what i found made it faster was removing this part
Code: def _watchedOrResume ( _total, _watched, _unwatched, _result, _file ):
global RESUME
global UNWATCHED
_total += 1
_playcount = _file['playcount']
_resume = _file['resume']['position']
# Add Watched flag and counter for episodes
if _playcount == 0:
_file['watched']='False'
_unwatched += 1
else:
_file['watched']='True'
_watched += 1
if (UNWATCHED == 'False' and RESUME == 'False') or (UNWATCHED == 'True' and _playcount == 0) or (RESUME == 'True' and _resume != 0) and _file.get('dateadded'):
_result.append(_file)
return _total, _watched, _unwatched, _result
But it only works for movies, not tvshow
I don't need watched/unwatched property,
So maybe if the script only calls "total" property it could be faster
RE: [RELEASE] Random and last items smartplaylist script for Skins - Martijn - 2014-02-12
seriously, anything wrong with using pastebin.com or the like instead of posting huge text on the forum ?
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-12
(2014-02-12, 16:35)Martijn Wrote: seriously, anything wrong with using pastebin.com or the like instead of posting huge text on the forum ?
Sorry Martijn, i'll post to pastebin next time
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-12
If I want to have statistics displayed on Home menu for custom menu :
I have to scan the entire smart playlist to count how many items are watched or unwatched.
By using the same function Martijn use in skin widget, I think that the script will be faster but as I put a limit on JSON query, JSON will only return 12 items in Ace case, even if smart playlist contains hundreds of movies.
So statistics will be wrong on Home menu for the specific custom menu.
Please user xbmclogs instead of pastebin, pastebin is blocked by my firewall at the office
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-12
(2014-02-12, 16:49)mikebzh44 Wrote: If I want to have statistics displayed on Home menu for custom menu :
I have to scan the entire smart playlist to count how many items are watched or unwatched.
By using the same function Martijn use in skin widget, I think that the script will be faster but as I put a limit on JSON query, JSON will only return 12 items in Ace case, even if smart playlist contains hundreds of movies.
So statistics will be wrong on Home menu for the specific custom menu.
Please user xbmclogs instead of pastebin, pastebin is blocked by my firewall at the office
Ah i see, By statistic you're referring to Total, number of watched and unwatched movies?
Hmm i don't mind excluding that if it makes the script faster...
Here's my log file with your modded script:
http://xbmclogs.com/show.php?id=129871
It doesn't say anything related to your script though...
Btw any chance to mod it so that it excludes watched and unwatched property? :p
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-12
Don't need your log until no script error occured.
Did you have modifie home.xml in order to add stats=False parameter ?
If so, did the widgets are faster to populate ?
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-12
(2014-02-12, 16:56)mikebzh44 Wrote: Don't need your log until no script error occured.
Did you have modifie home.xml in order to add stats=False parameter ?
If so, did the widgets are faster to populate ?
Here's the home.xml
http://xbmclogs.com/show.php?id=129875
The script won't even load, though
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-13
@deny and other "Big library user".
I don't think that this script can be improved as Files.GetDirectory JSONRPC method does not support limits= parameters to reduce results :
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory
BTW, with your library, Deny, and Ace skin, as you use it, I have build a custom menu based on your Action.xsp file and script run in less than 5 seconds :
Code: 11:23:54 T:5512 DEBUG: Random and Last items script: ##### JSON BIG QUERY 4.457s
11:23:54 T:5512 DEBUG: Random and Last items script: ##### GLOBAL STATS DONE 4.465s
11:23:55 T:5512 DEBUG: Random and Last items script: ##### MOVIES PROPERTIES DONE 4.744s
11:23:55 T:5512 DEBUG: Random and Last items script: Loading PlaylistLastMovieMenu31 started at 2014-02-13 11:23:50 and take 4.750s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### JSON BIG QUERY 4.628s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### GLOBAL STATS DONE 4.633s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### MOVIES PROPERTIES DONE 4.832s
11:31:41 T:4464 DEBUG: Random and Last items script: Loading PlaylistLastMovieMenu31 started at 2014-02-13 11:31:36 and take 4.835s
Times are cumulatives so running JSON query for Action.xsp file over entire library take 4,628s, scanning every 1205 movies to see if movie is watched or not, take 0,005s (4,633-4,628) and generating properties for 12 movies take 0,199s.
But, as you told me by MP, you have mod Ace skin to run 30 times the script because you have created 30 custom menus based on 30 smart playlists. As skin run 30 instances of script in parallel, you can understand that it can take a loooong time to load.
Can you try with standard Ace skin and just 4 / 5 custom menus ?
You can also use this randomandlastitems.py code (add some debug log), put XBMC in debug mode and rerun XBMC to see how long each script run :
https://www.dropbox.com/s/0cxa6aeqt09gahf/randomandlastitems.py
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-13
(2014-02-13, 13:00)mikebzh44 Wrote: @deny and other "Big library user".
I don't think that this script can be improved as Files.GetDirectory JSONRPC method does not support limits= parameters to reduce results :
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory
BTW, with your library, Deny, and Ace skin, as you use it, I have build a custom menu based on your Action.xsp file and script run in less than 5 seconds :
Code: 11:23:54 T:5512 DEBUG: Random and Last items script: ##### JSON BIG QUERY 4.457s
11:23:54 T:5512 DEBUG: Random and Last items script: ##### GLOBAL STATS DONE 4.465s
11:23:55 T:5512 DEBUG: Random and Last items script: ##### MOVIES PROPERTIES DONE 4.744s
11:23:55 T:5512 DEBUG: Random and Last items script: Loading PlaylistLastMovieMenu31 started at 2014-02-13 11:23:50 and take 4.750s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### JSON BIG QUERY 4.628s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### GLOBAL STATS DONE 4.633s
11:31:41 T:4464 DEBUG: Random and Last items script: ##### MOVIES PROPERTIES DONE 4.832s
11:31:41 T:4464 DEBUG: Random and Last items script: Loading PlaylistLastMovieMenu31 started at 2014-02-13 11:31:36 and take 4.835s
Times are cumulatives so running JSON query for Action.xsp file over entire library take 4,628s, scanning every 1205 movies to see if movie is watched or not, take 0,005s (4,633-4,628) and generating properties for 12 movies take 0,199s.
But, as you told me by MP, you have mod Ace skin to run 30 times the script because you have created 30 custom menus based on 30 smart playlists. As skin run 30 instances of script in parallel, you can understand that it can take a loooong time to load.
Can you try with standard Ace skin and just 4 / 5 custom menus ?
You can also use this randomandlastitems.py code (add some debug log), put XBMC in debug mode and rerun XBMC to see how long each script run :
https://www.dropbox.com/s/0cxa6aeqt09gahf/randomandlastitems.py
I'm getting some error with that script...
http://xbmclogs.com/show.php?id=130411
Actually i haven't put in all 30 smart playlist codes into home.xml
(Only action movie playlist)
I will try it again once all 30 playlists are there
Btw i think i found a workaround after reading your PM
- remove this part
Code: def _watchedOrResume ( _total, _watched, _unwatched, _result, _file ):
global RESUME
global UNWATCHED
_total += 1
_playcount = _file['playcount']
_resume = _file['resume']['position']
# Add Watched flag and counter for episodes
if _playcount == 0:
_file['watched']='False'
_unwatched += 1
else:
_file['watched']='True'
_watched += 1
if (UNWATCHED == 'False' and RESUME == 'False') or (UNWATCHED == 'True' and _playcount == 0) or (RESUME == 'True' and _resume != 0) and _file.get('dateadded'):
_result.append(_file)
return _total, _watched, _unwatched, _result
This will make movie playlists load faster, but it broke tvshow playlist
So what if we use separate randomandlastitem.py script with different name for tvshow?
Let's call it randomandlastitem2, which is the unmodified version of your script
So in home.xml it will be like this maybe :
Code: <!-- Ace -->
<window id="0">
<!--<defaultcontrol always="true">9000</defaultcontrol>-->
<allowoverlay>no</allowoverlay>
<include condition="!Skin.HasSetting(welcomedone5)">Startup</include>
<include condition="!Skin.HasSetting(fix5)">Quickfix</include>
<onunload condition="Skin.HasSetting(submode)">Close</onunload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl1.path)) + SubString(skin.string(mfvpl1_list),latest)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl1.path)],menu=Menu31)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl1.path)) + SubString(skin.string(mfvpl1_list),random)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Barat.xsp,menu=Menu31, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl2.path)) + SubString(skin.string(mfvpl2_list),latest)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl2.path)],menu=Menu32)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl2.path)) + SubString(skin.string(mfvpl2_list),random)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Asia.xsp,menu=Menu32, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl3.path)) + SubString(skin.string(mfvpl3_list),latest)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl3.path)],menu=Menu33)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl3.path)) + SubString(skin.string(mfvpl3_list),random)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Anime.xsp,menu=Menu33, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),latest)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl4.path)],menu=Menu34)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),random)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Serial_Barat.xsp,menu=Menu34, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl5.path)) + SubString(skin.string(mfvpl5_list),latest)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl5.path)],menu=Menu35)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl5.path)) + SubString(skin.string(mfvpl5_list),random)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Serial_Asia.xsp,menu=Menu35, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl6.path)) + SubString(skin.string(mfvpl6_list),latest)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(vpl6.path)],menu=Menu36)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl6.path)) + SubString(skin.string(mfvpl6_list),random)">RunScript(script.randomandlastitems2,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Recommended_Serial_Anime.xsp,menu=Menu36, daemon=True)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(fav101.path)) + SubString(skin.string(mfvpl101_list),latest)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Last,playlist=$INFO[Skin.String(fav101.path)],menu=Menu101)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(fav101.path)) + SubString(skin.string(mfvpl101_list),random)">RunScript(script.randomandlastitems,limit=12,stats=False,method=Random,playlist=special://masterprofile/playlists/video/Film_Action.xsp,menu=Menu101, daemon=True)</onload>
<onload condition="Player.HasAudio + System.HasAddon(script.artistslideshow)">RunScript(script.artistslideshow, daemon=True)</onload>
<onload condition="System.HasAddon(script.favourites) + SubString(skin.string(favourites.menu),on)">RunScript(script.favourites)</onload>
<controls>
<control type="multiimage" id="5043"><!-- Extra Fanart Song -->
<include>InvisibleButton</include>
<imagepath background="true">$INFO[Player.FolderPath,,../extrafanart/]</imagepath>
<visible>Player.HasAudio</visible>
</control>
<control type="multiimage" id="5044"><!-- Extra Fanart Artist -->
<include>InvisibleButton</include>
<imagepath background="true">$INFO[Skin.String(CustomMusicLogoPath)]$INFO[MusicPlayer.Artist,,/extrafanart/]</imagepath>
<visible>Player.HasAudio + IsEmpty(Control.GetLabel(5043))</visible>
</control>
<control type="multiimage">
<include>HomeBG</include>
<imagepath background="true">$INFO[Container(9000).ListItem.Icon]</imagepath>
</control>
<include>LiveBG</include>
<control type="group"><!-- default group -->
<include>Animation_Window</include>
<include condition="SubString(skin.string(menu_mode),alphabet)">MenuV</include>
<include condition="SubString(skin.string(menu_mode),genre)">MenuG</include>
<include>BGBlack</include>
</control>
</controls>
</window>
vpl4, vpl5, vpl6 are tvshows smart playlists, and they use randomandlastitem2.py
Is this possible?
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-13
So, at the moment, how many custom menus based on Movies smart playlists did you have ? How many custom menus based on TV Shows smart playlists did you have ?
I'm not sure _watchedOrResume function is the clue as this function only read JSON query result. For me, it's JSON query with XSP file that take the longest time to run.
And the error given in your log file are not related to movie part script where I add debug log. And there is no trace of running script for movies ?!
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-13
(2014-02-13, 14:11)mikebzh44 Wrote: So, at the moment, how many custom menus based on Movies smart playlists did you have ? How many custom menus based on TV Shows smart playlists did you have ?
I'm not sure _watchedOrResume function is the clue as this function only read JSON query result. For me, it's JSON query with XSP file that take the longest time to run.
And the error given in your log file are not related to movie part script where I add debug log. And there is no trace of running script for movies ?!
So i plan to have 2 switchable main menus, Alphabet-based and Genre Based
I'm testing the main page for genre right now,
What i showed you in PM is the Genre menu
and only 1 playlist is active, (Action)
The thing is, in home.xml there are 4 playlists for Movies and 3 for Tv shows
I guess they are executed when the skin launches, so..
that makes it 7 smart playlists
Hmm that's strange, i tested it again and there's no error,
but i don't see any time information??
http://xbmclogs.com/show.php?id=130428
And this time it's faster btw
RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2014-02-13
With your MyVideos75.db, yours XSP files and your guisettings.xml, I can run XBMC the same way you do.
On my laptop PC at my office (Core [email protected] GHz - 4 Gb RAM but Win7 32bits so only 3 Gb available) from starting XBMC from desktop to getting all widgets populated, it took only 31 sec.
The only way to speed (a little) the script is to use smart playlist based on episodes and not on TV shows but when you enter custom menu based on episode smart playlists, you see only episodes, not TV shows and seasons :S
Or you can build 2 smart playlists for each menu : one based on TV shows for the custom menu action and one based on episodes for the widget. But I don't think that Ace cant handle one smart playlist for menu action and another for widget. Or you will have to edit home.xml to call the script with the right playlist :
guisettings.xml :
Code: <setting type="string" name="skin.ace.vpl4.path">special://profile/playlists/video/Serial_Barat.xsp</setting>
home.xml :
Code: <onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),latest)">RunScript(script.randomandlastitems,limit=12,method=Last,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xsp,menu=Menu34)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),random)">RunScript(script.randomandlastitems,limit=12,method=Random,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xspmenu=Menu34)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),inprogress)">RunScript(script.randomandlastitems,limit=12,resume=True,method=Last,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xsp,menu=Menu34)</onload>
I cannot speed up the script by removing _watchedOrResume function. Because you are using TV Shows smart playlist, JSON query return only TV Shows informations. So for gettings latest or random episodes from TV Shows smart playlist, the script have to execute extra JSON queries to get informations about seasons and episodes for each TV shows returned by first JSON query.
So, I think you have to deal with it (or by a more powerfull HTPC ). And I think that when you will create your 30 custom menus based on 30 smart playlists, you will create a huge trafic jam with JSON query
RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2014-02-13
(2014-02-13, 16:51)mikebzh44 Wrote: With your MyVideos75.db, yours XSP files and your guisettings.xml, I can run XBMC the same way you do.
On my laptop PC at my office (Core [email protected] GHz - 4 Gb RAM but Win7 32bits so only 3 Gb available) from starting XBMC from desktop to getting all widgets populated, it took only 31 sec.
The only way to speed (a little) the script is to use smart playlist based on episodes and not on TV shows but when you enter custom menu based on episode smart playlists, you see only episodes, not TV shows and seasons :S
Or you can build 2 smart playlists for each menu : one based on TV shows for the custom menu action and one based on episodes for the widget. But I don't think that Ace cant handle one smart playlist for menu action and another for widget. Or you will have to edit home.xml to call the script with the right playlist :
guisettings.xml :
Code: <setting type="string" name="skin.ace.vpl4.path">special://profile/playlists/video/Serial_Barat.xsp</setting>
home.xml :
Code: <onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),latest)">RunScript(script.randomandlastitems,limit=12,method=Last,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xsp,menu=Menu34)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),random)">RunScript(script.randomandlastitems,limit=12,method=Random,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xspmenu=Menu34)</onload>
<onload condition="System.HasAddon(script.randomandlastitems) + !IsEmpty(skin.string(vpl4.path)) + SubString(skin.string(mfvpl4_list),inprogress)">RunScript(script.randomandlastitems,limit=12,resume=True,method=Last,playlist=special://profile/playlists/video/Serial_Barat_Episodes.xsp,menu=Menu34)</onload>
I cannot speed up the script by removing _watchedOrResume function. Because you are using TV Shows smart playlist, JSON query return only TV Shows informations. So for gettings latest or random episodes from TV Shows smart playlist, the script have to execute extra JSON queries to get informations about seasons and episodes for each TV shows returned by first JSON query.
So, I think you have to deal with it (or by a more powerfull HTPC ). And I think that when you will create your 30 custom menus based on 30 smart playlists, you will create a huge trafic jam with JSON query
Thanks for the tips Mike, i'll try running it on better system,
Right now mine runs on Win server 2008 Core 2 duo 2.46 Ghz at 2GB ram
So it depends on ram?
I can't imagine how long it takes if i put in 30 playlists lol
Since it's impossible to improve this script for huge library...
I guess the other options are :
- Wait till the directory listing you mentioned before gets properly implemented
- Maybe someday XBMC will allow us to create multiple libraries?
Would that solve this problem?
I hope the developers are looking to this problem
|