Skip to content

script.swan.helper - i am just learning py and cross xbmc usecases

License

Notifications You must be signed in to change notification settings

marduklev/script.swan.helper

Repository files navigation

script.swan.helper

= provide some functions for kodi xml skins

NOTE: i am still learning py and cross xbmc usecases

script actions for skinning skin

action param1
key1=value1
param2
key2=value2
example description
checkexist [required]
file='"a file-, or directory- path"'
[optional]
property=choose name for your property
RunScript(script.swan.helper,action=checkexist,file='"$VAR[extrasLocation_lookup]"',property=propertyname)



RunScript(script.swan.helper,action=checkexist,file='"$VAR[extrasLocation_lookup]"')
check for existence of a specific file or folder


when lookup succeed:

!String.IsEmpty(Window(home).Property(propertyname))
will be True

or

when propertyname is ommitted
!String.IsEmpty(Window(home).Property(filesearch_result))
will be True
get_trailer [required]
fp='an filepath to check for a local trailer'
[optional]
play=True

or

play=Skin.HasSetting(whatever_when true it'll play the trailer)
get_cast=True
RunScript(script.swan.helper,action=get_trailer,fp='$ESCINFO[container.listitem.path]')

optional you can perform a windowed playback, when use
play=True as parameter :

RunScript(script.swan.helper,action=get_trailer,fp='$ESCINFO[container.listitem.path],play=True')
first lookup if local trailer exist

if not check for listitem.trailer,
if listitem trailer empty than perform a youtube* lookup

in any case,if a video is found it store its url as
'window(home).property(listitemtrailer)' infolabel

* youtube lookup will just performed if
Skin.HasSetting(trailer_yt_fallback)
is True
force_musicvideos RunScript(script.swan.helper,action=force_musicvideos) navigates in videos window
and list musicvideos of an artist ( using 'container().listItem.artist' )
for the lookup

if no musicvideos found in the local db it will lookup via youtube plugin use
' container().listItem.artist' official musicvideos'
as the query
encode [required]
string='"Büllebü & Bülleba, or other String to encode"'
[optional]
property=choose name for your property
RunScript(script.swan.helper,action=encode,string='"$VAR[EncodeTitle]"',property=videoinfo_encoded_title)







RunScript(script.swan.helper,action=encode,string='"$VAR[EncodeTitle]"')
encode a string given by an param
to an percent encoded string

which can then be used
via:
$INFO[window(home).Property(paramvalue2)]

or if param 2 is omitted
the result can be returned via
$INFO[window(home).Property(encoded_string)]
playlist_playoffset RunScript(script.swan.helper,action=playlist_playoffset) used to play specific item when current container is filled by either
playlistmusic:https:// or playlistvideo:https://

will need skin integration
as container refresh (without reload.skin() or activate playlistwindow )is a bit cumbersome

use
string.isempty(window(home).property(playlist_updating))" to evalute show playlistmusic:https://
to true
select RunScript(script.swan.helper,action=select) will play specific item or folder, without clearing the current playlist

default = add item or folder to playlist and start play immediatly

if
skin.hassetting([dbtype]_select_queue)

it will just queue the [dbtype]item to next position in playlist

skinsetting possibilitys:
Skin.ToggleSetting(song_select_queue)
Skin.ToggleSetting(album_select_queue)
Skin.ToggleSetting(genre_select_queue)
Skin.ToggleSetting(year_select_queue)
Skin.ToggleSetting(musicvideo_select_queue)
textviewer [required]
header='"I will be The Header"'
[required]
text='"i am the text below the header, you know"'
RunScript(script.swan.helper,action=textviewer,header='"$VAR[ArtistOrTitle]"',text='"$VAR[plot]"')


RunScript(script.swan.helper,action=textviewer,header='$ESCINFO[ListItem.Title]',text='$ESCINFO[ListItem.Plot]"')
opens the textviewer dialog

contextmenu

  • queue the current focused item to either last or next playlistposition - if not in a media window for custom dynamic content containers

  • move playlistitems up/down or remove playlistitem from playlist - when use a dynamic container filled with currently playing playlist (playlistmusic:https:// ; playlistvideo:https://)

    to indicate if a container is used for playlist content you'll need to set a property (playlist_itemcontrol) in the skin so the contextitem for switch playlist items : is just visible if

    string.isequal(window(home).property(playlist_itemcontrol),enable)

    example

     <control type="panel" id="12345">
         <description>dynamic container provide playlistcontent</description>
     	<onfocus>SetProperty(playlist_itemcontrol,enable,home)</onfocus>
     	<onunfocus>ClearProperty(playlist_itemcontrol,home)</onunfocus>
     	.. 
     	<content>$VAR[playlistmusic]</content>
     </control>
     
     <variable name="playlistmusic">
     	<value condition="string.isempty(window(home).property(playlist))">playlistmusic:https://</value>
     	<value>-</value>
     </variable>
    

    the custom container for playlist wont refresh properly till window reload or open playlistwindow, therefore using a variable to toggle between visible states to force a proper refresh n your skin

    the script set a window property ''setproperty(playlist,update,home)'' when do queue,delete or switch functions, which can then be used to refresh the container content by using a variable

  • save currently active playlist : just activates window and send click to control 21 (save button) and set a window property ''setproperty(addon_forcedaction,back,home)'' example

    if you dont wanna move back manually just add following onunload commands to 'dialogkeyboard.xml'

     <onunload condition="String.IsEqual(Window(home).Property(addon_forcedaction),back)">Action(back)</onunload>
     <onunload condition="!String.IsEmpty(Window(home).Property(addon_forcedaction))">ClearProperty(addon_forcedaction,home)</onunload>
    
  • activate playlist window

  • activate the playercontrols dialog

  • play all songs by artis

    if either media window and on '. all albums' listitem entry, or if not media window for artist or album items (clears playlist, and start plaing folder)

TO DO:

  • hide items based upon addon setting
  • playlist save code - look at docs
  • get better diff of current playlist by getting an identifyer - look at docs/jsonrpc get.playlistidentifyer? ( currently just checks if a video is playing, no matter which playlist id is active (its absolutely possible to have video files within a active music playlist, even if rare case))

About

script.swan.helper - i am just learning py and cross xbmc usecases

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published