Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: handle restricted videos (VKvideo)
NTFSvolume82ca65fe746d
diff --git a/cyberdrop_dl/crawlers/vk/types.py b/cyberdrop_dl/crawlers/vk/types.pyindex 5c0c9e127..96ea0dca4 100644--- a/cyberdrop_dl/crawlers/vk/types.py+++ b/cyberdrop_dl/crawlers/vk/types.py@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, ClassVar, Self, overridefrom cyberdrop_dl.crawlers.vk import full_res_img, try_parse_urlfrom cyberdrop_dl.exceptions import ScrapeError-from cyberdrop_dl.utils import parse_url+from cyberdrop_dl.utils import css, parse_urlfrom cyberdrop_dl.utils.dataclass import deserializeif TYPE_CHECKING:@@ -59,7 +59,6 @@ class Format(APIObject):height: int | None = Nonehls: bool = False- @propertydef score(self) -> tuple[bool, int]:return (not self.hls, self.height or 0)@@ -74,6 +73,7 @@ class Video(Owned):title: str | None = Noneaccess_key: str | None = Nonedescription: str | None = None+ restriction: str | None = None@override@classmethod@@ -83,6 +83,8 @@ class Video(Owned):if (thumbs := video.get("image"))else None)+ if restriction := video.get("content_restricted_message") or video.get("restriction", {}).get("text"):+ restriction = css.unescape(restriction)return deserialize(cls,@@ -90,6 +92,7 @@ class Video(Owned):thumb=thumb,formats=tuple(_extract_formats(video)),embed=video.get("files", {}).get("external"),+ restriction=restriction or None,)@propertydiff --git a/cyberdrop_dl/crawlers/vk/vk.py b/cyberdrop_dl/crawlers/vk/vk.pyindex e0983f58d..b9f85ed95 100644--- a/cyberdrop_dl/crawlers/vk/vk.py+++ b/cyberdrop_dl/crawlers/vk/vk.py@@ -15,6 +15,7 @@ from cyberdrop_dl.crawlers.vk.types import (Audio,AudioPlaylist,File,+ Format,Graffiti,Link,Photo,@@ -223,7 +224,12 @@ class VKVideoCrawler(VKBaseCrawler, wiki_site="VKVideo"):self.handle_embed(new_item)return- best_fmt = max(video.formats, key=lambda f: f.score)+ if not video.formats:+ if video.restriction:+ raise ScrapeError(403, video.restriction)+ raise ScrapeError(422, f"No valid HLS or MP4 formats found for {video.web_path}")++ best_fmt = max(video.formats, key=Format.score)m3u8 = info = debrid_url = Noneif best_fmt.hls:m3u8, info = await self.request_m3u8(best_fmt.url)