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)



RE: [RELEASE] Random and last items smartplaylist script for Skins - Mudislander - 2015-03-19

Cool! Personally I think it's faster than dynamic content.

One issue ATM is script doesn't seem to like the sort method "Playlist" but need to check it out a bit further before I say too much - Could be me.


RE: [RELEASE] Random and last items smartplaylist script for Skins - denywinarto - 2015-05-20

(2015-03-19, 16:13)Mudislander Wrote: Cool! Personally I think it's faster than dynamic content.

One issue ATM is script doesn't seem to like the sort method "Playlist" but need to check it out a bit further before I say too much - Could be me.

How big is your library?
i used this but it was too laggy for multiple playlists...
and mike recomended me to use dynamic content...
If this is faster than dynamic content then i guess i'm going back to this lol

Also mike, i think skinshortcut script still cant completely replace your script because it cant sort playlist content based on recently added date like your script does..
(At least i havent found a method to do it)
I will try this again on Kodi and Isengard (once the alpha is out) hopefully the performance is better on newer xbmc

Edit : Looks like it works on smart playlist http://forum.kodi.tv/showthread.php?tid=227433


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-04

Hello,

I have this error using the script with SmartPlaylist (Kodi15+AeonMQ5):

Code:
14:13:37 T:140316753450752   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.KeyError'>
                                            Error Contents: ('playcount',)
                                            Traceback (most recent call last):
                                              File "/var/lib/kodi/.kodi/addons/script.randomandlastitems/randomandlastitems.py", line 848, in <module>
                                                _getMovies()
                                              File "/var/lib/kodi/.kodi/addons/script.randomandlastitems/randomandlastitems.py", line 129, in _getMovies
                                                _playcount = _movie['playcount']
                                            KeyError: ('playcount',)
                                            -->End of Python script error report<--

Any idea?


RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-05

At least, one of your movie don't have a playcount value in Kodi database.

You can edit /var/lib/kodi/.kodi/addons/script.randomandlastitems/randomandlastitems.py
Go to line 129 to find code
Code:
_playcount = _movie['playcount']
Replace it by
Code:
_playcount = _movie.get('playcount','0')

If it's fix your issue, I will push a new release Wink


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-05

Thanks, but new error:

Code:
18:45:24 T:140113357846272   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.KeyError'>
                                            Error Contents: ('dateadded',)
                                            Traceback (most recent call last):
                                              File "/var/lib/kodi/.kodi/addons/script.randomandlastitems/randomandlastitems.py", line 847, in <module>
                                                _getMovies()
                                              File "/var/lib/kodi/.kodi/addons/script.randomandlastitems/randomandlastitems.py", line 156, in _getMovies
                                                _result = sorted(_result, key=itemgetter('dateadded'), reverse=True)
                                            KeyError: ('dateadded',)
                                            -->End of Python script error report<--



RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-06

Don't know. I have try with Kodi 15.0 + Aeon Madnox and everything work fine.

This is how the script is call by the skin (look into your guisettings.xml to find how Aeon MQ5 do) :

