fix: TSID is also hex
[vuplus_dvbapp] / tools / create_picon_links.py
1 #
2 # create links for picon
3 #   usage: create_picon_links lamedb
4 # run in picon directory.
5 # It will read the servicenames from the lamedb and create symlinks
6 # for the servicereference names.
7
8 import os, sys
9
10 f = open(sys.argv[1]).readlines()
11
12 f = f[f.index("services\n")+1:-3]
13
14 while len(f):
15         ref = [int(x, 0x10) for x in f[0][:-1].split(':')]
16         name = f[1][:-1]
17
18         name = name.replace('\xc2\x87', '').replace('\xc2\x86', '')
19
20         refstr = "1:0:%d:%X:%X:%X:%X:%d:0:0" % (ref[4], ref[0], ref[2], ref[3], ref[1], ref[5])
21         refstr = refstr.replace(':', '_')
22
23         filename = name + ".png"
24         linkname = refstr + ".png"
25
26         if os.access(filename, os.F_OK) and not os.access(linkname, os.F_OK):
27                 os.symlink(filename, linkname)
28         else:
29                 print "could not find PNG for %s" % name
30         f =f[3:]