Commit ba9f37eb authored by Maxim Gubin's avatar Maxim Gubin Committed by Francesco Poldi

Fix unexpected stops due to empty response (#254)

parent 85a2bfed
...@@ -38,20 +38,27 @@ class Twint: ...@@ -38,20 +38,27 @@ class Twint:
print(response, file=open("twint-last-request.log", "w", encoding="utf-8")) print(response, file=open("twint-last-request.log", "w", encoding="utf-8"))
self.feed = [] self.feed = []
try: consecutive_errors_count = 0
if self.config.Favorites: while True:
self.feed, self.init = feed.Mobile(response) try:
elif self.config.Followers or self.config.Following: if self.config.Favorites:
self.feed, self.init = feed.Follow(response)
elif self.config.Profile:
if self.config.Profile_full:
self.feed, self.init = feed.Mobile(response) self.feed, self.init = feed.Mobile(response)
else: elif self.config.Followers or self.config.Following:
self.feed, self.init = feed.profile(response) self.feed, self.init = feed.Follow(response)
elif self.config.TwitterSearch: elif self.config.Profile:
self.feed, self.init = feed.Json(response) if self.config.Profile_full:
except Exception as e: self.feed, self.init = feed.Mobile(response)
print(str(e) + " [x] run.Feed") else:
self.feed, self.init = feed.profile(response)
elif self.config.TwitterSearch:
self.feed, self.init = feed.Json(response)
break
except Exception as e:
# Exit only we're 3 times sure it is the end of the road
consecutive_errors_count += 1
if consecutive_errors_count < 3: continue
print(str(e) + " [x] run.Feed")
break
async def follow(self): async def follow(self):
#logging.info("[<] " + str(datetime.now()) + ':: run+Twint+follow') #logging.info("[<] " + str(datetime.now()) + ':: run+Twint+follow')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment