diff --git a/feedleware/youtube/youtube.py b/feedleware/youtube/youtube.py index 14cbff7..92e2912 100644 --- a/feedleware/youtube/youtube.py +++ b/feedleware/youtube/youtube.py @@ -4,11 +4,12 @@ import json import logging import urllib import urllib.request -from typing import Any, Iterable, Optional, Tuple +from typing import Any, Iterable, Tuple from cachetools import cached, TTLCache from ..util import send_with_retry +HTTPError = urllib.error.HTTPError HTTPRequest = urllib.request.Request HTTPResponse = http.client.HTTPResponse HTTPException = http.client.HTTPException @@ -122,16 +123,22 @@ class APIClient: :returns: list of latest videos :throws HTTPException: if the query fails """ - response = self._query( - url="https://youtube.googleapis.com/youtube/v3/playlistItems", - method="GET", - data=( - ("part", "snippet"), - ("part", "status"), - ("playlistId", playlist_id), - ("maxResults", 50), + try: + response = self._query( + url="https://youtube.googleapis.com/youtube/v3/playlistItems", + method="GET", + data=( + ("part", "snippet"), + ("part", "status"), + ("playlistId", playlist_id), + ("maxResults", 50), + ) ) - ) + except HTTPError as err: + if err.code == 404: + return [] + + raise err return [ item["snippet"]