Kodi Community Forum

Full Version: InfoDialog current playing media in home?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I wonder if there is a way to get the music/video-infodialog of the currently playing video/song when in home.xml.
I was thinking of a hiddenlist, but I don't know which content path to use?

When using a ..playlist:// path i only get the full playlist:

xml:
<control type="list" id="999999">
    <width>500</width>
    <height>500</height>
    <orientation>vertical</orientation>
    <itemlayout height="36" width="1000">
        <control type="label">
            <label>$INFO[ListItem.Label]</label>
        </control>
    </itemlayout>
    <focusedlayout height="36" width="1000">
        <control type="label">
            <label>$INFO[ListItem.Label]</label>
        </control>
    </focusedlayout>
    <content>playlistmusic://</content>
</control>

Using a button, that sets the focus and calls info action works fine so far and info dialog gets shown:

xml:
<control type="button">
    <width>48</width>
    <height>48</height>
    <label/>
    <font />
    <texturefocus colordiffuse="$VAR[ColorHighlight]" flipx="true">osd/info.png</texturefocus>
    <texturenofocus colordiffuse="Dark2" flipx="true">osd/info.png</texturenofocus>
    <onclick>SetFocus(999999)</onclick>
    <onclick>Info</onclick>
</control>

But i have no idea, how to limit the playlist to the current playing item...

Anyone have an idea?
What's wrong with using MusicPlayer.xxx and VideoPlayer.xxx infos?
(2023-03-13, 18:11)Hitcher Wrote: [ -> ]What's wrong with using MusicPlayer.xxx and VideoPlayer.xxx infos?

Maybe I'm misunderstanding you, but I just wanted to use DialogVideoInfo.xml/DialogMusicInfo.xml dialog for that.
<content limit="1">playlistmusic://</content>
(2023-03-13, 18:46)Hitcher Wrote: [ -> ]<content limit="1">playlistmusic://</content>

I have already tried that too. It works until the next song is played.  Confused Because already played songs are not removed from the playlist. Sortby options also not work...
i use a hidden list, to get the info, and anoptional button to open dialogs

list
xml:

<control type="list" id="6999">
                <description>getinfo</description>
                <include>HiddenContainer</include>
                <onup>600</onup>
                <ondown>600</ondown>
                <onleft>600</onleft>
                <onright>600</onright>
                <ondown>600</ondown>
                <content limit="1">$VAR[CurrentlyPlayingItem]</content>
            </control>


content variable, example just if playing db item, currently unsure about addon paths
xml:

<variable name="CurrentlyPlayingItem">
        <value condition="player.hasaudio + !String.IsEmpty(musicplayer.dbid)">musicdb://songs/?
songid=$INFO[musicplayer.dbid]</value>
        
        <value condition="player.hasvideo + videoplayer.content(movies)">videodb://movies/titles/?

xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22title%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22$INFO[Player.Title]%22%5D%7D%5D%7D%2C%22type%22%3A%22movies%22%7D</value>
        <!-- <value condition="videoplayer.content(movies) + [!System.GetBool(videolibrary.groupmoviesets) | [System.GetBool(videolibrary.groupmoviesets) + String.IsEmpty(videoplayer.SetId)]]">videodb://movies/titles/$INFO[videoplayer.dbid]</value> -->
        
        <!-- <value condition="player.hasvideo + videoplayer.content(movies)">videodb://movies/titles/?

xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22title%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22$INFO[Player.Title]%22%5D%7D%5D%7D%2C%22type%22%3A%22movies%22%7D</value> -->
        <value condition="player.hasvideo + videoplayer.content(episodes)">videodb://tvshows/titles/-1/-1/?
xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22title%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22$INFO[Player.Title]%22%5D%7D%5D%7D%2C%22type%22%3A%22episodes%22%7D</value>
    </variable>

button action to open info
xml:

