correction cas ou la chaine n'est pas une chaine referencer

This commit is contained in:
vincent 2018-08-18 19:34:55 +02:00
parent eda4baa011
commit 86ccdbee75

View File

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