diff --git a/chaineTV.py b/chaineTV.py index f32f85a..097608b 100644 --- a/chaineTV.py +++ b/chaineTV.py @@ -148,9 +148,12 @@ def parse_emmission(URL): response = urllib.request.urlopen(URL) except urllib.error.URLError: return False + html = response.read() parse=BeautifulSoup(html,"html.parser") link=parse.select_one(".prog_name") + if link == None: + return "can't find show" href="https://www.programme-tv.net"+link['href'] response = urllib.request.urlopen(href) html = response.read() @@ -179,16 +182,19 @@ def cli(num): return emision=parse_emmission(geturlprogrammetv(data[num])) if emision: - print("emmision ce soir: "+emision["title"]) - if len(emision['casting']) > 0: - print("réalisateur: "+emision['casting'][0]) - print("acteur: "+str(emision['casting'][1:])) - print("synopsys: " +emision['synopsis']) - print("lien: "+emision['href']) + if emision == "can't find show": + print ("impssible de parser cette chaine") + else: + print("emmision ce soir: "+emision["title"]) + if len(emision['casting']) > 0: + print("réalisateur: "+emision['casting'][0]) + print("acteur: "+str(emision['casting'][1:])) + print("synopsys: " +emision['synopsis']) + print("lien: "+emision['href']) else: print("pas de connection internet impossible de determiner l'émission du soir") - + print("") if len(sys.argv) > 1: for i in sys.argv[1:]: if i =="update":