<control type="button" id="6011">
                        <visible>!Container(6999).IsUpdating + Integer.IsEqual(Container(6999).NumItems,1)</visible>
                        <centertop>50%</centertop>
                        <width>45</width>
                        <height>45</height>
                        <label />
                        <texturefocus colordiffuse="$VAR[color_osdmusic_accent]">buttons/osd/infonoborder.png</texturefocus>
                        <texturenofocus colordiffuse="$VAR[color_osdmusic_secondary]">buttons/osd/infonoborder.png</texturenofocus>
                        <!-- <onclick condition="player.hasvideo">ActivateWindow(fullscreeninfo)</onclick> -->
                        <!-- not done <onclick condition="player.hasaudio">ActivateWindow(songinformation)</onclick> -->
                        <onclick condition="true">setfocus(6999)</onclick>
                        <onclick condition="true">action(info)</onclick>
                    </control>

edit: unsure if
Player.Filenameandpath

will help to fill a gap if db id missing.
Thank you, works like a charm Smile
Is there a way to select the current playing video by dbid? videodb://movies/titles/$INFO[VideoPlayer.DBID] does not work...
(2023-03-30, 20:17)beatmasterrs Wrote: [ -> ]Is there a way to select the current playing video by dbid? videodb://movies/titles/$INFO[VideoPlayer.DBID] does not work...

hm, i dont get the intention behind.

when the video/media item is already playing, whats the reason behind to force a (second) select action?

for video path, you need/can use an xsp path, using player.** infolabels to get the wished valid result ( like the example above )

e.g.
xsp={"rules":{"and":[{"field":"title","operator":"is","value":["$INFO[Player.Title]"]}]},"type":"movies"}



xml:


<variable name="CurrentlyPlayingItem">
<value condition="player.hasaudio + !String.IsEmpty(musicplayer.dbid)">musicdb://songs/? songid=$INFO[musicplayer.dbid]</value>
<value condition="player.hasvideo + videoplayer.content(movies)">videodb://movies/titles/?

xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22title%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22$INFO[Player.Title]%22%5D%7D%5D%7D%2C%22type%22%3A%22movies%22%7D</value>
<value condition="player.hasvideo + videoplayer.content(episodes)">videodb://tvshows/titles/-1/-1/?
xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22title%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22$INFO[Player.Title]%22%5D%7D%5D%7D%2C%22type%22%3A%22episodes%22%7D</value>
</variable>


or
xml:
playmedia($ESCINFO[player.filenameandpath],*,*)

or
xml:
setfocus(id* of container which holds the currently playing item*)
action(select)
Oh sorry,i meant, can set a movie path with a dbid, for better results, in case I have two versions of a movie with the same title. Like the path for songs.
ok, so may extend the xsp to the needs.
unsure if listitempath can be used in xsp to filter.
but maybe year,folderpath or something can help to get best matching result.
if you wanna use a simple script to create xsp paths putside of kodi you can use my script which can help alot.

it'll either encode a given url or create decoded kodi xsp urls.
when you type decode, it 'll lead you trough  the possible options.
afterwards it'll create and open a text file to look up results.




you'll just need python on your os and manually install
inquirer via pipinstall and than run the script 😋
 
python:

import urllib.parse
import webbrowser

# pip install inquirer
import inquirer


