youtube: Handle missing uploads playlist
This commit is contained in:
parent
20c3d12331
commit
90858fbf7b
|
@ -4,11 +4,12 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from typing import Any, Iterable, Optional, Tuple
|
from typing import Any, Iterable, Tuple
|
||||||
from cachetools import cached, TTLCache
|
from cachetools import cached, TTLCache
|
||||||
from ..util import send_with_retry
|
from ..util import send_with_retry
|
||||||
|
|
||||||
|
|
||||||
|
HTTPError = urllib.error.HTTPError
|
||||||
HTTPRequest = urllib.request.Request
|
HTTPRequest = urllib.request.Request
|
||||||
HTTPResponse = http.client.HTTPResponse
|
HTTPResponse = http.client.HTTPResponse
|
||||||
HTTPException = http.client.HTTPException
|
HTTPException = http.client.HTTPException
|
||||||
|
@ -122,6 +123,7 @@ class APIClient:
|
||||||
:returns: list of latest videos
|
:returns: list of latest videos
|
||||||
:throws HTTPException: if the query fails
|
:throws HTTPException: if the query fails
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
response = self._query(
|
response = self._query(
|
||||||
url="https://youtube.googleapis.com/youtube/v3/playlistItems",
|
url="https://youtube.googleapis.com/youtube/v3/playlistItems",
|
||||||
method="GET",
|
method="GET",
|
||||||
|
@ -132,6 +134,11 @@ class APIClient:
|
||||||
("maxResults", 50),
|
("maxResults", 50),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except HTTPError as err:
|
||||||
|
if err.code == 404:
|
||||||
|
return []
|
||||||
|
|
||||||
|
raise err
|
||||||
|
|
||||||
return [
|
return [
|
||||||
item["snippet"]
|
item["snippet"]
|
||||||
|
|
Loading…
Reference in New Issue