-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.py
39 lines (31 loc) · 1023 Bytes
/
default.py
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
import xbmc
import xbmcgui
import xbmcvfs
def getfiles(input_dir):
retList = []
dirs, files = xbmcvfs.listdir(input_dir)
[retList.extend(getfiles('%s/%s' % (input_dir, item))) for item in dirs]
[retList.append('%s/%s' % (input_dir, item)) for item in files]
return retList
def shuffleplay():
path = xbmcgui.Dialog().browse(0, 'videos', 'video')
if not path:
return
pDialog = xbmcgui.DialogProgress()
pDialog.create('get video list')
# remove the tailing slash - so we do not have to use validatePath in the called function
files = getfiles(path[:-1])
pDialog.close()
if pDialog.iscanceled():
return
if not len(files):
return
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
[playlist.add(url = xbmc.validatePath(item)) for item in files]
playlist.shuffle()
if playlist.size() <= 0:
return
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(playlist)
if (__name__ == "__main__"):
shuffleplay()