unofficial-api-for-thumbzilla 1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unofficial_api_for_thumbzilla-1.1/LICENSE +59 -0
- unofficial_api_for_thumbzilla-1.1/PKG-INFO +30 -0
- unofficial_api_for_thumbzilla-1.1/pyproject.toml +55 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/__init__.py +3 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/api.py +420 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/modules/__init__.py +0 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/modules/consts.py +112 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/modules/errors.py +28 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/modules/type_hints.py +4 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/tests/test_amatuer.py +19 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/tests/test_channel.py +21 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/tests/test_pornstar.py +17 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/tests/test_search.py +15 -0
- unofficial_api_for_thumbzilla-1.1/thumbzilla_api/tests/test_video.py +21 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
|
9
|
+
|
|
10
|
+
0. Additional Definitions.
|
|
11
|
+
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
|
12
|
+
|
|
13
|
+
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
|
14
|
+
|
|
15
|
+
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
|
16
|
+
|
|
17
|
+
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
|
18
|
+
|
|
19
|
+
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
|
20
|
+
|
|
21
|
+
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
|
22
|
+
|
|
23
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
24
|
+
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
|
25
|
+
|
|
26
|
+
2. Conveying Modified Versions.
|
|
27
|
+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
|
28
|
+
|
|
29
|
+
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
|
30
|
+
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
|
31
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
32
|
+
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
|
33
|
+
|
|
34
|
+
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
|
35
|
+
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
|
36
|
+
4. Combined Works.
|
|
37
|
+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
|
38
|
+
|
|
39
|
+
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
|
40
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
|
41
|
+
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
|
42
|
+
d) Do one of the following:
|
|
43
|
+
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
|
44
|
+
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
|
45
|
+
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
|
46
|
+
5. Combined Libraries.
|
|
47
|
+
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
|
48
|
+
|
|
49
|
+
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
|
50
|
+
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
|
51
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
52
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
|
53
|
+
|
|
54
|
+
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
|
55
|
+
|
|
56
|
+
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
|
57
|
+
|
|
58
|
+
▲
|
|
59
|
+
[FSF]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unofficial-api-for-thumbzilla
|
|
3
|
+
Version: 1.1
|
|
4
|
+
Summary: An asynchronous API wrapper and scraper for thumbzilla.com
|
|
5
|
+
Keywords: api,scraper,async,asyncio,video-downloader,selectolax,curl-cffi,thumbzilla
|
|
6
|
+
Author: EchterAlsFake
|
|
7
|
+
Author-email: EchterAlsFake <EchterAlsFake@proton.me>
|
|
8
|
+
License-Expression: LGPL-3.0-only
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Topic :: Multimedia :: Video
|
|
19
|
+
Requires-Dist: eaf-base-api
|
|
20
|
+
Requires-Dist: m3u8
|
|
21
|
+
Requires-Dist: selectolax
|
|
22
|
+
Requires-Dist: av ; extra == 'av'
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Project-URL: Homepage, https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla
|
|
25
|
+
Project-URL: Repository, https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla
|
|
26
|
+
Project-URL: Bug Tracker, https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla/issues
|
|
27
|
+
Project-URL: Support me on Ko-Fi, https://ko-fi.com/EchterAlsFake
|
|
28
|
+
Project-URL: Donate via PayPal, https://paypal.me/EchterAlsFake
|
|
29
|
+
Project-URL: Donate via Crypto, https://nowpayments.io/donation/EchterAlsFake
|
|
30
|
+
Provides-Extra: av
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "unofficial-api-for-thumbzilla"
|
|
7
|
+
version = "1.1"
|
|
8
|
+
description = "An asynchronous API wrapper and scraper for thumbzilla.com"
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "EchterAlsFake", email = "EchterAlsFake@proton.me"}
|
|
11
|
+
]
|
|
12
|
+
requires-python = ">=3.12"
|
|
13
|
+
license = "LGPL-3.0-only"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
keywords = [
|
|
16
|
+
"api",
|
|
17
|
+
"scraper",
|
|
18
|
+
"async",
|
|
19
|
+
"asyncio",
|
|
20
|
+
"video-downloader",
|
|
21
|
+
"selectolax",
|
|
22
|
+
"curl-cffi",
|
|
23
|
+
"thumbzilla"
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 5 - Production/Stable",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
34
|
+
"Topic :: Multimedia :: Video"
|
|
35
|
+
]
|
|
36
|
+
dependencies = [
|
|
37
|
+
"eaf-base-api",
|
|
38
|
+
"m3u8",
|
|
39
|
+
"selectolax",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
av = ["av"]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla"
|
|
47
|
+
Repository = "https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla"
|
|
48
|
+
"Bug Tracker" = "https://github.com/EchterAlsFake/unofficial-api-for-thumbzilla/issues"
|
|
49
|
+
"Support me on Ko-Fi" = "https://ko-fi.com/EchterAlsFake"
|
|
50
|
+
"Donate via PayPal" = "https://paypal.me/EchterAlsFake"
|
|
51
|
+
"Donate via Crypto" = "https://nowpayments.io/donation/EchterAlsFake"
|
|
52
|
+
|
|
53
|
+
[tool.uv.build-backend]
|
|
54
|
+
module-name = "thumbzilla_api"
|
|
55
|
+
module-root = ""
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import copy
|
|
5
|
+
import json
|
|
6
|
+
import asyncio
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
from typing import AsyncGenerator
|
|
10
|
+
from dataclasses import dataclass, fields
|
|
11
|
+
from curl_cffi import Response, AsyncSession
|
|
12
|
+
from selectolax.lexbor import LexborHTMLParser
|
|
13
|
+
from base_api.modules.type_hints import DownloadReport
|
|
14
|
+
from base_api import BaseCore, Helper, BaseMedia, DownloadConfigHLS, ScrapeResult
|
|
15
|
+
from base_api.modules.errors import InvalidProxy, UnknownError, NetworkRequestError, BotProtectionDetected, ResourceGone
|
|
16
|
+
|
|
17
|
+
from thumbzilla_api.modules.errors import (NotFound, ProxyError, NetworkError, UnknownNetworkError, BotDetection,
|
|
18
|
+
DownloadFailed)
|
|
19
|
+
from thumbzilla_api.modules.consts import HEADERS, COOKIES, extractor_search
|
|
20
|
+
from thumbzilla_api.modules.type_hints import on_error_hint
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger("Thumbzilla API")
|
|
23
|
+
|
|
24
|
+
async def on_error(url: str, error: Exception, attempt: int) -> bool:
|
|
25
|
+
logger.warning(f"URL: {url}, ERROR: {error}, Attempt: {attempt}")
|
|
26
|
+
|
|
27
|
+
if isinstance(error, ResourceGone):
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
return True
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def get_html_content(core: BaseCore, url: str) -> str | None | dict:
|
|
34
|
+
try:
|
|
35
|
+
content = await core.fetch(url)
|
|
36
|
+
if isinstance(content, str):
|
|
37
|
+
return content
|
|
38
|
+
|
|
39
|
+
if isinstance(content, Response):
|
|
40
|
+
if content.status_code == 404:
|
|
41
|
+
raise NotFound(f"Server returned 404 for: {url}")
|
|
42
|
+
|
|
43
|
+
except NetworkRequestError as e:
|
|
44
|
+
raise NetworkError(str(e)) from e
|
|
45
|
+
|
|
46
|
+
except InvalidProxy as e:
|
|
47
|
+
raise ProxyError(str(e)) from e
|
|
48
|
+
|
|
49
|
+
except BotProtectionDetected as e:
|
|
50
|
+
raise BotDetection(str(e)) from e
|
|
51
|
+
|
|
52
|
+
except UnknownError as e:
|
|
53
|
+
raise UnknownNetworkError(str(e)) from e
|
|
54
|
+
|
|
55
|
+
@dataclass(kw_only=True, slots=True)
|
|
56
|
+
class Video(BaseMedia):
|
|
57
|
+
url: str
|
|
58
|
+
core: BaseCore
|
|
59
|
+
video_id: str | None = None
|
|
60
|
+
duration: str | None = None
|
|
61
|
+
thumbnail: str | None = None
|
|
62
|
+
embed_url: str | None = None
|
|
63
|
+
views: str | None = None
|
|
64
|
+
publish_date: str | None = None
|
|
65
|
+
publish_date_thumbnail: str | None = None
|
|
66
|
+
description: str | None = None
|
|
67
|
+
title: str | None = None
|
|
68
|
+
author_name: str | None = None
|
|
69
|
+
m3u8_url: str | None = None
|
|
70
|
+
m3u8_base_url: str | None = None
|
|
71
|
+
media_definitions: dict | None = None
|
|
72
|
+
|
|
73
|
+
# Optional
|
|
74
|
+
preview_video_url: str | None = None
|
|
75
|
+
performers: list[str] | None = None
|
|
76
|
+
uploader_url: str | None = None
|
|
77
|
+
|
|
78
|
+
async def _perform_load(self, api: bool, html: bool, anything_else: bool):
|
|
79
|
+
if html:
|
|
80
|
+
await asyncio.gather(self._fetch_html())
|
|
81
|
+
|
|
82
|
+
async def _fetch_html(self):
|
|
83
|
+
html_content = await get_html_content(url=self.url, core=self.core)
|
|
84
|
+
assert isinstance(html_content, str)
|
|
85
|
+
data: dict = await asyncio.to_thread(self._extract_html, html_content)
|
|
86
|
+
allowed_fields = {field.name for field in fields(self)}
|
|
87
|
+
|
|
88
|
+
for key, value in data.items():
|
|
89
|
+
if key in allowed_fields:
|
|
90
|
+
setattr(self, key, value)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
stuff = await get_html_content(core=self.core, url=self.m3u8_url)
|
|
94
|
+
self.m3u8_base_url = self.get_m3u8_base_url(stuff)
|
|
95
|
+
|
|
96
|
+
def _extract_html(self, html_content: str) -> dict:
|
|
97
|
+
parser = LexborHTMLParser(html_content)
|
|
98
|
+
|
|
99
|
+
stuff = parser.css_first('script[type="application/ld+json"]').text()
|
|
100
|
+
script = json.loads(stuff).get("@graph")
|
|
101
|
+
video_id = re.search(r'watch/(\d+)', self.url).group(1)
|
|
102
|
+
duration = int(re.search(r'PT(\d+)S', script[1].get("duration")).group(1))
|
|
103
|
+
thumbnail = script[1].get("thumbnailUrl")
|
|
104
|
+
embed_url = script[1].get("embedUrl")
|
|
105
|
+
views = script[1].get("interactionCount")
|
|
106
|
+
publish_date = script[1].get("uploadDate")
|
|
107
|
+
publish_date_thumbnail = script[0].get("datePublished")
|
|
108
|
+
description = script[0].get("description")
|
|
109
|
+
title = script[0].get("name")
|
|
110
|
+
author_name = script[0].get("author")
|
|
111
|
+
media_definitions = json.loads(re.search(r'"mediaDefinitions"\s*:\s*(\[.*?])', html_content).group(1))
|
|
112
|
+
|
|
113
|
+
m3u8_url = None
|
|
114
|
+
for media in media_definitions:
|
|
115
|
+
if media.get('format') == 'hls':
|
|
116
|
+
m3u8_url = media.get('videoUrl')
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
"video_id": video_id,
|
|
120
|
+
"duration": duration,
|
|
121
|
+
"thumbnail": thumbnail,
|
|
122
|
+
"embed_url": embed_url,
|
|
123
|
+
"views": views,
|
|
124
|
+
"publish_date": publish_date,
|
|
125
|
+
"publish_date_thumbnail": publish_date_thumbnail,
|
|
126
|
+
"description": description,
|
|
127
|
+
"title": title,
|
|
128
|
+
"author_name": author_name,
|
|
129
|
+
"m3u8_url": m3u8_url,
|
|
130
|
+
"media_definitions": media_definitions
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@staticmethod
|
|
134
|
+
def get_m3u8_base_url(stuff) -> str | None:
|
|
135
|
+
"""Convenience property to quickly get the main HLS adaptive stream path."""
|
|
136
|
+
data = json.loads(stuff)
|
|
137
|
+
|
|
138
|
+
m3u8_lines = ["#EXTM3U", "#EXT-X-VERSION:3"]
|
|
139
|
+
|
|
140
|
+
for stream in data:
|
|
141
|
+
quality = stream.get("quality", "unknown")
|
|
142
|
+
width = stream.get("width", 720)
|
|
143
|
+
height = stream.get("height", 404)
|
|
144
|
+
url = stream.get("videoUrl", "")
|
|
145
|
+
|
|
146
|
+
if not url:
|
|
147
|
+
continue
|
|
148
|
+
|
|
149
|
+
# Rough bandwidth estimation based on standard stream naming conventions
|
|
150
|
+
# (e.g., 4000K = 4,000,000 bps, 2000K = 2,000,000 bps)
|
|
151
|
+
# If '1080P_4000K' is in the URL, we use 4000000. Default to a sensible fallback.
|
|
152
|
+
bandwidth = 4000000
|
|
153
|
+
if "4000K" in url:
|
|
154
|
+
bandwidth = 4000000
|
|
155
|
+
elif "2000K" in url:
|
|
156
|
+
bandwidth = 2000000
|
|
157
|
+
elif "1000K" in url:
|
|
158
|
+
bandwidth = 1000000
|
|
159
|
+
|
|
160
|
+
# Adjust dimensions safely if height changes per quality
|
|
161
|
+
# Your JSON snippet showed height 404 for all, but typically:
|
|
162
|
+
stream_height = int(quality) if quality.isdigit() else height
|
|
163
|
+
# Rough 16:9 aspect ratio calculation for width if it's dynamic
|
|
164
|
+
stream_width = int(stream_height * (16 / 9)) if quality.isdigit() else width
|
|
165
|
+
|
|
166
|
+
# Append the stream info tag with attributes
|
|
167
|
+
m3u8_lines.append(
|
|
168
|
+
f'#EXT-X-STREAM-INF:BANDWIDTH={bandwidth},'
|
|
169
|
+
f'RESOLUTION={stream_width}x{stream_height},'
|
|
170
|
+
f'NAME="{quality}p"'
|
|
171
|
+
)
|
|
172
|
+
# The line immediately following the tag must be the URI
|
|
173
|
+
m3u8_lines.append(url)
|
|
174
|
+
|
|
175
|
+
return "\n".join(m3u8_lines)
|
|
176
|
+
|
|
177
|
+
async def download(self, configuration: DownloadConfigHLS) -> bool | DownloadReport:
|
|
178
|
+
config = copy.deepcopy(configuration)
|
|
179
|
+
config.m3u8_base_url = self.m3u8_base_url
|
|
180
|
+
|
|
181
|
+
if not config.no_title:
|
|
182
|
+
config.path = os.path.join(config.path, f"{self.title}.mp4")
|
|
183
|
+
|
|
184
|
+
try:
|
|
185
|
+
return await self.core.download(config)
|
|
186
|
+
|
|
187
|
+
except Exception as e:
|
|
188
|
+
raise DownloadFailed(str(e))
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@dataclass(kw_only=True, slots=True)
|
|
192
|
+
class Playlist(BaseMedia):
|
|
193
|
+
url: str
|
|
194
|
+
core: BaseCore
|
|
195
|
+
title: str | None = None
|
|
196
|
+
author_name: str | None = None
|
|
197
|
+
rating_percent: str | None = None
|
|
198
|
+
rating_count: str | None = None
|
|
199
|
+
views: str | None = None
|
|
200
|
+
videos_count: str | None = None
|
|
201
|
+
|
|
202
|
+
async def _perform_load(self, api: bool, html: bool, anything_else: bool):
|
|
203
|
+
if html:
|
|
204
|
+
await asyncio.gather(self._fetch_html())
|
|
205
|
+
|
|
206
|
+
async def _fetch_html(self):
|
|
207
|
+
html_content = await get_html_content(url=self.url, core=self.core)
|
|
208
|
+
assert isinstance(html_content, str)
|
|
209
|
+
data: dict = await asyncio.to_thread(self._extract_html, html_content)
|
|
210
|
+
allowed_fields = {field.name for field in fields(self)}
|
|
211
|
+
|
|
212
|
+
for key, value in data.items():
|
|
213
|
+
if key in allowed_fields:
|
|
214
|
+
setattr(self, key, value)
|
|
215
|
+
|
|
216
|
+
@staticmethod
|
|
217
|
+
def _extract_html(html_content: str) -> dict:
|
|
218
|
+
parser = LexborHTMLParser(html_content)
|
|
219
|
+
|
|
220
|
+
title = parser.css_first("h1#playlist_title").text(strip=True)
|
|
221
|
+
author_name = parser.css_first("p.playlist_desc").css_first("a").text(strip=True)
|
|
222
|
+
rating_percent = parser.css_first("div.rating_percent.js_rating_percent").text(strip=True)
|
|
223
|
+
rating_count = parser.css_first("span.playlist_stats_value").text(strip=True)
|
|
224
|
+
views = parser.css("span.playlist_stats_value")[1].text(strip=True)
|
|
225
|
+
video_count = parser.css("span.playlist_stats_value")[2].text(strip=True)
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
"title": title,
|
|
229
|
+
"author_name": author_name,
|
|
230
|
+
"rating_percent": rating_percent,
|
|
231
|
+
"rating_count": rating_count,
|
|
232
|
+
"views": views,
|
|
233
|
+
"video_count": video_count
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async def get_videos(self, pages: int = 2,
|
|
237
|
+
videos_concurrency: int | None = None,
|
|
238
|
+
pages_concurrency: int | None = None,
|
|
239
|
+
on_video_error: on_error_hint = on_error,
|
|
240
|
+
on_page_error: on_error_hint = None,
|
|
241
|
+
keep_original_order: bool = False,
|
|
242
|
+
load_html: bool = False) -> AsyncGenerator[ScrapeResult, None]:
|
|
243
|
+
url = self.url
|
|
244
|
+
helper = Helper(core=self.core, constructor=Video)
|
|
245
|
+
page_urls = [f"{url}&page={page}" for page in range(1, pages + 1)]
|
|
246
|
+
videos_concurrency = videos_concurrency or self.core.configuration.videos_concurrency
|
|
247
|
+
pages_concurrency = pages_concurrency or self.core.configuration.pages_concurrency
|
|
248
|
+
assert videos_concurrency and pages_concurrency
|
|
249
|
+
async for result in helper.iterator(target_page_urls=page_urls, max_video_concurrency=videos_concurrency,
|
|
250
|
+
max_page_concurrency=pages_concurrency, video_link_extractor=extractor_search,
|
|
251
|
+
on_video_error=on_video_error, keep_original_order=keep_original_order,
|
|
252
|
+
on_page_error=on_page_error, fetch_html=load_html):
|
|
253
|
+
yield result
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@dataclass(kw_only=True, slots=True)
|
|
257
|
+
class UserHelper(BaseMedia):
|
|
258
|
+
url: str
|
|
259
|
+
core: BaseCore
|
|
260
|
+
name: str | None = None
|
|
261
|
+
|
|
262
|
+
async def _perform_load(self, api: bool, html: bool, anything_else: bool):
|
|
263
|
+
if html:
|
|
264
|
+
await asyncio.gather(self._fetch_html())
|
|
265
|
+
|
|
266
|
+
async def _fetch_html(self):
|
|
267
|
+
html_content = await get_html_content(core=self.core, url=self.url)
|
|
268
|
+
assert isinstance(html_content, str)
|
|
269
|
+
data: dict = await asyncio.to_thread(self._extract_html, html_content)
|
|
270
|
+
allowed_fields = {field.name for field in fields(self)}
|
|
271
|
+
|
|
272
|
+
for key, value in data.items():
|
|
273
|
+
if key in allowed_fields:
|
|
274
|
+
setattr(self, key, value)
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
def _extract_html(html_content: str) -> dict:
|
|
278
|
+
parser = LexborHTMLParser(html_content)
|
|
279
|
+
try:
|
|
280
|
+
name = parser.css_first("h1.name-title").text(strip=True)
|
|
281
|
+
|
|
282
|
+
except AttributeError:
|
|
283
|
+
name = re.findall(r'username: "(.*?)"', html_content)[1]
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
"name": name,
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async def get_videos(self, pages: int = 2,
|
|
290
|
+
videos_concurrency: int | None = None,
|
|
291
|
+
pages_concurrency: int | None = None,
|
|
292
|
+
on_video_error: on_error_hint = on_error,
|
|
293
|
+
on_page_error: on_error_hint = None,
|
|
294
|
+
keep_original_order: bool = False,
|
|
295
|
+
load_html: bool = False,
|
|
296
|
+
) -> AsyncGenerator[ScrapeResult, None]:
|
|
297
|
+
|
|
298
|
+
helper = Helper(core=self.core, constructor=Video)
|
|
299
|
+
url = self.url
|
|
300
|
+
page_urls = [f"{url}?page={page}" for page in range(1, pages + 1)]
|
|
301
|
+
videos_concurrency = videos_concurrency or self.core.configuration.videos_concurrency
|
|
302
|
+
pages_concurrency = pages_concurrency or self.core.configuration.pages_concurrency
|
|
303
|
+
assert videos_concurrency and pages_concurrency
|
|
304
|
+
async for result in helper.iterator(target_page_urls=page_urls, max_video_concurrency=videos_concurrency,
|
|
305
|
+
max_page_concurrency=pages_concurrency, video_link_extractor=extractor_search,
|
|
306
|
+
on_video_error=on_video_error, keep_original_order=keep_original_order,
|
|
307
|
+
on_page_error=on_page_error, fetch_html=load_html):
|
|
308
|
+
yield result
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@dataclass(kw_only=True, slots=True)
|
|
312
|
+
class Pornstar(UserHelper):
|
|
313
|
+
pornstar_information: dict | None = None
|
|
314
|
+
|
|
315
|
+
@classmethod
|
|
316
|
+
def _extract_html(cls, html_content: str) -> dict:
|
|
317
|
+
data = super(Pornstar, cls)._extract_html(html_content)
|
|
318
|
+
|
|
319
|
+
parser = LexborHTMLParser(html_content)
|
|
320
|
+
|
|
321
|
+
thing = {}
|
|
322
|
+
keys = parser.css("p.info-stat-label")
|
|
323
|
+
values = parser.css("p.info-stat-data")
|
|
324
|
+
|
|
325
|
+
for key, value in zip(keys, values):
|
|
326
|
+
thing.update({key.text: value.text})
|
|
327
|
+
|
|
328
|
+
data["pornstar_information"] = thing
|
|
329
|
+
return data
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
@dataclass(kw_only=True, slots=True)
|
|
333
|
+
class Amateur(UserHelper):
|
|
334
|
+
pass
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@dataclass(kw_only=True, slots=True)
|
|
338
|
+
class Channel(UserHelper):
|
|
339
|
+
url: str
|
|
340
|
+
core: BaseCore
|
|
341
|
+
name: str | None = None
|
|
342
|
+
rank: str | None = None
|
|
343
|
+
views: str | None = None
|
|
344
|
+
videos_count: str | None = None
|
|
345
|
+
|
|
346
|
+
async def _perform_load(self, api: bool, html: bool, anything_else: bool):
|
|
347
|
+
if html:
|
|
348
|
+
await asyncio.gather(self._fetch_html())
|
|
349
|
+
|
|
350
|
+
async def _fetch_html(self):
|
|
351
|
+
html_content = await get_html_content(core=self.core, url=self.url)
|
|
352
|
+
assert isinstance(html_content, str)
|
|
353
|
+
data: dict = await asyncio.to_thread(self._extract_html, html_content)
|
|
354
|
+
allowed_fields = {field.name for field in fields(self)}
|
|
355
|
+
for key, value in data.items():
|
|
356
|
+
if key in allowed_fields:
|
|
357
|
+
setattr(self, key, value)
|
|
358
|
+
|
|
359
|
+
@staticmethod
|
|
360
|
+
def _extract_html(html_content: str) -> dict:
|
|
361
|
+
parser = LexborHTMLParser(html_content)
|
|
362
|
+
name = parser.css_first("h1.name-title").text(strip=True)
|
|
363
|
+
rank = parser.css_first("p.info-stat-data").text(strip=True)
|
|
364
|
+
views = parser.css("p.info-stat-data")[1].text(strip=True)
|
|
365
|
+
videos_count = parser.css("p.info-stat-data")[2].text(strip=True)
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
"name": name,
|
|
369
|
+
"rank": rank,
|
|
370
|
+
"views": views,
|
|
371
|
+
"videos_count": videos_count,
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class Client:
|
|
376
|
+
def __init__(self, core: BaseCore = BaseCore()):
|
|
377
|
+
self.core = core
|
|
378
|
+
self.core.initialize_session()
|
|
379
|
+
assert isinstance(self.core.session, AsyncSession)
|
|
380
|
+
self.core.session.headers.update(HEADERS)
|
|
381
|
+
self.core.session.cookies.update(COOKIES)
|
|
382
|
+
|
|
383
|
+
async def get_video(self, url: str, load_html: bool = True) -> Video:
|
|
384
|
+
video = Video(core=self.core, url=url)
|
|
385
|
+
return await video.load(html=load_html)
|
|
386
|
+
|
|
387
|
+
async def get_pornstar(self, url: str, load_html: bool = True) -> Pornstar:
|
|
388
|
+
pornstar = Pornstar(core=self.core, url=url)
|
|
389
|
+
return await pornstar.load(html=load_html)
|
|
390
|
+
|
|
391
|
+
async def get_playlist(self, url: str, load_html: bool = True) -> Playlist:
|
|
392
|
+
playlist = Playlist(core=self.core, url=url)
|
|
393
|
+
return await playlist.load(html=load_html)
|
|
394
|
+
|
|
395
|
+
async def get_channel(self, url: str, load_html: bool = True) -> Channel:
|
|
396
|
+
channel = Channel(core=self.core, url=url)
|
|
397
|
+
return await channel.load(html=load_html)
|
|
398
|
+
|
|
399
|
+
async def get_amateur(self, url: str, load_html: bool = True) -> Amateur:
|
|
400
|
+
amateur = Amateur(core=self.core, url=url)
|
|
401
|
+
return await amateur.load(html=load_html)
|
|
402
|
+
|
|
403
|
+
async def search(self, query: str, pages: int = 2,
|
|
404
|
+
videos_concurrency: int | None = None,
|
|
405
|
+
pages_concurrency: int | None = None,
|
|
406
|
+
on_video_error: on_error_hint = on_error,
|
|
407
|
+
on_page_error: on_error_hint = None
|
|
408
|
+
) -> AsyncGenerator[Video, None]:
|
|
409
|
+
# I am too lazy to implement search filters
|
|
410
|
+
helper = Helper(core=self.core, constructor=Video)
|
|
411
|
+
page_urls = [f"https://thumbzilla.com/search/?query={query}&page={page}" for page in range(1, pages + 1)]
|
|
412
|
+
videos_concurrency = videos_concurrency or self.core.configuration.videos_concurrency
|
|
413
|
+
pages_concurrency = pages_concurrency or self.core.configuration.pages_concurrency
|
|
414
|
+
assert videos_concurrency and pages_concurrency
|
|
415
|
+
|
|
416
|
+
async for video in helper.iterator(target_page_urls=page_urls, max_video_concurrency=videos_concurrency,
|
|
417
|
+
max_page_concurrency=pages_concurrency, video_link_extractor=extractor_search,
|
|
418
|
+
on_video_error=on_video_error,
|
|
419
|
+
on_page_error=on_page_error):
|
|
420
|
+
yield video
|
|
File without changes
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from curl_cffi import Response
|
|
3
|
+
from selectolax.lexbor import LexborHTMLParser
|
|
4
|
+
|
|
5
|
+
HEADERS = {
|
|
6
|
+
'Accept': '*/*',
|
|
7
|
+
'Accept-Language': 'en,en-US',
|
|
8
|
+
'Connection': 'keep-alive',
|
|
9
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0',
|
|
10
|
+
'Referer': 'https://www.thumbzilla.com/',
|
|
11
|
+
'Origin': 'https://www.thumbzilla.com',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
COOKIES = {
|
|
15
|
+
'access': '1',
|
|
16
|
+
'cookieConsent': '1',
|
|
17
|
+
'platform': 'pc'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Set up logging configuration
|
|
21
|
+
logging.basicConfig(
|
|
22
|
+
level=logging.DEBUG,
|
|
23
|
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
|
24
|
+
)
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_text_safe(node, selector):
|
|
29
|
+
"""Safely extract and strip text from a CSS selector."""
|
|
30
|
+
target = node.css_first(selector)
|
|
31
|
+
if target:
|
|
32
|
+
text = target.text(strip=True)
|
|
33
|
+
return text if text else None
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_attr_safe(node, selector, attr):
|
|
38
|
+
"""Safely extract an attribute from a CSS selector."""
|
|
39
|
+
target = node.css_first(selector) if selector else node
|
|
40
|
+
if target and target.attributes:
|
|
41
|
+
val = target.attributes.get(attr)
|
|
42
|
+
return val if val else None
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def extractor_search(html_content: str) -> list:
|
|
47
|
+
"""
|
|
48
|
+
Extracts comprehensive video attributes from HTML search results.
|
|
49
|
+
Returns a list of dictionaries.
|
|
50
|
+
"""
|
|
51
|
+
if isinstance(html_content, Response):
|
|
52
|
+
print(f"Status: {html_content.status_code}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
results = []
|
|
56
|
+
parser = LexborHTMLParser(html_content)
|
|
57
|
+
|
|
58
|
+
# 1. Locate the main container gracefully
|
|
59
|
+
stuff = parser.css_first("div.searchResults.full-row-thumbs.js_video_row.tm_search_result_videos")
|
|
60
|
+
if not stuff:
|
|
61
|
+
stuff = parser.css_first("div.full-row-thumbs")
|
|
62
|
+
if not stuff:
|
|
63
|
+
stuff = parser.css_first("ul.videos_grid")
|
|
64
|
+
|
|
65
|
+
if not stuff:
|
|
66
|
+
logger.error("Main video container not found in HTML. Aborting extraction.")
|
|
67
|
+
return results
|
|
68
|
+
|
|
69
|
+
# 2. Locate the video boxes
|
|
70
|
+
videos = stuff.css("article.video-box.pc.js_video-box.js-pop")
|
|
71
|
+
if not videos:
|
|
72
|
+
videos = stuff.css("a.video_link.tm_video_link.js_wrap_trigger_login.js_mpop.js-pop")
|
|
73
|
+
|
|
74
|
+
if not videos:
|
|
75
|
+
logger.warning("Container found, but no video elements were matched inside.")
|
|
76
|
+
return results
|
|
77
|
+
# 3. Iterate and Extract
|
|
78
|
+
for index, video in enumerate(videos, start=1):
|
|
79
|
+
# Base extraction using data-attributes (most reliable) and falling back to text/children
|
|
80
|
+
video_data = {
|
|
81
|
+
"video_id": get_attr_safe(video, None, "data-video-id"),
|
|
82
|
+
"title": get_attr_safe(video, None, "aria-label") or get_text_safe(video, ".video-title-text span"),
|
|
83
|
+
"video_url": get_attr_safe(video, "a", "href"),
|
|
84
|
+
"duration": get_text_safe(video, ".video-duration span"),
|
|
85
|
+
"author_name": get_attr_safe(video, None, "data-uploader-name") or get_text_safe(video,
|
|
86
|
+
".author-title-text"),
|
|
87
|
+
"uploader_url": get_attr_safe(video, ".author-title-text", "href"),
|
|
88
|
+
"thumbnail": get_attr_safe(video, "img.thumb-image", "data-src") or get_attr_safe(video,
|
|
89
|
+
"img.thumb-image",
|
|
90
|
+
"src"),
|
|
91
|
+
"preview_video_url": get_attr_safe(video, "img.thumb-image", "data-mediabook"),
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Extract the list of performers separately
|
|
95
|
+
performer_nodes = video.css(".channel-performer")
|
|
96
|
+
performers = [p.text(strip=True) for p in performer_nodes] if performer_nodes else []
|
|
97
|
+
video_data["performers"] = performers if performers else None
|
|
98
|
+
# Clean up and validate specific fields
|
|
99
|
+
|
|
100
|
+
if video_data["video_url"]:
|
|
101
|
+
video_data["url"] = f"https://www.thumbzilla.com{video_data['video_url']}"
|
|
102
|
+
|
|
103
|
+
# 4. Handle Edge Cases & Logging
|
|
104
|
+
missing_attrs = [key for key, value in video_data.items() if value is None]
|
|
105
|
+
video_data.pop("video_url")
|
|
106
|
+
if missing_attrs:
|
|
107
|
+
# Create a useful identifier for the log (use video_id if it exists, else the loop index)
|
|
108
|
+
identifier = video_data.get('video_id') or f"Index #{index}"
|
|
109
|
+
logger.warning(f"Video [{identifier}] is missing attributes: {', '.join(missing_attrs)}")
|
|
110
|
+
results.append(video_data)
|
|
111
|
+
|
|
112
|
+
return results
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class NotFound(Exception):
|
|
2
|
+
def __init__(self, msg: str):
|
|
3
|
+
self.msg = msg
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class NetworkError(Exception):
|
|
7
|
+
def __init__(self, msg: str):
|
|
8
|
+
self.msg = msg
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BotDetection(Exception):
|
|
12
|
+
def __init__(self, msg: str):
|
|
13
|
+
self.msg = msg
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ProxyError(Exception):
|
|
17
|
+
def __init__(self, msg: str):
|
|
18
|
+
self.msg = msg
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class UnknownNetworkError(Exception):
|
|
22
|
+
def __init__(self, msg):
|
|
23
|
+
self.msg = msg
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DownloadFailed(Exception):
|
|
27
|
+
def __init__(self, msg: str):
|
|
28
|
+
self.msg = msg
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from thumbzilla_api import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.asyncio
|
|
6
|
+
async def test_all():
|
|
7
|
+
client = Client()
|
|
8
|
+
amateur = await client.get_amateur("https://www.thumbzilla.com/amateur/0princesspeachy0-ph/")
|
|
9
|
+
|
|
10
|
+
assert isinstance(amateur.name, str) and len(amateur.name) > 0
|
|
11
|
+
|
|
12
|
+
idx = 0
|
|
13
|
+
async for video in amateur.get_videos():
|
|
14
|
+
idx += 1
|
|
15
|
+
|
|
16
|
+
assert isinstance(video.video.title, str)
|
|
17
|
+
|
|
18
|
+
if idx >= 3:
|
|
19
|
+
break
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from thumbzilla_api import Client
|
|
3
|
+
|
|
4
|
+
@pytest.mark.asyncio
|
|
5
|
+
async def test_all():
|
|
6
|
+
client = Client()
|
|
7
|
+
channel = await client.get_channel("https://www.thumbzilla.com/channel/brazzers/")
|
|
8
|
+
|
|
9
|
+
assert isinstance(channel.name, str) and len(channel.name) > 0
|
|
10
|
+
assert isinstance(channel.views, str) and len(channel.views) > 0
|
|
11
|
+
assert isinstance(channel.rank, str) and len(channel.rank) > 0
|
|
12
|
+
assert isinstance(channel.videos_count, str) and len(channel.videos_count) > 0
|
|
13
|
+
|
|
14
|
+
idx = 0
|
|
15
|
+
async for video in channel.get_videos():
|
|
16
|
+
idx += 1
|
|
17
|
+
assert isinstance(video.video.title, str) and len(video.video.title) > 0
|
|
18
|
+
|
|
19
|
+
if idx >= 3:
|
|
20
|
+
break
|
|
21
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from thumbzilla_api import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.asyncio
|
|
6
|
+
async def test_all():
|
|
7
|
+
client = Client()
|
|
8
|
+
pornstar = await client.get_pornstar("https://www.thumbzilla.com/pornstar/nancy-a/")
|
|
9
|
+
|
|
10
|
+
idx = 0
|
|
11
|
+
async for video in pornstar.get_videos():
|
|
12
|
+
idx += 1
|
|
13
|
+
|
|
14
|
+
assert isinstance(video.video.title, str) and len(video.video.title) > 0
|
|
15
|
+
|
|
16
|
+
if idx >= 3:
|
|
17
|
+
break
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from thumbzilla_api import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.asyncio
|
|
6
|
+
async def test_search():
|
|
7
|
+
client = Client()
|
|
8
|
+
idx = 0
|
|
9
|
+
|
|
10
|
+
async for video in client.search(query="nancy a"):
|
|
11
|
+
idx += 1
|
|
12
|
+
assert isinstance(video.video.title, str) and len(video.video.title) > 0
|
|
13
|
+
|
|
14
|
+
if idx >= 3:
|
|
15
|
+
break
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from thumbzilla_api import Client
|
|
4
|
+
from base_api import DownloadConfigHLS
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.mark.asyncio
|
|
8
|
+
async def test_all():
|
|
9
|
+
client = Client()
|
|
10
|
+
video = await client.get_video("https://www.thumbzilla.com/watch/231853081/")
|
|
11
|
+
|
|
12
|
+
assert isinstance(video.title, str) and len(video.title) > 0
|
|
13
|
+
assert isinstance(video.video_id, str) and len(video.video_id) > 0
|
|
14
|
+
assert isinstance(video.media_definitions, list) and len(video.media_definitions) > 0
|
|
15
|
+
assert isinstance(video.duration, int) and len(str(video.duration)) > 0
|
|
16
|
+
assert isinstance(video.thumbnail, str) and len(video.thumbnail) > 0
|
|
17
|
+
assert isinstance(video.author_name, str) and len(video.author_name) > 0
|
|
18
|
+
|
|
19
|
+
config = DownloadConfigHLS(quality="worst", return_report=True)
|
|
20
|
+
stuff = await video.download(config)
|
|
21
|
+
assert stuff.status == "completed"
|