xnxx_api 1.6.3__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.
- xnxx_api-1.6.3/LICENSE +56 -0
- xnxx_api-1.6.3/PKG-INFO +108 -0
- xnxx_api-1.6.3/README.md +86 -0
- xnxx_api-1.6.3/pyproject.toml +41 -0
- xnxx_api-1.6.3/xnxx_api/__init__.py +10 -0
- xnxx_api-1.6.3/xnxx_api/modules/__init__.py +0 -0
- xnxx_api-1.6.3/xnxx_api/modules/category.py +0 -0
- xnxx_api-1.6.3/xnxx_api/modules/consts.py +52 -0
- xnxx_api-1.6.3/xnxx_api/modules/errors.py +13 -0
- xnxx_api-1.6.3/xnxx_api/modules/search_filters.py +20 -0
- xnxx_api-1.6.3/xnxx_api/tests/__init__.py +0 -0
- xnxx_api-1.6.3/xnxx_api/tests/test_search.py +11 -0
- xnxx_api-1.6.3/xnxx_api/tests/test_user.py +19 -0
- xnxx_api-1.6.3/xnxx_api/tests/test_video.py +86 -0
- xnxx_api-1.6.3/xnxx_api/xnxx_api.py +367 -0
xnxx_api-1.6.3/LICENSE
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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.
|
xnxx_api-1.6.3/PKG-INFO
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xnxx_api
|
|
3
|
+
Version: 1.6.3
|
|
4
|
+
Summary: A Python API for the Porn Site xnxx.com
|
|
5
|
+
Author: Johannes Habel
|
|
6
|
+
Author-email: Johannes Habel <EchterAlsFake@proton.me>
|
|
7
|
+
License-Expression: LGPL-3.0-only
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Programming Language :: Python
|
|
10
|
+
Requires-Dist: bs4
|
|
11
|
+
Requires-Dist: eaf-base-api
|
|
12
|
+
Requires-Dist: m3u8
|
|
13
|
+
Requires-Dist: av ; python_full_version >= '3.10' and extra == 'av'
|
|
14
|
+
Requires-Dist: lxml ; extra == 'full'
|
|
15
|
+
Requires-Dist: httpx[http2] ; extra == 'full'
|
|
16
|
+
Requires-Dist: httpx[socks] ; extra == 'full'
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Project-URL: Homepage, https://github.com/EchterAlsFake/xnxx_api
|
|
19
|
+
Provides-Extra: av
|
|
20
|
+
Provides-Extra: full
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
<h1 align="center">XNXX API</h1>
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
<a href="https://pepy.tech/project/xnxx_api"><img src="https://static.pepy.tech/badge/xnxx_api" alt="Downloads"></a>
|
|
27
|
+
<a href="https://github.com/EchterAlsFake/xnxx_api/workflows/"><img src="https://github.com/EchterAlsFake/xnxx_api/workflows/CodeQL/badge.svg" alt="CodeQL Analysis"/></a>
|
|
28
|
+
<a href="https://echteralsfake.me/ci/xnxx_api/badge.svg"><img src="https://echteralsfake.me/ci/xnxx_api/badge.svg" alt="API Tests"/></a>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
# Disclaimer
|
|
32
|
+
> [!IMPORTANT]
|
|
33
|
+
> This is an unofficial and unaffiliated project. Please read the full disclaimer before use:
|
|
34
|
+
> **[DISCLAIMER.md](https://github.com/EchterAlsFake/API_Docs/blob/master/Disclaimer.md)**
|
|
35
|
+
>
|
|
36
|
+
> By using this project you agree to comply with the target site’s rules, copyright/licensing requirements,
|
|
37
|
+
> and applicable laws. Do not use it to bypass access controls or scrape at disruptive rates.
|
|
38
|
+
|
|
39
|
+
# Features
|
|
40
|
+
- Fetch videos + metadata
|
|
41
|
+
- Download videos
|
|
42
|
+
- Fetch users
|
|
43
|
+
- Search for videos
|
|
44
|
+
- Built-in caching
|
|
45
|
+
- Easy interface
|
|
46
|
+
- Great type hinting
|
|
47
|
+
- Proxy support
|
|
48
|
+
- Very customizable
|
|
49
|
+
|
|
50
|
+
# Supported Platforms
|
|
51
|
+
This API has been tested and confirmed working on:
|
|
52
|
+
|
|
53
|
+
- Windows 11 (x64)
|
|
54
|
+
- macOS Sequoia (x86_64)
|
|
55
|
+
- Linux (Arch) (x86_64)
|
|
56
|
+
- Android 16 (aarch64)
|
|
57
|
+
|
|
58
|
+
# Quickstart
|
|
59
|
+
|
|
60
|
+
### Have a look at the [Documentation](https://github.com/EchterAlsFake/API_Docs/blob/master/Porn_APIs/XNXX.md) for more details
|
|
61
|
+
|
|
62
|
+
- Install the library with `pip install xnxx_api`
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from xnxx_api import Client
|
|
67
|
+
# Initialize a Client object
|
|
68
|
+
client = Client()
|
|
69
|
+
|
|
70
|
+
# Fetch a video
|
|
71
|
+
video_object = client.get_video("<insert_url_here>")
|
|
72
|
+
|
|
73
|
+
# Information from Video objects
|
|
74
|
+
print(video_object.title)
|
|
75
|
+
print(video_object.likes)
|
|
76
|
+
# Download the video
|
|
77
|
+
|
|
78
|
+
video_object.download(downloader="threaded", quality="best", path="your_output_path + filename")
|
|
79
|
+
|
|
80
|
+
# SEE DOCUMENTATION FOR MORE
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> [!NOTE]
|
|
84
|
+
> XNXX API can also be used from the command line. Do: xnxx_api -h to see the options
|
|
85
|
+
|
|
86
|
+
# Changelog
|
|
87
|
+
See [Changelog](https://github.com/EchterAlsFake/xnxx_api/blob/master/README/Changelog.md) for more details.
|
|
88
|
+
|
|
89
|
+
# Support (Donations)
|
|
90
|
+
I am developing all my projects entirely for free. I do that because I have fun and I don't want
|
|
91
|
+
to charge 30€ like other people do.
|
|
92
|
+
|
|
93
|
+
However, if you find my work useful, please consider donating something. A tiny amount such as 1€
|
|
94
|
+
means a lot to me.
|
|
95
|
+
|
|
96
|
+
Paypal: https://paypal.me/EchterAlsFake
|
|
97
|
+
<br>XMR (Monero): `42XwGZYbSxpMvhn9eeP4DwMwZV91tQgAm3UQr6Zwb2wzBf5HcuZCHrsVxa4aV2jhP4gLHsWWELxSoNjfnkt4rMfDDwXy9jR`
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Contribution
|
|
101
|
+
Do you see any issues or having some feature requests? Simply open an Issue or talk
|
|
102
|
+
in the discussions.
|
|
103
|
+
|
|
104
|
+
Pull requests are also welcome.
|
|
105
|
+
|
|
106
|
+
# License
|
|
107
|
+
Licensed under the LGPLv3 License
|
|
108
|
+
<br>Copyright (C) 2023–2025 Johannes Habel
|
xnxx_api-1.6.3/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<h1 align="center">XNXX API</h1>
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/xnxx_api"><img src="https://static.pepy.tech/badge/xnxx_api" alt="Downloads"></a>
|
|
5
|
+
<a href="https://github.com/EchterAlsFake/xnxx_api/workflows/"><img src="https://github.com/EchterAlsFake/xnxx_api/workflows/CodeQL/badge.svg" alt="CodeQL Analysis"/></a>
|
|
6
|
+
<a href="https://echteralsfake.me/ci/xnxx_api/badge.svg"><img src="https://echteralsfake.me/ci/xnxx_api/badge.svg" alt="API Tests"/></a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
# Disclaimer
|
|
10
|
+
> [!IMPORTANT]
|
|
11
|
+
> This is an unofficial and unaffiliated project. Please read the full disclaimer before use:
|
|
12
|
+
> **[DISCLAIMER.md](https://github.com/EchterAlsFake/API_Docs/blob/master/Disclaimer.md)**
|
|
13
|
+
>
|
|
14
|
+
> By using this project you agree to comply with the target site’s rules, copyright/licensing requirements,
|
|
15
|
+
> and applicable laws. Do not use it to bypass access controls or scrape at disruptive rates.
|
|
16
|
+
|
|
17
|
+
# Features
|
|
18
|
+
- Fetch videos + metadata
|
|
19
|
+
- Download videos
|
|
20
|
+
- Fetch users
|
|
21
|
+
- Search for videos
|
|
22
|
+
- Built-in caching
|
|
23
|
+
- Easy interface
|
|
24
|
+
- Great type hinting
|
|
25
|
+
- Proxy support
|
|
26
|
+
- Very customizable
|
|
27
|
+
|
|
28
|
+
# Supported Platforms
|
|
29
|
+
This API has been tested and confirmed working on:
|
|
30
|
+
|
|
31
|
+
- Windows 11 (x64)
|
|
32
|
+
- macOS Sequoia (x86_64)
|
|
33
|
+
- Linux (Arch) (x86_64)
|
|
34
|
+
- Android 16 (aarch64)
|
|
35
|
+
|
|
36
|
+
# Quickstart
|
|
37
|
+
|
|
38
|
+
### Have a look at the [Documentation](https://github.com/EchterAlsFake/API_Docs/blob/master/Porn_APIs/XNXX.md) for more details
|
|
39
|
+
|
|
40
|
+
- Install the library with `pip install xnxx_api`
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from xnxx_api import Client
|
|
45
|
+
# Initialize a Client object
|
|
46
|
+
client = Client()
|
|
47
|
+
|
|
48
|
+
# Fetch a video
|
|
49
|
+
video_object = client.get_video("<insert_url_here>")
|
|
50
|
+
|
|
51
|
+
# Information from Video objects
|
|
52
|
+
print(video_object.title)
|
|
53
|
+
print(video_object.likes)
|
|
54
|
+
# Download the video
|
|
55
|
+
|
|
56
|
+
video_object.download(downloader="threaded", quality="best", path="your_output_path + filename")
|
|
57
|
+
|
|
58
|
+
# SEE DOCUMENTATION FOR MORE
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> [!NOTE]
|
|
62
|
+
> XNXX API can also be used from the command line. Do: xnxx_api -h to see the options
|
|
63
|
+
|
|
64
|
+
# Changelog
|
|
65
|
+
See [Changelog](https://github.com/EchterAlsFake/xnxx_api/blob/master/README/Changelog.md) for more details.
|
|
66
|
+
|
|
67
|
+
# Support (Donations)
|
|
68
|
+
I am developing all my projects entirely for free. I do that because I have fun and I don't want
|
|
69
|
+
to charge 30€ like other people do.
|
|
70
|
+
|
|
71
|
+
However, if you find my work useful, please consider donating something. A tiny amount such as 1€
|
|
72
|
+
means a lot to me.
|
|
73
|
+
|
|
74
|
+
Paypal: https://paypal.me/EchterAlsFake
|
|
75
|
+
<br>XMR (Monero): `42XwGZYbSxpMvhn9eeP4DwMwZV91tQgAm3UQr6Zwb2wzBf5HcuZCHrsVxa4aV2jhP4gLHsWWELxSoNjfnkt4rMfDDwXy9jR`
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# Contribution
|
|
79
|
+
Do you see any issues or having some feature requests? Simply open an Issue or talk
|
|
80
|
+
in the discussions.
|
|
81
|
+
|
|
82
|
+
Pull requests are also welcome.
|
|
83
|
+
|
|
84
|
+
# License
|
|
85
|
+
Licensed under the LGPLv3 License
|
|
86
|
+
<br>Copyright (C) 2023–2025 Johannes Habel
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xnxx_api"
|
|
7
|
+
version = "1.6.3"
|
|
8
|
+
description = "A Python API for the Porn Site xnxx.com"
|
|
9
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "LGPL-3.0-only"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Johannes Habel", email = "EchterAlsFake@proton.me" }
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"bs4",
|
|
18
|
+
"eaf_base_api",
|
|
19
|
+
"m3u8",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Programming Language :: Python",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
av = ["av; python_version >= '3.10'"]
|
|
27
|
+
full = ["lxml", "httpx[http2]", "httpx[socks]"] # H2 for HTTP 2.0 support, LXML for faster parsing speed, though optional :)
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/EchterAlsFake/xnxx_api"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
xnxx_api = "xnxx_api.xnxx_api:main"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
packages = { find = {} }
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
[tool.uv.build-backend]
|
|
40
|
+
module-name = "xnxx_api"
|
|
41
|
+
module-root = ""
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# xnxx_api/__init__.py
|
|
2
|
+
|
|
3
|
+
__all__ = [
|
|
4
|
+
"Client", "BaseCore", "Video",
|
|
5
|
+
"errors", "consts", "search_filters", "category"
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
# Public API from xnxx_api.py
|
|
9
|
+
from xnxx_api.xnxx_api import Client, BaseCore, Video
|
|
10
|
+
from xnxx_api.modules import errors, consts, category, search_filters
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import html
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from typing import List
|
|
6
|
+
# ROOT URLs
|
|
7
|
+
ROOT_URL = "https://www.xnxx.com/"
|
|
8
|
+
|
|
9
|
+
# REGEX
|
|
10
|
+
REGEX_VIDEO_CHECK = re.compile(r"xnxx.com/(.*?)")
|
|
11
|
+
REGEX_VIDEO_TITLE = re.compile(r"html5player\.setVideoTitle\('([^']*)'\);")
|
|
12
|
+
REGEX_VIDEO_UPLOADER = re.compile(r"html5player\.setUploaderName\('([^']*)'\);")
|
|
13
|
+
REGEX_VIDEO_LIKES = re.compile(r'<span class="icon thumb-up"></span><span class="value">(.*?)</span>', re.DOTALL)
|
|
14
|
+
REGEX_VIDEO_DISLIKES = re.compile(r'<span class="icon thumb-down"></span><span class="value">(.*?)</span>', re.DOTALL)
|
|
15
|
+
REGEX_VIDEO_COMMENT_COUNT = re.compile(r'<span class="icon comments"></span><span class="value">(.*?)</span>')
|
|
16
|
+
REGEX_VIDEO_PORNSTARS = re.compile(r'<a class="is-pornstar" href="/search/(.*?)">')
|
|
17
|
+
REGEX_VIDEO_KEYWORDS = re.compile(r'<a class="is-keyword" href="/search/(.*?)">')
|
|
18
|
+
REGEX_VIDEO_M3U8 = re.compile(r"html5player\.setVideoHLS\('([^']+)'\);")
|
|
19
|
+
|
|
20
|
+
REGEX_SCRAPE_VIDEOS = re.compile(r'<div class="thumb"><a href="/video-(.*?)"')
|
|
21
|
+
|
|
22
|
+
REGEX_SEARCH_TOTAL_PAGES = re.compile(r'class="last-page">(.*?)</a>')
|
|
23
|
+
REGEX_MODEL_TOTAL_PAGES = re.compile(r'<a class="last-page" data-page="(.*?)">')
|
|
24
|
+
REGEX_MODEL_TOTAL_VIDEO_VIEWS = re.compile(r'<span class="icon-f icf-eye"></span> (.*?) video views')
|
|
25
|
+
|
|
26
|
+
headers = {
|
|
27
|
+
"Referer": "https://www.xnxx.com/"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def extractor_json(content: str) -> List[str]:
|
|
32
|
+
data = json.loads(html.unescape(content))
|
|
33
|
+
|
|
34
|
+
if data["code"] == 404:
|
|
35
|
+
return []
|
|
36
|
+
|
|
37
|
+
videos = data["videos"]
|
|
38
|
+
video_urls = []
|
|
39
|
+
for video in videos:
|
|
40
|
+
video_urls.append(f"https://xnxx.com{video.get('u')}")
|
|
41
|
+
|
|
42
|
+
return video_urls
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def extractor_html(content: str) -> List[str]:
|
|
46
|
+
urls = REGEX_SCRAPE_VIDEOS.findall(content)
|
|
47
|
+
video_urls = []
|
|
48
|
+
for url_ in urls:
|
|
49
|
+
if not "THUMBNUM" in url_:
|
|
50
|
+
video_urls.append(f"https://www.xnxx.com/video-{url_}")
|
|
51
|
+
|
|
52
|
+
return video_urls
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Length:
|
|
2
|
+
X_0_10min = "/0-10min"
|
|
3
|
+
X_10min_plus = "/10min+"
|
|
4
|
+
X_10_20min = "/10-20min"
|
|
5
|
+
X_20min_plus = "/20min+"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UploadTime:
|
|
9
|
+
year = "/year"
|
|
10
|
+
month = "/month"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchingQuality:
|
|
14
|
+
X_720p = "/hd-only"
|
|
15
|
+
X_1080p_plus = "/fullhd"
|
|
16
|
+
|
|
17
|
+
class Mode:
|
|
18
|
+
default = ""
|
|
19
|
+
hits = "/hits"
|
|
20
|
+
random = "/random"
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from ..xnxx_api import Client
|
|
2
|
+
|
|
3
|
+
client = Client()
|
|
4
|
+
user = client.get_user("https://www.xnxx.com/pornstar/cory-chase")
|
|
5
|
+
objects_video = ["title", "publish_date", "length", "author"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_video_views():
|
|
10
|
+
assert isinstance(user.total_video_views, str)
|
|
11
|
+
assert user.total_videos > 0
|
|
12
|
+
|
|
13
|
+
def test_videos():
|
|
14
|
+
for idx, video in enumerate(user.videos()):
|
|
15
|
+
if idx == 10:
|
|
16
|
+
break
|
|
17
|
+
for object in objects_video:
|
|
18
|
+
assert isinstance(getattr(video, object), str)
|
|
19
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from ..xnxx_api import Client
|
|
2
|
+
url = "https://www.xnxx.com/video-1b9bufc9/die_zierliche_stieftochter_passt_kaum_in_den_mund_ihres_stiefvaters"
|
|
3
|
+
# This will be the URL for all tests
|
|
4
|
+
|
|
5
|
+
video = Client().get_video(url)
|
|
6
|
+
|
|
7
|
+
def test_video_title():
|
|
8
|
+
title = video.title
|
|
9
|
+
assert isinstance(title, str) and len(title) > 0
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_author():
|
|
13
|
+
author = video.author
|
|
14
|
+
assert isinstance(author, str) and len(author) > 0
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_length():
|
|
18
|
+
length = video.length
|
|
19
|
+
assert isinstance(length, str) and len(length) > 0
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_highest_quality():
|
|
23
|
+
highest_quality = video.highest_quality
|
|
24
|
+
assert isinstance(highest_quality, str) and len(highest_quality) > 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_views():
|
|
28
|
+
views = video.views
|
|
29
|
+
assert isinstance(views, str) and len(views) > 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_comment_count():
|
|
33
|
+
comment_count = video.comment_count
|
|
34
|
+
assert isinstance(comment_count, str)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_likes():
|
|
38
|
+
likes = video.likes
|
|
39
|
+
assert isinstance(likes, str)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_dislikes():
|
|
43
|
+
dislikes = video.dislikes
|
|
44
|
+
assert isinstance(dislikes, str)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_pornstars():
|
|
48
|
+
pornstars = video.pornstars
|
|
49
|
+
assert isinstance(pornstars, list) # Some videos don't contain pornstars, which is why we don't test it here
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_description():
|
|
53
|
+
description = video.description
|
|
54
|
+
assert isinstance(description, str) and len(description) > 0
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_keywords():
|
|
58
|
+
tags = video.tags
|
|
59
|
+
assert isinstance(tags, list) and len(tags) > 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_thumbnail_url():
|
|
63
|
+
thumbnail_url = video.thumbnail_url
|
|
64
|
+
assert isinstance(thumbnail_url, list) and len(thumbnail_url) > 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_publish_date():
|
|
68
|
+
publish_date = video.publish_date
|
|
69
|
+
assert isinstance(publish_date, str) and len(publish_date) > 0
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_content_url():
|
|
73
|
+
content_url = video.content_url
|
|
74
|
+
assert isinstance(content_url, str) and len(content_url) > 0
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_get_segments():
|
|
78
|
+
segments = list(video.get_segments(quality="best"))
|
|
79
|
+
assert len(segments) > 10
|
|
80
|
+
|
|
81
|
+
def test_download_low():
|
|
82
|
+
fortnite_1 = video.download(quality="worst", remux=True, return_report=True)
|
|
83
|
+
fortnite_2 = video.download(quality="worst", remux=False, return_report=True)
|
|
84
|
+
|
|
85
|
+
assert fortnite_1["status"] == "completed"
|
|
86
|
+
assert fortnite_2["status"] == "completed"
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from modules.consts import *
|
|
3
|
+
from modules.errors import *
|
|
4
|
+
from modules.search_filters import *
|
|
5
|
+
|
|
6
|
+
except (ModuleNotFoundError, ImportError):
|
|
7
|
+
from .modules.consts import *
|
|
8
|
+
from .modules.errors import *
|
|
9
|
+
from .modules.search_filters import *
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import html
|
|
13
|
+
import json
|
|
14
|
+
import logging
|
|
15
|
+
import argparse
|
|
16
|
+
import threading
|
|
17
|
+
|
|
18
|
+
from httpx import Response
|
|
19
|
+
from bs4 import BeautifulSoup
|
|
20
|
+
from functools import cached_property
|
|
21
|
+
from typing import Union, Generator, Optional
|
|
22
|
+
from base_api.modules.config import RuntimeConfig
|
|
23
|
+
from base_api.base import BaseCore, setup_logger, Helper
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
import lxml
|
|
27
|
+
parser = "lxml"
|
|
28
|
+
|
|
29
|
+
except (ModuleNotFoundError, ImportError):
|
|
30
|
+
parser = "html.parser"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Video:
|
|
34
|
+
def __init__(self, url, core: Optional[BaseCore] = None):
|
|
35
|
+
self.url = url
|
|
36
|
+
self.core = core
|
|
37
|
+
self.available_m3u8_urls = None
|
|
38
|
+
self.script_content = None
|
|
39
|
+
self.html_content = None
|
|
40
|
+
self.metadata_matches = None
|
|
41
|
+
self.json_content = None
|
|
42
|
+
self.logger = setup_logger(name="XNXX API - [Video]", log_file=None, level=logging.CRITICAL)
|
|
43
|
+
|
|
44
|
+
if not REGEX_VIDEO_CHECK.search(self.url):
|
|
45
|
+
raise InvalidUrl("The video URL is invalid!")
|
|
46
|
+
|
|
47
|
+
else:
|
|
48
|
+
self.get_base_html()
|
|
49
|
+
self.get_script_content()
|
|
50
|
+
self.get_metadata_matches()
|
|
51
|
+
self.extract_json_from_html()
|
|
52
|
+
|
|
53
|
+
def enable_logging(self, log_file, level, log_ip: str = None, log_port: int = None):
|
|
54
|
+
self.logger = setup_logger(name="XNXX API - [Video]", log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
55
|
+
|
|
56
|
+
def get_base_html(self) -> None:
|
|
57
|
+
self.html_content = self.core.fetch(url=self.url)
|
|
58
|
+
if isinstance(self.html_content, Response):
|
|
59
|
+
raise RegionBlocked(f"The Video: {self.url} is not available in your country!")
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def is_desired_script(cls, tag):
|
|
63
|
+
if tag.name != "script":
|
|
64
|
+
return False
|
|
65
|
+
script_contents = ['html5player', 'setVideoTitle', 'setVideoUrlLow']
|
|
66
|
+
return all(content in tag.text for content in script_contents)
|
|
67
|
+
|
|
68
|
+
def get_metadata_matches(self) -> None:
|
|
69
|
+
soup = BeautifulSoup(self.html_content, parser)
|
|
70
|
+
metadata_span = soup.find('span', class_='metadata')
|
|
71
|
+
metadata_text = metadata_span.get_text()
|
|
72
|
+
|
|
73
|
+
# Use a regex to extract the desired strings
|
|
74
|
+
self.metadata_matches = re.findall(r'(\d+min|\d+p|\d[\d.,]*\s*[views]*)', metadata_text)
|
|
75
|
+
|
|
76
|
+
def get_script_content(self) -> None:
|
|
77
|
+
soup = BeautifulSoup(self.html_content, parser)
|
|
78
|
+
target_script = soup.find(self.is_desired_script)
|
|
79
|
+
if target_script:
|
|
80
|
+
self.script_content = target_script.text
|
|
81
|
+
|
|
82
|
+
else:
|
|
83
|
+
raise InvalidResponse("Couldn't extract JSON from HTML")
|
|
84
|
+
|
|
85
|
+
def extract_json_from_html(self) -> None:
|
|
86
|
+
soup = BeautifulSoup(self.html_content, parser)
|
|
87
|
+
# Find the <script> tag with type="application/ld+json"
|
|
88
|
+
script_tag = soup.find('script', {'type': 'application/ld+json'})
|
|
89
|
+
|
|
90
|
+
if script_tag:
|
|
91
|
+
json_text = script_tag.string.strip() # Get the content of the tag as a string
|
|
92
|
+
data = json.loads(json_text)
|
|
93
|
+
self.json_content = data
|
|
94
|
+
|
|
95
|
+
@cached_property
|
|
96
|
+
def m3u8_base_url(self) -> str:
|
|
97
|
+
"""
|
|
98
|
+
The m3u8 base URL is a file that contains the list of segments (.ts files) for the different resolutions.
|
|
99
|
+
This is basically the whole magic for all my APIs :)
|
|
100
|
+
:return: (str) The m3u8 base URL
|
|
101
|
+
"""
|
|
102
|
+
return REGEX_VIDEO_M3U8.search(self.script_content).group(1)
|
|
103
|
+
|
|
104
|
+
def get_segments(self, quality: str) -> list:
|
|
105
|
+
return self.core.get_segments(quality=quality, m3u8_url_master=self.m3u8_base_url)
|
|
106
|
+
|
|
107
|
+
def download(self, quality, path="./", callback=None, no_title=False, remux: bool = False,
|
|
108
|
+
callback_remux=None, start_segment: int = 0, stop_event: Optional[threading.Event] = None,
|
|
109
|
+
segment_state_path: Optional[str] = None, segment_dir: Optional[str] = None,
|
|
110
|
+
return_report: bool = False, cleanup_on_stop: bool = True, keep_segment_dir: bool = False
|
|
111
|
+
) -> bool:
|
|
112
|
+
"""
|
|
113
|
+
:param callback:
|
|
114
|
+
:param quality:
|
|
115
|
+
:param path:
|
|
116
|
+
:param no_title:
|
|
117
|
+
:param remux:
|
|
118
|
+
:param callback_remux:
|
|
119
|
+
:param start_segment:
|
|
120
|
+
:param stop_event:
|
|
121
|
+
:param segment_state_path:
|
|
122
|
+
:param segment_dir:
|
|
123
|
+
:param return_report:
|
|
124
|
+
:param cleanup_on_stop:
|
|
125
|
+
:param keep_segment_dir:
|
|
126
|
+
:return:
|
|
127
|
+
"""
|
|
128
|
+
if not no_title:
|
|
129
|
+
path = os.path.join(path, f"{self.title}.mp4")
|
|
130
|
+
|
|
131
|
+
return self.core.download(video=self, quality=quality, path=path, callback=callback, remux=remux,
|
|
132
|
+
callback_remux=callback_remux, start_segment=start_segment, stop_event=stop_event,
|
|
133
|
+
segment_state_path=segment_state_path, segment_dir=segment_dir, return_report=return_report,
|
|
134
|
+
cleanup_on_stop=cleanup_on_stop, keep_segment_dir=keep_segment_dir)
|
|
135
|
+
|
|
136
|
+
@cached_property
|
|
137
|
+
def title(self) -> str:
|
|
138
|
+
return html.unescape(REGEX_VIDEO_TITLE.search(self.script_content).group(1))
|
|
139
|
+
|
|
140
|
+
@cached_property
|
|
141
|
+
def author(self) -> str:
|
|
142
|
+
return REGEX_VIDEO_UPLOADER.search(self.script_content).group(1)
|
|
143
|
+
|
|
144
|
+
@cached_property
|
|
145
|
+
def length(self) -> str:
|
|
146
|
+
length = self.metadata_matches[0]
|
|
147
|
+
length = str(length).strip("min")
|
|
148
|
+
return length
|
|
149
|
+
|
|
150
|
+
@cached_property
|
|
151
|
+
def highest_quality(self) -> str:
|
|
152
|
+
return self.metadata_matches[1]
|
|
153
|
+
|
|
154
|
+
@cached_property
|
|
155
|
+
def views(self) -> str:
|
|
156
|
+
try:
|
|
157
|
+
views = self.metadata_matches[2]
|
|
158
|
+
|
|
159
|
+
except IndexError:
|
|
160
|
+
views = self.metadata_matches[1]
|
|
161
|
+
|
|
162
|
+
return views
|
|
163
|
+
|
|
164
|
+
@cached_property
|
|
165
|
+
def comment_count(self) -> str:
|
|
166
|
+
return REGEX_VIDEO_COMMENT_COUNT.search(self.html_content).group(1)
|
|
167
|
+
|
|
168
|
+
@cached_property
|
|
169
|
+
def likes(self) -> str:
|
|
170
|
+
return REGEX_VIDEO_LIKES.search(self.html_content).group(1)
|
|
171
|
+
|
|
172
|
+
@cached_property
|
|
173
|
+
def dislikes(self) -> str:
|
|
174
|
+
return REGEX_VIDEO_DISLIKES.search(self.html_content).group(1)
|
|
175
|
+
|
|
176
|
+
@cached_property
|
|
177
|
+
def pornstars(self) -> list:
|
|
178
|
+
pornstar_list = REGEX_VIDEO_PORNSTARS.findall(self.html_content)
|
|
179
|
+
pornstar_list_filtered = []
|
|
180
|
+
for pornstar in pornstar_list:
|
|
181
|
+
pornstar = str(pornstar).replace("+", " ")
|
|
182
|
+
pornstar_list_filtered.append(pornstar)
|
|
183
|
+
|
|
184
|
+
return pornstar_list_filtered
|
|
185
|
+
|
|
186
|
+
@cached_property
|
|
187
|
+
def tags(self) -> list:
|
|
188
|
+
tags_list = REGEX_VIDEO_KEYWORDS.findall(self.html_content)
|
|
189
|
+
tags_list_filtered = []
|
|
190
|
+
for tag in tags_list:
|
|
191
|
+
tag = str(tag).replace("+", " ")
|
|
192
|
+
tags_list_filtered.append(tag)
|
|
193
|
+
|
|
194
|
+
return tags_list_filtered
|
|
195
|
+
|
|
196
|
+
@cached_property
|
|
197
|
+
def description(self) -> str:
|
|
198
|
+
return html.unescape(self.json_content["description"])
|
|
199
|
+
|
|
200
|
+
@cached_property
|
|
201
|
+
def thumbnail_url(self) -> list:
|
|
202
|
+
return self.json_content["thumbnailUrl"]
|
|
203
|
+
|
|
204
|
+
@cached_property
|
|
205
|
+
def publish_date(self) -> str:
|
|
206
|
+
return self.json_content["uploadDate"]
|
|
207
|
+
|
|
208
|
+
@cached_property
|
|
209
|
+
def content_url(self) -> str:
|
|
210
|
+
return self.json_content["contentUrl"]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class Search(Helper):
|
|
214
|
+
def __init__(self, query: str, core: Optional[BaseCore], upload_time: Union[str, UploadTime], length: Union[str, Length], searching_quality:
|
|
215
|
+
Union[str, SearchingQuality], mode: Union[str, Mode]):
|
|
216
|
+
super().__init__(core, video=Video)
|
|
217
|
+
|
|
218
|
+
self.core = core
|
|
219
|
+
self.query = self.validate_query(query)
|
|
220
|
+
self.upload_time = upload_time
|
|
221
|
+
self.length = length
|
|
222
|
+
self.searching_quality = searching_quality
|
|
223
|
+
self.mode = mode
|
|
224
|
+
self.logger = setup_logger(name="XNXX API - [Search]", log_file=None, level=logging.CRITICAL)
|
|
225
|
+
|
|
226
|
+
def enable_logging(self, log_file, level, log_ip: str = None, log_port: int = None):
|
|
227
|
+
self.logger = setup_logger(name="XNXX API - [Search]", log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
228
|
+
|
|
229
|
+
@classmethod
|
|
230
|
+
def validate_query(cls, query):
|
|
231
|
+
return query.replace(" ", "+")
|
|
232
|
+
|
|
233
|
+
@cached_property
|
|
234
|
+
def html_content(self) -> str:
|
|
235
|
+
# Now this is going to be weird, just don't ask
|
|
236
|
+
return self.core.fetch(f"https://www.xnxx.com/search{self.mode}{self.upload_time}{self.length}{self.searching_quality}/{self.query}")
|
|
237
|
+
|
|
238
|
+
@cached_property
|
|
239
|
+
def total_pages(self) -> str:
|
|
240
|
+
return REGEX_SEARCH_TOTAL_PAGES.search(self.html_content).group(1)
|
|
241
|
+
|
|
242
|
+
def videos(self, pages_concurrency: int = None, videos_concurrency: int = None, pages: int = 0) -> Generator[Video, None, None]:
|
|
243
|
+
self.url = f"https://www.xnxx.com/search{self.mode}{self.upload_time}{self.length}{self.searching_quality}/{self.query}"
|
|
244
|
+
|
|
245
|
+
if pages >= int(self.total_pages):
|
|
246
|
+
self.logger.warning(f"You want to fetch: {pages}, but only: {self.total_pages} are available. Reducing!")
|
|
247
|
+
pages = int(self.total_pages)
|
|
248
|
+
|
|
249
|
+
page_urls = [self.url]
|
|
250
|
+
page_urls.extend([f"{self.url}/{page}" for page in range(1, int(pages))])
|
|
251
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
252
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
253
|
+
|
|
254
|
+
yield from self.iterator(page_urls=page_urls, videos_concurrency=videos_concurrency,
|
|
255
|
+
pages_concurrency=pages_concurrency, extractor=extractor_html)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class User(Helper):
|
|
259
|
+
def __init__(self, url: str, core: Optional[BaseCore]):
|
|
260
|
+
super().__init__(core, video=Video)
|
|
261
|
+
self.url = url
|
|
262
|
+
self.core = core
|
|
263
|
+
self.content = self.core.fetch(url)
|
|
264
|
+
self.logger = setup_logger(name="XNXX API - [User]", log_file=None, level=logging.CRITICAL)
|
|
265
|
+
|
|
266
|
+
def enable_logging(self, file, level, log_ip: str = None, log_port: int = None):
|
|
267
|
+
self.logger = setup_logger(name="XNXX API - [User]", log_file=file, level=level, http_ip=log_ip, http_port=log_port)
|
|
268
|
+
|
|
269
|
+
@cached_property
|
|
270
|
+
def base_json(self):
|
|
271
|
+
url = f"{self.url}/videos/best/0"
|
|
272
|
+
content = self.core.fetch(url)
|
|
273
|
+
data = json.loads(html.unescape(content))
|
|
274
|
+
return data
|
|
275
|
+
|
|
276
|
+
def videos(self, videos_concurrency: int = None, pages_concurrency: int = None,
|
|
277
|
+
pages: int = 0) -> Generator[Video, None, None]:
|
|
278
|
+
|
|
279
|
+
if pages > self.total_pages:
|
|
280
|
+
self.logger.warning(f"You are trying to fetch more pages than there are... Reducing to: {self.total_pages}")
|
|
281
|
+
pages = int(self.total_pages)
|
|
282
|
+
|
|
283
|
+
page_urls = [f"{self.url}/videos/best/{page}" for page in range(pages)]
|
|
284
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
285
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
286
|
+
yield from self.iterator(page_urls=page_urls, videos_concurrency=videos_concurrency,
|
|
287
|
+
pages_concurrency=pages_concurrency, extractor=extractor_json)
|
|
288
|
+
|
|
289
|
+
@cached_property
|
|
290
|
+
def total_videos(self) -> int:
|
|
291
|
+
return int(self.base_json["nb_videos"])
|
|
292
|
+
|
|
293
|
+
@cached_property
|
|
294
|
+
def total_pages(self) -> int:
|
|
295
|
+
return round(int(self.base_json["nb_per_page"]) // self.total_videos)
|
|
296
|
+
|
|
297
|
+
@cached_property
|
|
298
|
+
def total_video_views(self) -> str:
|
|
299
|
+
return REGEX_MODEL_TOTAL_VIDEO_VIEWS.search(self.content).group(1)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class Client:
|
|
303
|
+
def __init__(self, core: Optional[BaseCore] = None):
|
|
304
|
+
self.core = core or BaseCore(config=RuntimeConfig())
|
|
305
|
+
self.core.initialize_session()
|
|
306
|
+
self.core.session.headers.update({"Referer": "https://www.xnxx.com/"})
|
|
307
|
+
|
|
308
|
+
def get_video(self, url) -> Video:
|
|
309
|
+
"""
|
|
310
|
+
:param url: (str) The URL of the video
|
|
311
|
+
:return: (Video) The video object
|
|
312
|
+
"""
|
|
313
|
+
return Video(url, core=self.core)
|
|
314
|
+
|
|
315
|
+
def search(self, query: str, upload_time: Union[str, UploadTime] = "", length: Union[str, Length] = "",
|
|
316
|
+
searching_quality: Union[str, SearchingQuality] = "", mode: Union[str, Mode] = "") -> Search:
|
|
317
|
+
"""
|
|
318
|
+
:param query:
|
|
319
|
+
:param upload_time:
|
|
320
|
+
:param length:
|
|
321
|
+
:param searching_quality:
|
|
322
|
+
:param mode:
|
|
323
|
+
:return: (Search) the search object
|
|
324
|
+
"""
|
|
325
|
+
return Search(query=query, core=self.core, upload_time=upload_time, length=length,
|
|
326
|
+
searching_quality=searching_quality, mode=mode)
|
|
327
|
+
|
|
328
|
+
def get_user(self, url: str) -> User:
|
|
329
|
+
"""
|
|
330
|
+
:param url: (str) The user URL
|
|
331
|
+
:return: (User) The User object
|
|
332
|
+
"""
|
|
333
|
+
return User(url, core=self.core)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def main():
|
|
337
|
+
parser = argparse.ArgumentParser(description="API Command Line Interface")
|
|
338
|
+
parser.add_argument("--download", metavar="URL (str)", type=str, help="URL to download from")
|
|
339
|
+
parser.add_argument("--quality", metavar="best,half,worst", type=str, help="The video quality (best,half,worst)", required=True)
|
|
340
|
+
parser.add_argument("--file", metavar="Source to .txt file", type=str, help="(Optional) Specify a file with URLs (separated with new lines)")
|
|
341
|
+
parser.add_argument("--output", metavar="Output directory", type=str, help="The output path (with filename)", required=True)
|
|
342
|
+
parser.add_argument("--no-title", metavar="True,False", type=str, help="Whether to apply video title automatically to output path or not", required=True)
|
|
343
|
+
|
|
344
|
+
args = parser.parse_args()
|
|
345
|
+
no_title = BaseCore().str_to_bool(args.no_title)
|
|
346
|
+
|
|
347
|
+
if args.download:
|
|
348
|
+
client = Client()
|
|
349
|
+
video = client.get_video(args.download)
|
|
350
|
+
video.download(quality=args.quality, path=args.output, no_title=no_title)
|
|
351
|
+
|
|
352
|
+
if args.file:
|
|
353
|
+
videos = []
|
|
354
|
+
client = Client()
|
|
355
|
+
|
|
356
|
+
with open(args.file, "r") as file:
|
|
357
|
+
content = file.read().splitlines()
|
|
358
|
+
|
|
359
|
+
for url in content:
|
|
360
|
+
videos.append(client.get_video(url))
|
|
361
|
+
|
|
362
|
+
for video in videos:
|
|
363
|
+
video.download(quality=args.quality, path=args.output, downloader=args.downloader, no_title=no_title)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
if __name__ == "__main__":
|
|
367
|
+
main()
|