Kodi Community Forum

Full Version: script.toolbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11
okay, seems some demand is there, my impression is:

1) put it into a separate add-on
2) use way one (setting properties) because it´s easier to read and more friendly to non-coders

Will tackle that when i find some free minutes.

Cheers
phil65,

I for one would love to see something like this and yes to add some additional python accessible functions as MassIV suggested. One I would like would be 'FileExists'. I know the need for this has lessened to some degree as a number of former custom image types have made their way into mainline Kodi, but the need to have a blank fallback image for an image control that you check to see if your image loaded is a PITA.

PHP Code:
                <control type="group">
                    <
visible>VideoPlayer.Content(Movies) | VideoPlayer.Content(episodes)</visible><!-- Movies or Tv Episodes -->
                    <
animation effect="fade" time="200">VisibleChange</animation>
                    <
control type="image" id="890"><!-- Use Clearart if available -->
                        <
left>8</left>
                        <
top>496</top>
                        <
width>275</width>
                        <
height>145</height>
                        <
texture>$VAR[PlayerVideoClearart]</texture>
                        <
aligny>bottom</aligny>
                        <
aspectratio>keep</aspectratio>
                    </
control>
                    <
control type="group">
                        <
visible>StringCompare(Control.GetLabel(890),blank.png)</visible>
                        <
control type="image" id="891"><!-- Use Logo if available -->
                            <
left>8</left>
                            <
top>565</top>
                            <
width>276</width>
                            <
height>75</height>
                            <
texture>$VAR[PlayerVideoLogo]</texture>
                            <
aspectratio align="left" aligny="bottom">keep</aspectratio>
                        </
control>
                        <
control type="image"><!-- Fallback to video cover image if no clearart or logo -->
                            <
left>56</left>
                            <
top>460</top>
                            <
width>180</width>
                            <
height>180</height>
                            <
aligny>bottom</aligny>
                            <
texture diffuse="mask-rect.png">$VAR[PlayerVideoCover]</texture>
                            <
aspectratio scalediffuse="false">keep</aspectratio>
                            <
visible>StringCompare(Control.GetLabel(891),blank.png)</visible>
                        </
control>
                    </
control>
                </
control

In the above example each one of the $VAR's has a default value of 'blank.png' which is used in the check in the next image block. Would be really nice to be able to give a script a list of images to check and have it return the first one found. To display one image block with one visible condition has got to be faster and easier to read for the skin coder.

I'm sure if we thought about it, there would be a number of situations like this one that could be handled better than they currently are.

Just my 2c worth
Wyrm
you can use IsEmpty(VideoPlayer.Art(xxx)) (or am i missing something?)
(2014-10-31, 06:07)phil65 Wrote: [ -> ]you can use IsEmpty(VideoPlayer.Art(xxx)) (or am i missing something?)
phil65,

Sorry mate, you're missing something. That would work if you are using something supported by VideoPlayer.Art(xxx), but what happens if there is a art type not supported by Kodi? Or if you wanted to go that extra mile and try to bring in a image that had not been scanned into the DB but was still available in the local directory? For example here is one of my $VAR's

PHP Code:
    <variable name="ListViewVideoLogo">
        <
value condition="!IsEmpty(ListItem.Art(clearlogo)) + [Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes) | Container.Content(movies)]">$INFO[ListItem.Art(clearlogo)]</value>
        <
value condition="!IsEmpty(ListItem.Art(tvshow.clearlogo)) + [Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)]">$INFO[ListItem.Art(tvshow.clearlogo)]</value>
        <
value condition="IsEmpty(ListItem.Art(clearlogo)) + [Container.Content(tvshows) | Container.Content(seasons) | Container.Content(movies)]">$INFO[ListItem.path,,logo.png]</value>
        <
value condition="IsEmpty(ListItem.Art(tvshow.clearlogo)) + [Container.Content(tvshows) | Container.Content(seasons)]">$INFO[ListItem.path,,logo.png]</value>
        <
