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,6 +182,9 @@ def cli(num):
return return
emision=parse_emmission(geturlprogrammetv(data[num])) emision=parse_emmission(geturlprogrammetv(data[num]))
if emision: if emision:
if emision == "can't find show":
print ("impssible de parser cette chaine")
else:
print("emmision ce soir: "+emision["title"]) print("emmision ce soir: "+emision["title"])
if len(emision['casting']) > 0: if len(emision['casting']) > 0:
print("réalisateur: "+emision['casting'][0]) print("réalisateur: "+emision['casting'][0])
@ -188,7 +194,7 @@ def cli(num):
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":