Merge branch 'bug_615_replace_rawfile'
[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 #       SID:NS:TSID:ONID:STYPE:UNUSED(channelnumber in enigma1)
21 #       X   X  X    X    D     D
22
23 #       REFTYPE:FLAGS:STYPE:SID:TSID:ONID:NS:PARENT_SID:PARENT_TSID:UNUSED
24 #       D       D     X     X   X    X    X  X          X           X
25
26         refstr = "1:0:%X:%X:%X:%X:%X:0:0:0" % (ref[4], ref[0], ref[2], ref[3], ref[1])
27         refstr = refstr.replace(':', '_')
28
29         filename = name + ".png"
30         linkname = refstr + ".png"
31
32         if os.access(filename, os.F_OK) and not os.access(linkname, os.F_OK):
33                 os.symlink(filename, linkname)
34         else:
35                 print "could not find PNG for %s" % name
36         f =f[3:]