Exemplo n.º 1
0
def Last_Played():
    """
Return the link of the last played (or currently playing) video.
This differs to the built in getPlayingFile command as that only shows details
of the current playing file, these details can differ to the url which was
originally sent through to initiate the stream. This Last_Played function
directly accesses the database to get the REAL link which was initiated and
will even return the plugin path if it's been played through an external add-on.

CODE: Last_Played()

EXAMPLE CODE:
if koding.Play_Video('http://totalrevolution.tv/videos/python_koding/Browse_To_Folder.mov'):
    xbmc.sleep(3000)
    xbmc.Player().stop()
    last_vid = Last_Played()
    dialog.ok('[COLOR gold]VIDEO LINK[/COLOR]','The link we just played is:\n\n%s'%last_vid)
else:
    dialog.ok('[COLOR gold]PLAYBACK FAILED[/COLOR]','Sorry this video is no longer available, please try using a different video link.')
~"""
    from database import DB_Query
    from filetools import DB_Path_Check
    from vartools import Decode_String
    db_path = DB_Path_Check('MyVideos')
    sql = "SELECT files.strFilename as mystring, path.strPath as mybase FROM files JOIN path ON files.idPath=path.idPath ORDER BY files.lastPlayed DESC LIMIT 1"
    results = DB_Query(db_path, sql)
    try:
        if Decode_String(results[0]['mybase']).startswith('plugin://'):
            return Decode_String(results[0]['mystring'])
        else:
            return Decode_String(results[0]['mybase'] + results[0]['mystring'])
    except:
        return False
def Keyboard(heading='',
             default='',
             hidden=False,
             return_false=False,
             autoclose=False,
             kb_type='alphanum'):
    """
Show an on-screen keyboard and return the string

CODE: koding.Keyboard([default, heading, hidden, return_false, autoclose, kb_type])

AVAILABLE PARAMS:

    heading  -  Optionally enter a heading for the text box.

    default  -  This is optional, if set this will act as the default text shown in the text box

    hidden   -  Boolean, if set to True the text will appear as hidden (starred out)

    return_false - By default this is set to False and when escaping out of the keyboard
    the default text is returned (or an empty string if not set). If set to True then
    you'll receive a return of False.

    autoclose - By default this is set to False but if you want the keyboard to auto-close
    after a period of time you can send through an integer. The value sent through needs to
    be milliseconds, so for example if you want it to close after 3 seconds you'd send through
    3000. The autoclose function only works with standard alphanumeric keyboard types.

    kb_type  -  This is the type of keyboard you want to show, by default it's set to alphanum.
    A list of available values are listed below:

        'alphanum'  - A standard on-screen keyboard containing alphanumeric characters.
        'numeric'   - An on-screen numerical pad.
        'date'      - An on-screen numerical pad formatted only for a date.
        'time'      - An on-screen numerical pad formatted only for a time.
        'ipaddress' - An on-screen numerical pad formatted only for an IP Address.
        'password'  - A standard keyboard but returns value as md5 hash. When typing
        the text is starred out, once you've entered the password you'll get another
        keyboard pop up asking you to verify. If the 2 match then your md5 has is returned.


EXAMPLE CODE:
mytext = koding.Keyboard(heading='Type in the text you want returned',default='test text')
dialog.ok('TEXT RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
dialog.ok('AUTOCLOSE ENABLED','This following example we\'ve set the autoclose to 3000. That\'s milliseconds which converts to 3 seconds.')
mytext = koding.Keyboard(heading='Type in the text you want returned',default='this will close in 3s',autoclose=3000)
dialog.ok('TEXT RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
mytext = koding.Keyboard(heading='Enter a number',kb_type='numeric')
dialog.ok('NUMBER RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
dialog.ok('RETURN FALSE ENABLED','All of the following examples have "return_false" enabled. This means if you escape out of the keyboard the return will be False.')
mytext = koding.Keyboard(heading='Enter a date',return_false=True,kb_type='date')
dialog.ok('DATE RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
mytext = koding.Keyboard(heading='Enter a time',return_false=True,kb_type='time')
dialog.ok('TIME RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
mytext = koding.Keyboard(heading='IP Address',return_false=True,kb_type='ipaddress',autoclose=5)
dialog.ok('IP RETURNED','You typed in:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
mytext = koding.Keyboard(heading='Password',kb_type='password')
dialog.ok('MD5 RETURN','The md5 for this password is:', '', '[COLOR=dodgerblue]%s[/COLOR]'%mytext)
~"""
    from vartools import Decode_String
    kb_type = eval('xbmcgui.INPUT_%s' % kb_type.upper())
    if hidden:
        hidden = eval('xbmcgui.%s_HIDE_INPUT' % kb_type.upper())
    keyboard = dialog.input(heading, default, kb_type, hidden, autoclose)

    if keyboard != '':
        return keyboard

    elif not return_false:
        return Decode_String(default)

    else:
        return False