def options(option_value,xsp_type=None,field=None):

    if option_value == 'Choose Method':
        list = ['encode', 'decode']

    if option_value == 'xsp_type':
        list = ['songs', 'albums', 'artists', 'movies', 'tvshows', 'episodes', 'musicvideos', 'mixed']

    elif option_value == 'match':
        list = ['and', 'or']

    elif option_value == 'field':
        if xsp_type == 'songs':
            list = ['Genre', 'Source', 'Album', 'Artist', 'AlbumArtist', 'Title', 'Year', 'Time', 'TrackNumber', 'Filename', 'Path', 'Playcount', 'LastPlayed', 'Rating', 'UserRating', 'Comment', 'Moods']
        elif xsp_type ==  'albums':
            list = ['Genre', 'Source', 'Album', 'Artist', 'AlbumArtist', 'Year', 'Review', 'Themes', 'Moods', 'Styles', 'Compilation', 'AlbumType', 'MusicLabel', 'Rating', 'UserRating', 'Playcount', 'LastPlayed', 'Path']
        elif xsp_type ==  'artists':
            list = ['Artist', 'Source', 'Genre', 'Moods', 'Styles', 'Instruments', 'Biography', 'ArtistType', 'Gender', 'Disambiguation', 'Born', 'BandFormed', 'Disbanded', 'Died', 'Role', 'Path']
        elif xsp_type ==  'tvshows':
            list = ['Title', 'OriginalTitle', 'Plot', 'TvShowStatus', 'Votes', 'Rating', 'UserRating', 'Year', 'Genre', 'Director', 'Actor', 'NumberOfEpisodes', 'NumberOfWatchedEpisodes', 'Playcount', 'Path', 'Studio', 'MPAA', 'DateAdded', 'LastPlayed', 'InProgress', 'Tag']
        elif xsp_type ==  'episodes':
            list = ['Title', 'TvShowTitle', 'OriginalTitle', 'Plot', 'Votes', 'Rating', 'UserRating', 'Time', 'Writer', 'AirDate', 'Playcount', 'LastPlayed', 'InProgress', 'Genre', 'Year', 'Premiered', 'Director', 'Actor', 'EpisodeNumber', 'Season', 'Filename', 'Path', 'Studio', 'Mpaa', 'DateAdded', 'Tag', 'VideoResolution', 'AudioChannels', 'AudioCount', 'SubtitleCount', 'VideoCodec', 'AudioCodec', 'AudioLanguage', 'SubtitleLanguage', 'VideoAspectRatio']
        elif xsp_type ==  'movies':
            list = ['Title', 'OriginalTitle', 'Plot', 'PlotOutline', 'Tagline', 'Votes', 'Rating', 'UserRating', 'Time', 'Writer', 'Playcount', 'LastPlayed', 'InProgress', 'Genre', 'Country', 'Year', 'Premiered', 'Director', 'Actor', 'Mpaa', 'Top250', 'Studio', 'Trailer', 'Filename', 'Path', 'Set', 'Tag', 'DateAdded', 'VideoResolution', 'AudioChannels', 'AudioCount', 'SubtitleCount', 'VideoCodec', 'AudioCodec', 'AudioLanguage', 'SubtitleLanguage', 'VideoAspectRatio']
        elif xsp_type ==  'musicvideos':
            list = ['Title', 'Genre', 'Album', 'Year', 'Artist', 'Filename', 'Path', 'Playcount', 'LastPlayed', 'Rating', 'UserRating', 'Time', 'Director', 'Studio', 'Plot', 'Tag', 'DateAdded', 'VideoResolution', 'AudioChannels', 'AudioCount', 'SubtitleCount', 'VideoCodec', 'AudioCodec', 'AudioLanguage', 'SubtitleLanguage', 'VideoAspectRatio']
        else:
            list = ['Playlist', 'VirtualFolder']

    elif option_value == 'operator':
        list = ['contains', 'doesnotcontain', 'is', 'isnot', 'startswith', 'endswith', 'lessthan', 'greaterthan', 'after', 'before']
        if field == 'date':
            # untested
            list.extend(['inthelast', 'notinthelast'])

    if option_value == 'Do You wanna add another Rule':
        list = ['yes', 'no']

    # main operand, result = {'option_value': 'RESULT STRING'}
    questions = [
        inquirer.List
           (
            option_value,
              message=f"choose {option_value}",
              choices=list,
           ),
    ]

    answer_ = inquirer.prompt(questions)

    ## convert n override
    option_value = answer_[option_value]
    # test print('\n','options END', option_value,'\n\n')



    return option_value