value condition="IsEmpty(ListItem.Art(clearlogo)) + Container.Content(episodes)">$INFO[ListItem.Path,,../logo.png]</value>
        <
value>blank.png</value
If $INFO[ListItem.Path] has something in it, the $VAR would not be empty and so the IsEmpty would not work (although looking at what I have there, the second last <value> tag would still return something even if nothing there, so a bug on my behalf). Point is I want to make sure I show some graphic on screen, and I want to check thru a list of possible candidates until I find something to display. So from previous example in last message, check all of the possible cleararts, then all of the possible logos and finally just show the icon/thumb if nothing else available.

That's a lot of checks and a lot of code just to make sure something nice is showing on screen (and very likely a lot of time if I get right to the end before I find something to display).

Wyrm
sorry, won´t do that. Directly accessing the disc is something I am very careful with. Skins shouldnt do that IMO because for example it can make NAS drives wake up.
The user should make sure that all wanted artwork is in the database.
(2014-10-31, 01:23)phil65 Wrote: [ -> ]okay, seems some demand is there, my impression is:

1) put it into a separate add-on
2) use way one (setting properties) because it´s easier to read and more friendly to non-coders

Will tackle that when i find some free minutes.

Cheers

Sounds good to me, thanks.
+1 to this.
here it is:
script.toolbox
Documentation will follow in some time. Tongue
nice new feature: blurred background image + average color for nowplaying screen (not 100% ready yet):
https://www.youtube.com/watch?v=jd8QYBia...e=youtu.be
Nice Wink

Can you point somewhere in script's code to look about the functions until you have the documentation ready ?

Cheers
Nessus
(2014-11-10, 02:00)nessus Wrote: [ -> ]Nice Wink

Can you point somewhere in script's code to look about the functions until you have the documentation ready ?

Cheers
Nessus

default.py. script has same stucture as script.extendedinfo.
Code:
01:25:56 T:140707923556096   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: ImageGrab is Windows only
                                            Traceback (most recent call last):
                                              File "/home/ronie/.kodi/addons/script.toolbox/default.py", line 17, in <module>
                                                from Utils import *
                                              File "/home/ronie/.kodi/addons/script.toolbox/resources/lib/Utils.py", line 9, in <module>
                                                from PIL import Image, ImageFilter, ImageGrab, ImageOps
                                              File "/usr/lib/python2.7/dist-packages/PIL/ImageGrab.py", line 22, in <module>
                                                raise ImportError("ImageGrab is Windows only")
                                            ImportError: ImageGrab is Windows only
                                            -->End of Python script error report<--

also keep in mind that PIL currently doesn't work on android at all:
5218 (PR)
(2014-11-10, 02:29)ronie Wrote: [ -> ]
Code:
01:25:56 T:140707923556096   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: ImageGrab is Windows only
                                            Traceback (most recent call last):
                                              File "/home/ronie/.kodi/addons/script.toolbox/default.py", line 17, in <module>
                                                from Utils import *
                                              File "/home/ronie/.kodi/addons/script.toolbox/resources/lib/Utils.py", line 9, in <module>
                                                from PIL import Image, ImageFilter, ImageGrab, ImageOps
                                              File "/usr/lib/python2.7/dist-packages/PIL/ImageGrab.py", line 22, in <module>
                                                raise ImportError("ImageGrab is Windows only")
                                            ImportError: ImageGrab is Windows only
                                            -->End of Python script error report<--

also keep in mind that PIL currently doesn't work on android at all:
5218 (PR)

yes, the ImageGrab() was only for testing and will probably get removed, the blur is intended to be used with an infolabel. (info=blur,id=$INFO[...])
didn´t know about the PIL-on-Android issue though. that´s a pity Sad
(2014-10-31, 08:29)phil65 Wrote: [ -> ]sorry, won´t do that. Directly accessing the disc is something I am very careful with. Skins shouldnt do that IMO because for example it can make NAS drives wake up.
The user should make sure that all wanted artwork is in the database.
phil65,

