diff --git a/backend/chainetv/emission.py b/backend/chainetv/emission.py index b8a8af3..8ecab50 100644 --- a/backend/chainetv/emission.py +++ b/backend/chainetv/emission.py @@ -2,12 +2,13 @@ from bs4 import BeautifulSoup import urllib.request import re from datetime import datetime, timedelta +from time import sleep #debug #import pprint class Emmission(object): - + loading = False def __init__(self): self._LoadreferencePage() @@ -19,11 +20,17 @@ class Emmission(object): return None print("load") self.html = BeautifulSoup(response.read(),"html.parser") - self.timeexp=datetime.utcnow() +timedelta(minutes=5) + self.timeexp=datetime.utcnow() +timedelta(seconds=30) def parse_emmission(self,strsearch): - if (datetime.utcnow() > self.timeexp): + if ((datetime.utcnow() > self.timeexp) and (self.loading == False)): + self.loading = True self._LoadreferencePage() + self.loading = False + else: + while(self.loading): + sleep(0.1) + pass strsearch=strsearch.replace('É','E') linkchaine=self.html.find(text=re.compile(re.escape(strsearch))) if linkchaine == None: