[Streams] Check non-existent streams more than once (#5223)

* [Streams] Check non-existent streams more than once

- For YouTube streams, it seems like the RSS feed may sometimes return
  an HTTP 404 for a channel, even though the channel exists.
- If this happens more than a few times, then we should declare the
  stream as non-existent, and purge it from the list of streams we
  check.

* [Streams] Move retry_count reset for YouTubeStream

- Reset after the RSS check, since that is the only place where we raise
  StreamNotFound in that function.

* [Streams] Increase retry to 20

* [Streams] Reduce retry count to 10
This commit is contained in:
Lui
2021-09-03 07:25:01 -07:00
committed by GitHub
parent cad7f400f9
commit 36ea867dcf
2 changed files with 24 additions and 2 deletions

View File

@@ -31,6 +31,8 @@ from datetime import datetime
from collections import defaultdict
from typing import Optional, List, Tuple, Union, Dict
MAX_RETRY_COUNT = 10
_ = Translator("Streams", __file__)
log = logging.getLogger("red.core.cogs.Streams")
@@ -747,8 +749,14 @@ class Streams(commands.Cog):
else:
embed = await stream.is_online()
except StreamNotFound:
log.info("Stream with name %s no longer exists. Removing...", stream.name)
to_remove.append(stream)
if stream.retry_count > MAX_RETRY_COUNT:
log.info("Stream with name %s no longer exists. Removing...", stream.name)
to_remove.append(stream)
else:
log.info(
"Stream with name %s seems to not exist, will retry later", stream.name
)
stream.retry_count += 1
continue
except OfflineStream:
if not stream.messages: