diff --git a/tv/__init__.py b/tv/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tv/genconf/__init__.py b/tv/genconf/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tv/recup_sap b/tv/recup_sap new file mode 100755 index 00000000..b963eae5 Binary files /dev/null and b/tv/recup_sap differ diff --git a/tv/vignettes/vignettes_diff.py b/tv/vignettes/vignettes_diff.py new file mode 100755 index 00000000..c96de2bb --- /dev/null +++ b/tv/vignettes/vignettes_diff.py @@ -0,0 +1,173 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import os,sys +sys.path.append('/usr/scripts/gestion') +import lock +import time +from time import localtime,sleep +from socket import gethostname + + +host = gethostname() + +t = localtime() +trame_entete=""" + + + +Chaines diffusées + + + + +\"En_tete\"
+
Chaines diffusées
+
+Cette page à été générée à %02ih%02i
+
+ +

Pour plus d'informations cliquez ici

+Petites vignettes
+Vignettes Normales
+ + +""" % (int(t[3]) ,int(t[4]) ) + +table_piedpage=""" +
+""" + +trame_piedpage=""" + +""" + +def ajoute_image(nom,ip,html,html_petites): + html.write('') + html.write('Chaine : %s / IP : %s
' % (ip, nom, ip)) + html.write('Chaine : %s
IP : %s:1234' % (nom, ip)) + html.write('\n') + html_petites.write('') + html_petites.write('Chaine : %s / IP : %s
' % (ip, nom, ip)) + html_petites.write('Chaine : %s
IP : %s:1234' % (nom, ip)) + html_petites.write('\n') + + + +def vignettes() : + html = open('/tmp/vignettes.html','w') + html.write(trame_entete) + html_petites = open('/tmp/vignettes_petites.html','w') + html_petites.write(trame_entete) + col = 0 + col_petites = 0 + #a factoriser + chaines_probleamatiques=[] +# os.system('cat /var/run/mumudvb/chaines_diffusees_carte* > /tmp/chaines_diff.txt') +# os.system('sort /tmp/chaines_diff.txt> /tmp/chaines_diff_triees.txt') +# data = open('/tmp/chaines_diff_triees.txt','r').readlines() + os.system('wget http://tv.crans.org/sap.txt -O /tmp/sap.txt') + pre_data = open('/tmp/sap.txt','r').readlines() + + data=[] + if host="mouton": + data=pre_data + print data + + for line in data : + line = line.strip() +# nom=line.split(':')[2] +# ip=line.split(':')[0] + nom=line.split(':')[0] + ip=line.split(':')[1] + + + #on évite les radios, peu de debit et pas de vignettes + if nom[0:3]=='rad' : +# continue + #C'est une radio on cherche un logo + ok=0 #désolé vince j'ai essayé les exceptions mois c pas si simple + nom_court=(' '.join(nom.split(' ')[2:])).lower() + print "On s'occupe de la radio %s" % nom_court + for file in os.listdir('/var/www/images/logos_radios'): + if file.startswith(nom_court): + os.system('cp /var/www/images/logos_radios/\"%s\" /var/www/images/%s.jpg' % (file,ip)) + os.system('cp /var/www/images/logos_radios/\"%s\" /var/www/images/%s_petites.jpg' % (file,ip)) + if col == 2 : + col = 1 + html.write('\n') + else : + col += 1 + if col_petites == 3: + col_petites = 1 + html_petites.write('\n') + else : + col_petites += 1 + ajoute_image(nom,ip,html,html_petites) + ok=1 #désolé vince j'ai essayé les exceptions mois c pas si simple + if not ok: + #il n'y a pas de logo :-( + chaines_probleamatiques.append('Chaine : %s
IP : %s:1234

\n' %(nom,ip)) + print "\t Fait" + continue + print 'on s\'occupe de %s %s' % (ip,nom) + + print '\trecuperation du flux' + + os.system('nice mplayer -vo jpeg:outdir=/tmp udp://%s:1234 -frames 10 -really-quiet' % (ip)) + if not os.path.exists('/tmp/00000010.jpg') or not os.stat('/tmp/00000010.jpg')[6] : + print '\tOn retente' + if os.path.exists('/tmp/00000010.jpg') and os.stat('/tmp/00000010.jpg')[6] : + print 'FICIHER VIDE' + os.system('cd /tmp && nice mplayer -vo jpeg:outdir=/tmp udp://%s:1234 -frames 10' % (ip)) + print '\tredimesionnement\n' +# os.system('convert -geometry \'400x300 !\' /tmp/00000010.jpg /var/www/images/%s.jpg 2>/dev/null 1>/dev/null' % (ip)) +# os.system('convert -geometry \'200x150 !\' /tmp/00000010.jpg /var/www/images/%s_petites.jpg 2>/dev/null 1>/dev/null' % (ip)) + os.system('convert -geometry \'400x300 !\' /tmp/00000010.jpg /var/www/images/%s.jpg ' % (ip)) + os.system('convert -geometry \'200x150 !\' /tmp/00000010.jpg /var/www/images/%s_petites.jpg ' % (ip)) + + if os.path.exists('/tmp/00000010.jpg') and os.stat('/tmp/00000010.jpg')[6] : #on teste sur le mpg car il est enleve a chaque fois + if col == 2 : + col = 1 + html.write('\n') + else : + col += 1 + if col_petites == 3: + col_petites = 1 + html_petites.write('\n') + else : + col_petites += 1 + ajoute_image(nom,ip,html,html_petites) + print "--------------- Ok %s" % ip + else : + chaines_probleamatiques.append('Chaine : %s
IP : %s:1234

\n' %(nom,ip)) + print "--------------- Problematique %s ..." % ip + os.system('rm /var/www/images/%s.jpg' % (ip)) + os.system('rm /var/www/images/%s_petites.jpg' % (ip)) + + os.system('rm /tmp/000000*jpg') + + + html.write(table_piedpage) + html_petites.write(table_piedpage) + #on ecrit les radios + html.write('

Liste des chaines diffusées mais dont le flux est érroné ou uniquement audio (les flux videos ne seront probablement non lisibles avec VLC mais lisibles avec xine)


') + html_petites.write('

Liste des chaines diffusées mais dont le flux est érroné ou uniquement audio (les flux videos ne seront probablement non lisibles avec VLC mais lisibles avec xine)


') + for line in chaines_probleamatiques : + html.write(line) + html_petites.write(line) + #on ecrit la vraie fin + html.write(trame_piedpage) + html.close() + html_petites.write(trame_piedpage) + html_petites.close() + os.system('mv -f /tmp/vignettes.html /var/www/vignettes.html') + os.system('mv -f /tmp/vignettes_petites.html /var/www/vignettes_petites.html') + + +if __name__ == '__main__' : + lock.make_lock('vignettes') + print 'Vignetisation générale' + vignettes() + print 'On a fini' + lock.remove_lock('vignettes') diff --git a/tv/vignettes/vignettes_new.py b/tv/vignettes/vignettes_new.py new file mode 100755 index 00000000..7787a60d --- /dev/null +++ b/tv/vignettes/vignettes_new.py @@ -0,0 +1,194 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import os,sys +sys.path.append('/usr/scripts/gestion') +import lock +import time +from time import localtime,sleep +from socket import gethostname + + +host = gethostname() + +t = localtime() +trame_entete=""" + + + +Chaines diffusées + + + + +\"En_tete\"
+
Chaines diffusées
+
+Cette page à été générée à %02ih%02i
+
+ +

Pour plus d'informations cliquez ici

+Petites vignettes
+Vignettes Normales
+ + +""" % (int(t[3]) ,int(t[4]) ) + +table_piedpage=""" +
+""" + +trame_piedpage=""" + +""" + +def ajoute_image(nom,ip,html,html_petites): + html.write('') + html.write('Chaine : %s / IP : %s
' % (ip, nom, ip)) + html.write('Chaine : %s
IP : %s:1234' % (nom, ip)) + html.write('\n') + html_petites.write('') + html_petites.write('Chaine : %s / IP : %s
' % (ip, nom, ip)) + html_petites.write('Chaine : %s
IP : %s:1234' % (nom, ip)) + html_petites.write('\n') + + + +def vignettes() : + html = open('/tmp/vignettes.html','w') + html.write(trame_entete) + html_petites = open('/tmp/vignettes_petites.html','w') + html_petites.write(trame_entete) + col = 0 + col_petites = 0 + #a factoriser + chaines_probleamatiques=[] +# os.system('cat /var/run/mumudvb/chaines_diffusees_carte* > /tmp/chaines_diff.txt') +# os.system('sort /tmp/chaines_diff.txt> /tmp/chaines_diff_triees.txt') +# data = open('/tmp/chaines_diff_triees.txt','r').readlines() + os.system('wget http://tv.crans.org/sap.txt -O /tmp/sap.txt') + pre_data = open('/tmp/sap.txt','r').readlines() + + data=[] + if host=="mouton": + data=pre_data + chemin_images="/var/www/images/" + elif host=="canard": + chemin_images="/tmp/tv_images/" + for line in pre_data : + ip_serv=line.split(':')[1].split('.')[1] + if ip_serv=="201": + data.append(line) + elif host=="oie": + chemin_images="/tmp/tv_images/" + for line in pre_data : + ip_serv=line.split(':')[1].split('.')[1] + if ip_serv=="202": + data.append(line) + elif host=="lapin": + chemin_images="/tmp/tv_images/" + for line in pre_data : + ip_serv=line.split(':')[1].split('.')[1] + if ip_serv=="200": + data.append(line) + + + print data + + for line in data : + line = line.strip() +# nom=line.split(':')[2] +# ip=line.split(':')[0] + nom=line.split(':')[0] + ip=line.split(':')[1] + + + #on évite les radios, peu de debit et pas de vignettes + if nom[0:3]=='rad' : +# continue + #C'est une radio on cherche un logo + ok=0 #désolé vince j'ai essayé les exceptions mois c pas si simple + nom_court=(' '.join(nom.split(' ')[2:])).lower() + print "On s'occupe de la radio %s" % nom_court + for file in os.listdir('%s/logos_radios' % chemin_images): + if file.startswith(nom_court): + os.system('cp %s/logos_radios/\"%s\" /var/www/images/%s.jpg' % (chemin_images,file,ip)) + os.system('cp %s/logos_radios/\"%s\" /var/www/images/%s_petites.jpg' % (chemin_images,file,ip)) + if col == 2 : + col = 1 + html.write('\n') + else : + col += 1 + if col_petites == 3: + col_petites = 1 + html_petites.write('\n') + else : + col_petites += 1 + ajoute_image(nom,ip,html,html_petites) + ok=1 #désolé vince j'ai essayé les exceptions mois c pas si simple + if not ok: + #il n'y a pas de logo :-( + chaines_probleamatiques.append('Chaine : %s
IP : %s:1234

\n' %(nom,ip)) + print "\t Fait" + continue + print 'on s\'occupe de %s %s' % (ip,nom) + + print '\trecuperation du flux' + + os.system('nice mplayer -vo jpeg:outdir=/tmp udp://%s:1234 -frames 10 -really-quiet' % (ip)) + if not os.path.exists('/tmp/00000001.jpg') or not os.stat('/tmp/00000001.jpg')[6] : + print '\tOn retente' + if os.path.exists('/tmp/00000001.jpg') and os.stat('/tmp/00000001.jpg')[6] : + print 'FICIHER VIDE' + os.system('cd /tmp && nice mplayer -vo jpeg:outdir=/tmp udp://%s:1234 -frames 1' % (ip)) + print '\tredimesionnement\n' +# os.system('convert -geometry \'400x300 !\' /tmp/00000010.jpg /var/www/images/%s.jpg 2>/dev/null 1>/dev/null' % (ip)) +# os.system('convert -geometry \'200x150 !\' /tmp/00000010.jpg /var/www/images/%s_petites.jpg 2>/dev/null 1>/dev/null' % (ip)) + os.system('convert -geometry \'400x300 !\' /tmp/00000001.jpg %s/%s.jpg ' % (chemin_images,ip)) + os.system('convert -geometry \'200x150 !\' /tmp/00000001.jpg %s/%s_petites.jpg ' % (chemin_images,ip)) + + if os.path.exists('/tmp/00000001.jpg') and os.stat('/tmp/00000001.jpg')[6] : #on teste sur le mpg car il est enleve a chaque fois + if col == 2 : + col = 1 + html.write('\n') + else : + col += 1 + if col_petites == 3: + col_petites = 1 + html_petites.write('\n') + else : + col_petites += 1 + ajoute_image(nom,ip,html,html_petites) + print "--------------- Ok %s" % ip + else : + chaines_probleamatiques.append('Chaine : %s
IP : %s:1234

\n' %(nom,ip)) + print "--------------- Problematique %s ..." % ip + os.system('rm %s/%s.jpg' % (chemin_images,ip)) + os.system('rm %s/%s_petites.jpg' % (chemin_images,ip)) + + os.system('rm /tmp/000000*jpg') + + + html.write(table_piedpage) + html_petites.write(table_piedpage) + #on ecrit les radios + html.write('

Liste des chaines diffusées mais dont le flux est érroné ou uniquement audio (les flux videos ne seront probablement non lisibles avec VLC mais lisibles avec xine)


') + html_petites.write('

Liste des chaines diffusées mais dont le flux est érroné ou uniquement audio (les flux videos ne seront probablement non lisibles avec VLC mais lisibles avec xine)


') + for line in chaines_probleamatiques : + html.write(line) + html_petites.write(line) + #on ecrit la vraie fin + html.write(trame_piedpage) + html.close() + html_petites.write(trame_piedpage) + html_petites.close() + os.system('mv -f /tmp/vignettes.html /var/www/vignettes.html') + os.system('mv -f /tmp/vignettes_petites.html /var/www/vignettes_petites.html') + + +if __name__ == '__main__' : + lock.make_lock('vignettes') + print 'Vignetisation générale' + vignettes() + print 'On a fini' + lock.remove_lock('vignettes')