Code:
RunScript(script.randomandlastitems,type=Movie,playlist=special://profile/playlists/video/Parents-Widget.xsp,method=Last,limit=10,unwatched=False,resume=False,property=SmartPlaylist1)

BTW, Aeon MQ5 is not designed for Isengard, am I wrong ? You should run Aeon MQ6.


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-06

Hi,

No they released a MQ5 isengard version.

I found this in .kodi/addons/skin.aeonmq5.isengardmod/720p/includes.xml:

Code:
<onload condition="SubString(skin.string(menu1.master),vpl) + SubString(skin.string(mfvpl1_list),latest)">RunScript(script.randomandlastitems,limit=12,method=Last,playlist=$INFO[Skin.String(menu1.path)],menu=vpl1)</onload>
<onload condition="SubString(skin.string(menu1.master),vpl) + SubString(skin.string(mfvpl1_list),random)">RunScript(script.randomandlastitems,limit=12,method=Random,playlist=$INFO[Skin.String(menu1.path)],menu=vpl1)</onload>
<onload condition="SubString(skin.string(menu1.master),vpl) + SubString(skin.string(mfvpl1_list),inprogress)">RunScript(script.randomandlastitems,limit=12,resume=True,method=Last,playlist=$INFO[Skin.String(menu1.path)],menu=vpl1)</onload>

I don't know if I was clear enough, but the script works fine when using the all video library, but not with SmartPlaylist.

Thanks,


RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-06

And in .kodi/userdata/guisettings.xml ?


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-06

I found nothing about your script, in guisettings.xml


RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-06

OK maybe Aeon MQ5 work differently than Aeon Shednox or Aeon Madnox.

Could you edit .kodi/addons/script.randomandlastitems/randomandlastitems.py
Go to line 154 and add print("##### _RESULT=", _result) after.

Code before editing :

Code:
_count = 0
        if METHOD == 'Last':
            _result = sorted(_result, key=itemgetter('dateadded'), reverse=True)

Code after editing :

Code:
_count = 0
        print("##### _RESULT=", _result)
        if METHOD == 'Last':
            _result = sorted(_result, key=itemgetter('dateadded'), reverse=True)

TAKE CARE OF INDENTATION !! On the forum, the first line of code is left aligned but in python code is not.

Then run Kodi, get the error and close Kodi.

And look into kodi.log for line(s) starting with :

Code:
16:17:20 T:11244  NOTICE: ('##### _RESULT=',

Paste those lines here.


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-06

Here you go.

I only pasted the first two idems, as the library is big.

I see the 'dateadded' attribute...

Code:
16: 30: 46T: 139755400787712NOTICE: ('#####_RESULT=',
[
    {
        u'art': {
            
        },
        u'title': u'',
        u'filetype': u'directory',
        u'label': u'Films',
        u'file': u'special: //profile/playlists/video/Films.xsp',
        u'type': u'unknown'
    },
    {
        u'rating': 0.0,
        u'art': {
            u'fanart': u'image: //%2fvar%2flib%2fkodi%2fxbmc_videodb_2015-06-04%2fmovies%2f3_Days_to_Kill_2014-fanart.jpg/',
            u'poster': u'image: //%2fvar%2flib%2fkodi%2fxbmc_videodb_2015-06-04%2fmovies%2f3_Days_to_Kill_2014-poster.jpg/'
        },
        u'filetype': u'file',
        u'file': u'nfs: //192.168.5.250/volume1/Videos/_FILMS/3.days.to.kill.(2014).mkv',
        u'year': 2014,
        u'id': 1,
        u'plot': u"Ethan Renner est un redoutable agent secret r\xe9solu \xe0 renoncer \xe0 sa vie
tr\xe9pidante pour se rapprocher enfin de sa femme et sa fille, qu'il a longtemps tenues \xe0 distance pour les prot\xe9ger. Lorsqu\u2019on lui impose une ultime mission, il doit
mener de front les deux combats les plus difficiles de sa carri\xe8re : traquer un dangereux terroriste et s'occuper de sa fille adolescente pour la premi\xe8re fois depuis dix an
s\u2026",
        u'title': u'3DaystoKill',
        u'tagline': u'',
        u'label': u'3DaystoKill',
        u'type': u'movie',
        u'streamdetails': {
            u'video': [
                
            ],
            u'audio': [
                
            ],
            u'subtitle': [
                
            ]
        },
        u'plotoutline': u"Ethan Renner est un redoutable agent secret r\xe9solu \xe0 renoncer \xe0 sa vie tr\xe9pidante pour se rapprocher enfin de sa femme et sa fille, qu'il a longtemps tenues \x
e0 distance pour les prot\xe9ger. Lorsqu\u2019on lui impose une ultime mission, il doit mener de front les deux combats les plus difficiles de sa carri\xe8re : traquer un dangereu
x terroriste et s'occuper de sa fille adolescente pour la premi\xe8re fois depuis dix ans\u2026",
        u'resume': {
            u'position': 0.0,
            u'total': 0.0
        },
        u'director': [
            u'JosephMCGINTYNICHOL'
        ],
        u'studio': [
            
        ],
        u'genre': [
            u'Action',
            u'Thriller'
        ],
        u'dateadded': u'2014-10-2309: 38: 16',
        u'country': [
            
        ],
        u'lastplayed': u'',
        u'originaltitle': u'3DaystoKill',
        u'mpaa': u'France: -10',
        u'playcount': 0,
        u'runtime': 7320,
        u'trailer': u'http: //fr.vid.web.720p.acsta.net/nmedia/33/14/01/29/18/19542193_hd_013.mp4'
    },



RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-06

But I do have some elements, where dateadded is missing, like the playlist it self.


RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-07

Could you share your XSP file ?

Because the first item :

Code:
[
    {
        u'art': {
            
        },
        u'title': u'',
        u'filetype': u'directory',
        u'label': u'Films',
        u'file': u'special: //profile/playlists/video/Films.xsp',
        u'type': u'unknown'
    },

make me think that you are using a smart playlist based on smart playlists.

With my smart playlists and my script, all my items returned are like the second one.


RE: [RELEASE] Random and last items smartplaylist script for Skins - ferllings - 2015-08-07

Well done, that was it!

it was not based on other SmartPlaylist, but on Virtual Folder.
So I guess this is the same.

Now it's based on path, and it's working better.

Thanks a lot for your patience.


RE: [RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2015-08-07

Great !!!