def writeopenfile(method,source,result,url=None):
    lines = ['source:', source,' ','result :', result]
    with open('urlencode_decode_kodi_xsp_.txt', 'w') as f:
        for line in lines:
            f.write(line)
            f.write('\n')

    if method == 'encode':
        # append = ['\n','Kodi Content Tag', url]
        with open('urlencode_decode_kodi_xsp_.txt', 'a') as f:
           # f.writelines('\n'.join(append))
           f.writelines('\n'.join(['\n','experimental Kodi xml Content Tag', '<content>', url,'</content>']))

    webbrowser.open("urlencode_decode_kodi_xsp_.txt")

    return

def add_rules(xsp_type,xsp_rules,num_rules=2):
    # num_rules just inner indexing
    seperator = ','
    field = options("field", xsp_type)
    operator = options("operator", xsp_type, field)
    field_value = input("enter the field value to operate:")

    new_rule = '{"field":"%s","operator":"%s","value":["%s"]}' % (field,operator,field_value)

    xsp_rules = xsp_rules + seperator + new_rule

    #  inner_loop = input("like to add another rule?? type [y] if you're d'accord:")
    inner_loop = options("Do You wanna add another Rule")

    if inner_loop == 'yes':
        num_rules = num_rules + 1
        # print(
            # 'fixed content is=:"', xsp_type,'"\n',
            # 'current rules are=:"', xsp_rules,'"\n',
            # 'start set rule number:"', num_rules,'"\n'
            # )
        xsp_rules = add_rules(xsp_type,xsp_rules,num_rules)

    return xsp_rules

def main():

    # method = input("encode or decode:")
    method =  options("Choose Method")

    # use numpad
    if method == 'encode':
        xsp_type = options("xsp_type")
        match = options("match")
        field = options("field", xsp_type)
        operator = options("operator", xsp_type, field)
        field_value = input("enter the field value to operate:")

        xsp_rules = '{"field":"%s","operator":"%s","value":["%s"]}' % (field,operator,field_value)

        # add rule subr
        # get_newrule = input('like to add another rule?? :')
        get_newrule = options("Do You wanna add another Rule")

        if get_newrule == 'yes':
            xsp_rule = xsp_rules
            xsp_rules = add_rules(xsp_type,xsp_rule)

        # example* source =
        #    *  '{"rules":{"and":[{"field":"%s","operator":"%s","value":["%s"]}]},"type":"%s"}' % (field,operator,field_value,xsp_type)
        #    *  '{"rules":{"and":[{"field":"actor","operator":"contains","value":["$VAR[videoinfo_cast_container_id]"]},{"field":"title","operator":"isnot","value":["$INFO[Window(home).Property(EncodedTitle)]"]}]},"type":"movies"}'
        source = '{"rules":{"%s":[%s]},"type":"%s"}' % (match,xsp_rules,xsp_type)

        result = urllib.parse.quote(source.encode())


        # experimental : set db_url_root_path
        if xsp_type == 'movies' or xsp_type == 'tvshows' or xsp_type == 'episodes' or xsp_type == 'musicvideos' or xsp_type == 'videos':
            db = 'videodb'
        else:
            db = 'musicdb'
        # else: files\\ ??

        if xsp_type == 'movies' or xsp_type == 'tvshows' or xsp_type == 'musicvideos':
            db_url_root_path = "%s://%s/titles/?xsp=" % (db,xsp_type)

        elif xsp_type == 'episodes':
            db_url_root_path = f"{db}://tvshows/titles/-1/-1/?xsp="

        else:
            db_url_root_path = "%sdb://%s/?xsp=" % (db,xsp_type)

        url = db_url_root_path + result
        print(' source \n', source,'\n\n result \n', result,'\n\n full_encodedpath: \n<content>\n', url,'\n</content>')

        writeopenfile(method,source,result,url)

    # decode
    elif method == 'decode':
        # example source = '%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22actor%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%5B%22christian%20bale%22%5D%7D%5D%7D%2C%22type%22%3A%22movies%22%7D'
        source = input("Copy Paste percent encode URL :\n")
        result = urllib.parse.unquote(source)

        print(' source \n',source,'\n\n result: \n', result)
        writeopenfile(method,source,result)

    else:
        print(' Not possible ')

if __name__ == '__main__':
    main()