1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# -*- coding: utf-8 -*-
# Copyright 2017 Leo Moll and Dominik Schlösser
#
# -- Imports ------------------------------------------------
import sys, urllib
import xbmcplugin, xbmcgui
# -- Classes ------------------------------------------------
class InitialUI( object ):
def __init__( self, handle, sortmethods = None ):
self.handle = handle
self.sortmethods = sortmethods if sortmethods is not None else [ xbmcplugin.SORT_METHOD_TITLE ]
self.channelid = 0
self.initial = ''
self.count = 0
def Begin( self, channelid ):
self.channelid = channelid
for method in self.sortmethods:
xbmcplugin.addSortMethod( self.handle, method )
def Add( self, altname = None ):
if altname is None:
resultingname = '%s (%d)' % ( self.initial if self.initial != ' ' and self.initial != '' else ' No Title', self.count )
else:
resultingname = altname
li = xbmcgui.ListItem( label = resultingname )
xbmcplugin.addDirectoryItem(
handle = self.handle,
url = _build_url( {
'mode': "shows",
'channel': self.channelid,
'initial': self.initial,
'count': self.count
} ),
listitem = li,
isFolder = True
)
def End( self ):
xbmcplugin.endOfDirectory( self.handle )
# -- Functions ----------------------------------------------
def _build_url( query ):
return sys.argv[0] + '?' + urllib.urlencode( query )
|