diff --git a/tv/vignettes/vignettes.py b/tv/vignettes/vignettes.py index bfe70c7c..507320a1 100755 --- a/tv/vignettes/vignettes.py +++ b/tv/vignettes/vignettes.py @@ -63,81 +63,81 @@ def vignettes() : os.system('sort /tmp/chaines_recup_sap.txt> /tmp/chaines_recup_sap_triees.txt') data = open('/tmp/chaines_recup_sap_triees.txt','r').readlines() - return +# return for line in data : - - line = line.strip() - nom=line.split(':')[0] - ip=line.split(':')[1] - #on évite les radios, peu de debit et pas de vignettes - if nom[0:3]=='rad' : - #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' - #ip port duree - os.system('dumpudp %s 1234 2 > /tmp/%s.ts 2>/dev/null &' % (ip,ip)) - print '\tconversion en mpeg1' - os.system('rm /tmp/%s.mpg 2>/dev/null 1> /dev/null' % (ip)) #eviter le message demandant l'ecrasement + + line = line.strip() + nom=line.split(':')[0] + ip=line.split(':')[-1] + #on évite les radios, peu de debit et pas de vignettes + if nom[0:3]=='rad' : + #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' + #ip port duree + os.system('/usr/scripts/tv/dumpudp %s 1234 2 > /tmp/%s.ts 2>/dev/null &' % (ip,ip)) + print '\tconversion en mpeg1' + os.system('rm /tmp/%s.mpg 2>/dev/null 1> /dev/null' % (ip)) #eviter le message demandant l'ecrasement os.system('ffmpeg -deinterlace -an -i /tmp/%s.ts /tmp/%s.mpg 2>/dev/null 1> /dev/null' % (ip,ip)) if not os.path.exists('/tmp/%s.mpg' % (ip)) or not os.stat('/tmp/%s.mpg' % (ip))[6] : print '\tOn retente' if os.path.exists('/tmp/%s.mpg' % (ip)) and os.stat('/tmp/%s.mpg' % (ip))[6] : print 'FICIHER VIDE' - os.system('dumpudp %s 1234 2 > /tmp/%s.ts ' % (ip,ip)) + os.system('/usr/scripts/tv/dumpudp %s 1234 2 > /tmp/%s.ts ' % (ip,ip)) print '\t\tconversion en mpeg1' os.system('ffmpeg -y -deinterlace -an -i /tmp/%s.ts /tmp/%s.mpg 2>/dev/null 1> /dev/null' % (ip,ip)) - print '\tconversion en ppm de la frame 11' - os.system('rm /tmp/image_%s*ppm 2>/dev/null 2> /dev/null 1> /dev/null' % (ip)) #eviter le message demandant l'ecrasement - os.system('transcode -q 0 -i /tmp/%s.mpg -x mpeg2,null -y ppm,null -c 10-11 -o /tmp/image_%s 2>/dev/null 1>/dev/null' % (ip,ip)) - print '\tconversion en jpg\n' - os.system('convert -geometry \'400x300 !\' /tmp/image_%s*ppm /var/www/images/%s.jpg 2>/dev/null 1>/dev/null' % (ip,ip)) - os.system('convert -geometry \'200x150 !\' /tmp/image_%s*ppm /var/www/images/%s_petites.jpg 2>/dev/null 1>/dev/null' % (ip,ip)) - - if os.path.exists('/tmp/%s.mpg' % (ip)) and os.stat('/tmp/%s.mpg' % (ip))[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 '\tconversion en ppm de la frame 11' + os.system('rm /tmp/image_%s*ppm 2>/dev/null 2> /dev/null 1> /dev/null' % (ip)) #eviter le message demandant l'ecrasement + os.system('transcode -q 0 -i /tmp/%s.mpg -x mpeg2,null -y ppm,null -c 10-11 -o /tmp/image_%s 2>/dev/null 1>/dev/null' % (ip,ip)) + print '\tconversion en jpg\n' + os.system('convert -geometry \'400x300 !\' /tmp/image_%s*ppm /var/www/images/%s.jpg 2>/dev/null 1>/dev/null' % (ip,ip)) + os.system('convert -geometry \'200x150 !\' /tmp/image_%s*ppm /var/www/images/%s_petites.jpg 2>/dev/null 1>/dev/null' % (ip,ip)) + + if os.path.exists('/tmp/%s.mpg' % (ip)) and os.stat('/tmp/%s.mpg' % (ip))[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/%s.ts /tmp/%s.mpg /tmp/image_%s*ppm' % (ip,ip,ip)) + os.system('rm /tmp/%s.ts /tmp/%s.mpg /tmp/image_%s*ppm' % (ip,ip,ip)) html.write(table_piedpage)