我用的是def
m3ufile= 'IPTV1'
M3UPATH= '/tmp/IPTV/IPTV1.m3u'
BFNAME= 'userbouquet.IPTV1.tv'
LastScanned= 'userbouquet.LastScanned.tv'
WGET='wget --no-check-certificate'
BOUQUETSPATH='/etc/enigma2/bouquets.tv'
E2SETTINGSPATH='/etc/enigma2'
##################################################################
def convert():
with open('%s/%s' % (E2SETTINGSPATH, BFNAME), 'w') as outfile:
desk_tmp = ''
outfile.write('#NAME %s\r\n' % m3ufile)
if os.path.isfile(M3UPATH):
for line in open(M3UPATH):
if line.startswith('http://'):
outfile.write('#SERVICE 4097:0:1:0:0:0:0:0:0:0:%s' % line.replace(':', '%3a'))
outfile.write('#DESCRIPTION %s' % desk_tmp)
elif line.startswith('#EXTINF'):
desk_tmp = '%s' % line.split(',list.alliptvlinks.com ')[-1]
elif '<stream_url><![CDATA' in line:
outfile.write('#SERVICE 4097:0:1:0:0:0:0:0:0:0:%s\r\n' % line.split('[')[-1].split(']')[0].replace(':', '%3a'))
outfile.write('#DESCRIPTION %s\r\n' % desk_tmp)
elif '<title>' in line:
if '<![CDATA[' in line:
desk_tmp = '%s\r\n' % line.split('[')[-1].split(']')[0]
else:
desk_tmp = '%s\r\n' % line.split('<')[1].split('>')[1]
outfile.write('\r\n')
outfile.close()
if os.path.isfile(BOUQUETSPATH):
for line in open(BOUQUETSPATH):
if BFNAME in line:
if os.path.isfile('%s/%s' % (E2SETTINGSPATH, BFNAME)) and os.path.isfile(BOUQUETSPATH):
remove_line(BOUQUETSPATH, BFNAME)
with open(BOUQUETSPATH, 'a') as outfile:
outfile.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "%s" ORDER BY bouquet\r\n' % BFNAME)
outfile.close()
if LastScanned in line:
remove_line(BOUQUETSPATH, LastScanned)
with open(BOUQUETSPATH, 'a') as outfile:
outfile.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "%s" ORDER BY bouquet\r\n' % LastScanned)
outfile.close()
os.system('wget -q -O - http://root%s@127.0.0.1/web/servicelistreload?mode=0 > /dev/null 2>&1 && sleep 2')
return
else:
print("File missing %s" % M3UPATH)
将日期从(/tmp/IPTV/IPTV1.m3u)转换为(/etc/enigma2/userbouquet.IPTV1.tv)
我需要的是对(/tmp/IPTV)中的所有文件执行相同的工作,例如(IPTV1、IPTV2、IPTV3…IPTV100) 并将其转换为(/etc/enigma2/userbouquet.IPTV1.tv,/etc/enigma2/userbouquet.IPTV2.tv…/etc/enigma2/userbouquet.IPTV100.tv)
多谢各位
好的。。。。我找到了解决办法
相关问题 更多 >
编程相关推荐