youtube: Handle missing uploads playlist
This commit is contained in:
parent
20c3d12331
commit
90858fbf7b
|
@ -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"]
|
||||
|
|
Loading…
Reference in New Issue