oe-alliance / AutoBouquetsMaker

Automatically build and update bouquets from the DVB stream.
GNU General Public License v3.0
22 stars 59 forks source link

Fix terrestrial TDT transponder with wrong NIT center_frequency #243

Closed Azureit closed 2 years ago

Azureit commented 2 years ago
Azureit commented 2 years ago

python "oneliner" command to get latest info from oficial TDT site:

wget -q -O- 'https://servicos.apps.meo.pt/Services/TDTService.svc/emissores' | python3 -c "import sys, json, unicodedata, re, time;a=json.load(sys.stdin);z={}
for b in a:c=b['Frequencia'].replace(' ','')[:7].split('-');d=b['EstacaoEmissora'];z[re.sub(r'[^A-Z0-9]+','_',unicodedata.normalize('NFKD',d.upper()).encode('ascii','ignore').decode('utf-8')).strip('_').lower()]=[str((int(c[0])+int(c[1]))*1000000//2),d,b['Canal'],time.mktime(time.strptime(b['DataAtualizacao'],'%d-%m-%Y'))]
y=len(max(z,key=len));a=sorted(e for b,c,d,e in z.values())[-1];x='<\x21-- https://tdt.telecom.pt/emissores (last list update: {}) -->'.format(time.strftime('%d-%m-%Y',time.localtime(a)))
print('\nUpdate for the file \"terrestrial_pt_tdt.xml\":\n\t<dvbtconfigs>\n\t\t{}'.format(x));w='\t\t<configuration key=\"{}\" frequency=\"{}\">{}</configuration>'
for a in sorted(z.keys()):print(w.format(a,z[a][0],z[a][1]))
print('\t</dvbtconfigs>\n\t<customtransponders>');w='\t\t<customtransponder key=\"{}\" frequency=\"{}\" transport_stream_id=\"UNKNOWN\" system=\"0\" />'
#for a in sorted(z.keys()):print(w.format(a,z[a][0]))
print('\t</customtransponders>')
print('\nUpdate for the file \"terrestrial.xml\":\n\t\t{}'.format(x));w='\t\t<transponder centre_frequency=\"{}\" system=\"0\" bandwidth=\"0\" constellation=\"2\" code_rate_hp=\"1\" code_rate_lp=\"0\" guard_interval=\"3\" transmission_mode=\"1\" hierarchy_information=\"0\" inversion=\"0\" /> <\x21-- Ch {} -->'
for a,b in sorted(set((c,e) for c,d,e,f in z.values())):print(w.format(a,b))"