forked from rmrector/script.playrandomvideos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
38 lines (31 loc) · 1023 Bytes
/
script.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
import os
import sys
import xbmc
import xbmcaddon
addon = xbmcaddon.Addon()
resourcelibs = xbmc.translatePath(addon.getAddonInfo('path')).decode('utf-8')
resourcelibs = os.path.join(resourcelibs, u'resources', u'lib')
sys.path.append(resourcelibs)
import playrandom
from pykodi import log, get_pathinfo
def main():
if len(sys.argv) < 2:
runscript = 'RunScript(script.playrandomvideos, "<list path>", "label=<list label>")'
log("See README.md for full usage: '%s'" % runscript, xbmc.LOGNOTICE)
return
if not sys.argv[1]:
return
pathinfo = get_arginfo()
if not pathinfo:
return
playrandom.play(pathinfo)
def get_arginfo():
pathinfo = {}
for i in range(2, len(sys.argv)):
arg = sys.argv[i].split("=", 1)
pathinfo[arg[0].strip().lower()] = arg[1].strip() if len(arg) > 1 else True
pathinfo['full path'] = sys.argv[1]
pathinfo.update(get_pathinfo(pathinfo['full path']))
return pathinfo
if __name__ == '__main__':
main()