I would have though you need your NAS to wake up anyway, as you are looking for information on a listitem, thus you are about to play something. But I also understand you reasoning on this as well, so fair enough.

Another suggestion if I may.

It would be nice to be able to call a number of dialogs from within the skin. For example while we can code a custom version of a selection dialog or a yes/no dialog, we have already coded one of these, so why do we need to code it all over again? If I could provide two options to display and have the script return a result with either one of those options or a code to say that the user exited the dialog without choosing an option that would save recoding a yes/no dialog for each instance of a yes/no that I wanted to use.

Finally, love the blur idea. As to Ronie's post about Android not having a working PIL library, could you not just return the image unchanged if you can't find PIL. That way most platforms will have a working blur and when Android issue is sorted, so will they.

Wyrm
(2014-11-10, 10:00)wyrm Wrote: [ -> ]
(2014-10-31, 08:29)phil65 Wrote: [ -> ]sorry, won´t do that. Directly accessing the disc is something I am very careful with. Skins shouldnt do that IMO because for example it can make NAS drives wake up.
The user should make sure that all wanted artwork is in the database.
phil65,

I would have though you need your NAS to wake up anyway, as you are looking for information on a listitem, thus you are about to play something. But I also understand you reasoning on this as well, so fair enough.

Another suggestion if I may.

It would be nice to be able to call a number of dialogs from within the skin. For example while we can code a custom version of a selection dialog or a yes/no dialog, we have already coded one of these, so why do we need to code it all over again? If I could provide two options to display and have the script return a result with either one of those options or a code to say that the user exited the dialog without choosing an option that would save recoding a yes/no dialog for each instance of a yes/no that I wanted to use.

Finally, love the blur idea. As to Ronie's post about Android not having a working PIL library, could you not just return the image unchanged if you can't find PIL. That way most platforms will have a working blur and when Android issue is sorted, so will they.

Wyrm
no, in general you only access your xbmc userdata folder, not your source path.
yesnodialog and selectdialog are already implemented. Example:
Code:
RunScript(script.toolbox,info=yesnodialog,header=Shutdown,text=$LOCALIZE[31149],yesaction=Dialog.Close(all,true)|Quit())
The blur stuff should be used in a senseful way, please don´t clutter your skins with it Smile (depending on source image and blur radius it can take some seconds)
Not sure yet how to deal with the android situation. Will see.
(2014-11-10, 15:03)phil65 Wrote: [ -> ]no, in general you only access your xbmc userdata folder, not your source path.
Sure I get that, it's just if I'm looking thru my video library (userdata folder) it's usually because I'm looking for something to play (My source path), so having my NAS spool up while I'm looking is a positive, not a negative. But, that's my use case and I appreciate that it may not be everyone's use case (or anyone's use case for that matter). Was just a suggestion, move along, nothing to see here ;-)

Quote:yesnodialog and selectdialog are already implemented. Example:
Code:
RunScript(script.toolbox,info=yesnodialog,header=Shutdown,text=$LOCALIZE[31149],yesaction=Dialog.Close(all,true)|Quit())
Cool, will have to go poke thru your script and see what else is lurking there (hopefully my brain will not explode from reading python)
Quote:The blur stuff should be used in a senseful way, please don´t clutter your skins with it Smile (depending on source image and blur radius it can take some seconds)
Not sure yet how to deal with the android situation. Will see.
No such thing as a free lunch, will definitely use this one sparingly. My vertical home menu used to use skin supplied blurred icons to denote depth (icons were coming from the distance and into view), but could not do the same with custom user supplied icons, so I dropped this idea. I instead used a colour diffuse (darker was further away) and made the distant icons smaller. Would be nice to be able to re-add this original idea and still allow for custom icons.

Thanks for working on these scripts, I know my skin has benefited from a number of them.
Wyrm (xTV-SAF)
Pages: 1 2 3 4 5 6 7 8 9 10 11