Kodi Community Forum
[RELEASE] Random and last items smartplaylist script for Skins - 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] Random and last items smartplaylist script for Skins (/showthread.php?tid=122448)



- mikebzh44 - 2012-02-14

Big_Noid Wrote:Don't you already fetch playcount to filter watched/unwatched and resumed items? The script wouldn't run slower then if the option unwatched=true is set?
No, propertie Count is the number of movie in the library/playlist and I don't make the difference between watched or unwatched.

When you set unwatched=True, I only return limit= movies that are unwatched (i.e. playcount > 0).

So I scan movie #1 to movie #Count and if playcount > 0 then I return the movie.

I stop the loop when I reach the end of movies or the number set by limit=

If you want to have the number of unwatched movies, I have to scan all the movies, even if I already have reach the limit= number, to set the unwatched propertie. So I guess the script will be slower.

But I can make a specific version and let you test it.

I will also ask in the JSONRPC thread if a simple way exists.


- mikebzh44 - 2012-02-15

Version 1.0.5 released.

2 new properties added :

Unwatched to get unwatched number of movies in the library or playlist
Watched to get watched number of movies in the library or playlist


- BigNoid - 2012-02-15

Thx for adding those two properties. I do get an error with the latest version:
Code:
16:58:49 T:3360    INFO: -->Python script returned the following error<--
16:58:49 T:3360   ERROR: Error Type: <type 'exceptions.UnboundLocalError'>
16:58:49 T:3360   ERROR: Error Contents: local variable '_movie' referenced before assignment
16:58:49 T:4044   DEBUG: FileCurl::Open(09DFE348) http://mirrors.xbmc.org/addons/eden-pre/addons.xml
16:58:49 T:808    INFO: -->Python script returned the following error<--
16:58:49 T:808   ERROR: Error Type: <type 'exceptions.UnboundLocalError'>
16:58:49 T:808   ERROR: Error Contents: local variable '_movie' referenced before assignment
16:58:49 T:3500   DEBUG: Thread XFILE::CFileCache start, auto delete: 0
16:58:49 T:3360   ERROR: Traceback (most recent call last):
                                              File "C:\Users\XBMC\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 174, in <module>
                                                _getMovies()
                                              File "C:\Users\XBMC\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 72, in _getMovies
                                                _resume = _movie['resume']['position']
                                            UnboundLocalError: local variable '_movie' referenced before assignment
16:58:49 T:3360    INFO: -->End of Python script error report<--
16:58:49 T:808   ERROR: Traceback (most recent call last):
                                              File "C:\Users\XBMC\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 174, in <module>
                                                _getMovies()
                                              File "C:\Users\XBMC\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 72, in _getMovies
                                                _resume = _movie['resume']['position']
                                            UnboundLocalError: local variable '_movie' referenced before assignment
16:58:49 T:808    INFO: -->End of Python script error report<--



- mikebzh44 - 2012-02-15

Yes bad copy/paste.

Passion repository have been updated. Redownload the ZIP and tell me if it's still KO Sad


- mikebzh44 - 2012-02-15

Small problem with parameter resume=True.

Resumed movies are not well trap so let the parameter to false Sad


- BigNoid - 2012-02-15

All good now Smile


- Martijn - 2012-02-15

Got an error with latest script:
http://paste.ubuntu.com/843519/

EDIT:
Happened because I emptied my library and the playlists still exist


- mikebzh44 - 2012-02-16

Martijn Wrote:Got an error with latest script:
http://paste.ubuntu.com/843519/

EDIT:
Happened because I emptied my library and the playlists still exist
I love when user solve the problem by himself Laugh


- Martijn - 2012-02-16

mikebzh44 Wrote:I love when user solve the problem by himself Laugh

Didn't say i fixed it. Just gave you on how to reproduce Cool
The exception should still be caught by the script Wink

Because when you have a certain smartplaylist with some rules you can get an empty list


- fmronan - 2012-02-16

we know, that's for tommorowRolleyes


- mikebzh44 - 2012-02-16

Martijn Wrote:Didn't say i fixed it. Just gave you on how to reproduce Cool
The exception should still be caught by the script Wink

Because when you have a certain smartplaylist with some rules you can get an empty list
Sure.

Bad news, filtering on partially watched movies will be disable on the next version because of a bug in the JSONRPC API :

http://forum.xbmc.org/showpost.php?p=1019599&postcount=1715


- mikebzh44 - 2012-02-16

Version 1.0.6 released

- [Fix] Handle exception when playlist is empty or fetching information failed
- resume= parameter is disable because of a bug in method GetDirectory of JSONRPC API

For resume= option, if method GetDirectory in JSONRPC API couldn't be fixed, I can work around this problem by making a single request for each movie in the playlist/library, but script will be slower :S


- BigNoid - 2012-02-16

We can use the watchlist script for resumed movies. Imo it's better to have a fast script.


- mikebzh44 - 2012-02-16

Yes but watchlist script will not work on playlist. So you won't be able to display a widget showing partially watched movie in playlist Kids as example.

I can make extra request for each movie only if resume is set to True. So script will run as fast as now when resume is set to False.

Because, I don't known if JSONRPC API will be modified : http://forum.xbmc.org/showpost.php?p=1019634&postcount=1716


- mad-max - 2012-02-16

I have some issues with latest version 1.06...

My onload command:

Code:
<onload>XBMC.RunScript(script.randomandlastitems,limit=3,method='Last',playlist='special://skin/playlists/HDMovies.xsp',menu='Menu1')</onload>

Error in Log:

Code:
13:18:28 T:528  NOTICE: -->Python Interpreter Initialized<--
13:18:28 T:528 WARNING: CUtil::GetMatchingSource... no matching source found for ['special://skin/playlists/HDMovies.xsp']
13:18:28 T:528 WARNING: Previous line repeats 4 times.
13:18:28 T:528 WARNING: XFILE::CFactoryDirectory::Create - Unsupported protocol('special) in 'special://skin/playlists/HDMovies.xsp'
13:18:28 T:528   ERROR: Error Type: <type 'exceptions.KeyError'>
13:18:28 T:528   ERROR: Error Contents: ('result',)
13:18:28 T:528   ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 180, in <module>
                                                _getMovies()
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.randomandlastitems\randomandlastitems.py", line 49, in _getMovies
                                                if (json_pl_response['result'] != None) and (json_pl_response['result'].has_key("files")):
                                            KeyError: ('result',)
13:18:30 T:4784   ERROR: Control 1 in window 10099 has been asked to focus, but it can't

Running Beta 3 on Win 7...

Any hint?

cheers,
mad-max


This forum uses Lukasz Tkacz MyBB addons.