ajout d'un lien vers programme-tv.net

This commit is contained in:
vincent 2018-08-17 13:32:28 +02:00
parent e9b3636df8
commit cf25521a26

View File

@ -2,8 +2,11 @@ from tkinter import *
import json import json
import sys import sys
import os import os
import unicodedata
class Interface: class Interface:
import webbrowser
def __init__(self): def __init__(self):
self.datafilepath=os.path.dirname(os.path.realpath(__file__))+"/chaine.json" self.datafilepath=os.path.dirname(os.path.realpath(__file__))+"/chaine.json"
@ -48,6 +51,9 @@ class Interface:
except KeyError: except KeyError:
print("numero de chaine inconnue") print("numero de chaine inconnue")
self.label2["text"] += "numero de chaine inconnue"+"\r" self.label2["text"] += "numero de chaine inconnue"+"\r"
self.value.set("")
return
self.label2["text"] += geturlprogrammetv(self.data[self.value.get()])
self.value.set("") self.value.set("")
@ -110,6 +116,13 @@ def parsechaine(file):
with open(file, 'w', encoding='utf-8') as f: with open(file, 'w', encoding='utf-8') as f:
json.dump(liste_chaine, f, indent=4) json.dump(liste_chaine, f, indent=4)
def geturlprogrammetv(strsearch):
strsearch=unicodedata.normalize('NFD', strsearch).encode('ascii', 'ignore')
strsearch=strsearch.decode("utf-8")
strsearch=strsearch.replace(" ","+")
return "https://www.programme-tv.net/rechercher?q="+strsearch
def cli(num): def cli(num):
datafilepath=os.path.dirname(os.path.realpath(__file__))+"/chaine.json" datafilepath=os.path.dirname(os.path.realpath(__file__))+"/chaine.json"
@ -119,7 +132,8 @@ def cli(num):
print(data[num]) print(data[num])
except KeyError: except KeyError:
print("numero de chaine inconnue") print("numero de chaine inconnue")
return
print (geturlprogrammetv(data[num]))
if len(sys.argv) > 1: if len(sys.argv) > 1: