xvideos_api 1.8.2__py3-none-any.whl
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.
- xvideos_api/__init__.py +6 -0
- xvideos_api/modules/__init__.py +0 -0
- xvideos_api/modules/consts.py +52 -0
- xvideos_api/modules/errors.py +13 -0
- xvideos_api/modules/sorting.py +31 -0
- xvideos_api/tests/__init__.py +0 -0
- xvideos_api/tests/test_download.py +18 -0
- xvideos_api/tests/test_pornstar.py +14 -0
- xvideos_api/tests/test_search.py +75 -0
- xvideos_api/tests/test_video.py +63 -0
- xvideos_api/xvideos_api.py +591 -0
- xvideos_api-1.8.2.dist-info/METADATA +108 -0
- xvideos_api-1.8.2.dist-info/RECORD +16 -0
- xvideos_api-1.8.2.dist-info/WHEEL +4 -0
- xvideos_api-1.8.2.dist-info/entry_points.txt +3 -0
- xvideos_api-1.8.2.dist-info/licenses/LICENSE +56 -0
xvideos_api/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from typing import List
|
|
5
|
+
from urllib.parse import urljoin
|
|
6
|
+
from bs4 import SoupStrainer, BeautifulSoup
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
REGEX_VIDEO_CHECK_URL = re.compile(r'(.*?)xvideos.com/video(.*?)')
|
|
10
|
+
REGEX_VIDEO_M3U8 = re.compile(r"html5player\.setVideoHLS\('([^']+)'\);")
|
|
11
|
+
REGEX_IFRAME = re.compile(r'video-embed" type="text" readonly value="(.*?)" class="form-control"')
|
|
12
|
+
REGEX_SEARCH_SCRAPE_VIDEOS = re.compile(r'none;"><a href="(.*?)">', re.DOTALL)
|
|
13
|
+
|
|
14
|
+
headers = {
|
|
15
|
+
"Referer": "https://xvideos.com/",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def extractor_json(html: str) -> List[str]:
|
|
20
|
+
"""
|
|
21
|
+
Extracts the video URLs from a HTML. This function needs to be given to the iterator function
|
|
22
|
+
in the Helper class. See BaseCore (eaf_base_api)
|
|
23
|
+
|
|
24
|
+
This function is for JSON type returns e.g., /best/1 URL types. This does NOT work for HTML.
|
|
25
|
+
See extractor below.
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
data = json.loads(html)
|
|
29
|
+
video_urls = []
|
|
30
|
+
for u in (v.get("u") for v in data.get("videos", [])):
|
|
31
|
+
if not u:
|
|
32
|
+
continue
|
|
33
|
+
parts = str(u).split("/")
|
|
34
|
+
if len(parts) >= 6:
|
|
35
|
+
vid = parts[4]
|
|
36
|
+
slug = parts[5]
|
|
37
|
+
video_urls.append(f"https://www.xvideos.com/video.{vid}/{slug}")
|
|
38
|
+
|
|
39
|
+
return video_urls
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def extractor_html(html: str) -> List[str]:
|
|
43
|
+
strainer = SoupStrainer('div', class_='thumb') # parse only these nodes
|
|
44
|
+
soup = BeautifulSoup(html, 'lxml', parse_only=strainer)
|
|
45
|
+
out = []
|
|
46
|
+
for div in soup.find_all('div', class_='thumb'):
|
|
47
|
+
a_tag = div.find('a', href=True)
|
|
48
|
+
if a_tag and a_tag['href']:
|
|
49
|
+
out.append(a_tag['href'])
|
|
50
|
+
|
|
51
|
+
video_urls = [urljoin("https://www.xvideos.com", u) for u in out if "video." in u]
|
|
52
|
+
return video_urls
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Sort:
|
|
2
|
+
Sort_relevance = "relevance"
|
|
3
|
+
Sort_upload_date = "uploaddate"
|
|
4
|
+
Sort_rating = "rating"
|
|
5
|
+
Sort_length = "length"
|
|
6
|
+
Sort_views = "views"
|
|
7
|
+
Sort_random = "random"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SortDate:
|
|
11
|
+
Sort_all = "all"
|
|
12
|
+
Sort_last_3_days = "today"
|
|
13
|
+
Sort_week = "week"
|
|
14
|
+
Sort_month = "month"
|
|
15
|
+
Sort_last_3_months = "3month"
|
|
16
|
+
Sort_last_6_months = "6month"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SortVideoTime:
|
|
20
|
+
Sort_all = "allduration"
|
|
21
|
+
Sort_short = "1-3min"
|
|
22
|
+
Sort_middle = "3-10min"
|
|
23
|
+
Sort_long = "10min_more"
|
|
24
|
+
Sort_long_10_20min = "10-20min"
|
|
25
|
+
Sort_really_long = "20min_more"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SortQuality:
|
|
29
|
+
Sort_all = "all"
|
|
30
|
+
Sort_720p = "hd"
|
|
31
|
+
Sort_1080_plus = "1080P"
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from ..xvideos_api import Client
|
|
2
|
+
|
|
3
|
+
client = Client()
|
|
4
|
+
|
|
5
|
+
url_1 = "https://de.xvideos.com/video.ufavdcma5da/regional/202/0/gilf_showing_her_new_sexy_new_years_eve_party_outfit_with_some_dirtytalk._watch_the_horny_granny_nude_at_the_end_ai-generated"
|
|
6
|
+
url_2 = "https://de.xvideos.com/video.ufceveh7bfc/regional/202/0/called_a_whore_on_new_year_s_eve_-_stepsister_came_-_had_to_fuck_her_-_russian_amateur_with_conversations_and_subtitles"
|
|
7
|
+
url_3 = "https://de.xvideos.com/video.ufdidkbdca0/regional/202/0/hot_milf_gives_handjob_from_behind_-_step_mom_helping_step_son_handmade._new_year_party"
|
|
8
|
+
|
|
9
|
+
video_1 = client.get_video(url_1)
|
|
10
|
+
video_2 = client.get_video(url_2)
|
|
11
|
+
video_3 = client.get_video(url_3)
|
|
12
|
+
|
|
13
|
+
def test_download_high():
|
|
14
|
+
stuff_1 = video_1.download(quality="worst", return_report=True)
|
|
15
|
+
stuff_2 = video_2.download(quality="worst", return_report=True, remux=True)
|
|
16
|
+
assert stuff_1["status"] == "completed"
|
|
17
|
+
assert stuff_2["status"] == "completed"
|
|
18
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from ..xvideos_api import Client
|
|
2
|
+
|
|
3
|
+
client = Client()
|
|
4
|
+
pornstar = client.get_pornstar("https://de.xvideos.com/pornstars/sweetie-fox1")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_pornstar():
|
|
8
|
+
assert isinstance(pornstar.total_videos, int)
|
|
9
|
+
assert isinstance(pornstar.total_pages, int)
|
|
10
|
+
|
|
11
|
+
for idx, video in enumerate(pornstar.videos(videos_concurrency=1, pages_concurrency=1)):
|
|
12
|
+
assert isinstance(video.title, str) and len(video.title) >= 3
|
|
13
|
+
if idx == 3:
|
|
14
|
+
break
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from ..xvideos_api import Client, Sort, SortVideoTime, SortQuality, SortDate, VideoUnavailable
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
# Initialize client and query
|
|
5
|
+
client = Client()
|
|
6
|
+
query = "Mia Khalifa"
|
|
7
|
+
|
|
8
|
+
def validate_video_objects(videos):
|
|
9
|
+
"""Helper function to validate video objects."""
|
|
10
|
+
for idx, video in enumerate(videos):
|
|
11
|
+
try:
|
|
12
|
+
print(video.title)
|
|
13
|
+
assert isinstance(video.title, str) and len(video.title) > 0, f"Invalid video title at index {idx}."
|
|
14
|
+
if idx == 3: # Validate up to 4 videos for brevity
|
|
15
|
+
break
|
|
16
|
+
|
|
17
|
+
except VideoUnavailable:
|
|
18
|
+
break # Expected
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.parametrize("sort_option", [
|
|
22
|
+
Sort.Sort_rating,
|
|
23
|
+
Sort.Sort_relevance,
|
|
24
|
+
Sort.Sort_views,
|
|
25
|
+
Sort.Sort_length,
|
|
26
|
+
Sort.Sort_random,
|
|
27
|
+
Sort.Sort_upload_date,
|
|
28
|
+
])
|
|
29
|
+
def test_sort_search(sort_option):
|
|
30
|
+
"""Test sorting by different Sort options."""
|
|
31
|
+
videos = client.search(query, sorting_sort=sort_option)
|
|
32
|
+
validate_video_objects(videos)
|
|
33
|
+
|
|
34
|
+
@pytest.mark.parametrize("time_option", [
|
|
35
|
+
SortVideoTime.Sort_long,
|
|
36
|
+
SortVideoTime.Sort_all,
|
|
37
|
+
SortVideoTime.Sort_short,
|
|
38
|
+
SortVideoTime.Sort_middle,
|
|
39
|
+
SortVideoTime.Sort_really_long,
|
|
40
|
+
SortVideoTime.Sort_long_10_20min,
|
|
41
|
+
])
|
|
42
|
+
def test_sort_video_time_search(time_option):
|
|
43
|
+
"""Test sorting by different SortVideoTime options."""
|
|
44
|
+
videos = client.search(query, sorting_time=time_option)
|
|
45
|
+
validate_video_objects(videos)
|
|
46
|
+
|
|
47
|
+
@pytest.mark.parametrize("quality_option", [
|
|
48
|
+
SortQuality.Sort_720p,
|
|
49
|
+
SortQuality.Sort_all,
|
|
50
|
+
SortQuality.Sort_1080_plus,
|
|
51
|
+
])
|
|
52
|
+
def test_sort_quality_search(quality_option):
|
|
53
|
+
"""Test sorting by different SortQuality options."""
|
|
54
|
+
videos = client.search(query, sort_quality=quality_option)
|
|
55
|
+
validate_video_objects(videos)
|
|
56
|
+
|
|
57
|
+
@pytest.mark.parametrize("date_option", [
|
|
58
|
+
SortDate.Sort_all,
|
|
59
|
+
SortDate.Sort_week,
|
|
60
|
+
SortDate.Sort_month,
|
|
61
|
+
SortDate.Sort_last_3_days,
|
|
62
|
+
SortDate.Sort_last_3_months,
|
|
63
|
+
SortDate.Sort_last_6_months,
|
|
64
|
+
])
|
|
65
|
+
def test_sort_date_search(date_option):
|
|
66
|
+
"""Test sorting by different SortDate options."""
|
|
67
|
+
videos = client.search(query, sorting_date=date_option, videos_concurrency=1, pages_concurrency=1)
|
|
68
|
+
validate_video_objects(videos)
|
|
69
|
+
|
|
70
|
+
def test_base_search():
|
|
71
|
+
"""Test basic search functionality."""
|
|
72
|
+
videos = client.search(query, videos_concurrency=1, pages_concurrency=1)
|
|
73
|
+
validate_video_objects(videos)
|
|
74
|
+
|
|
75
|
+
# Refactored by ChatGPT lol
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from ..xvideos_api import Client, Channel
|
|
2
|
+
|
|
3
|
+
url = "https://de.xvideos.com/video.ohplvhk02fd/meine_lesbische_freundin_hat_mich_beim_fremdgehen_mit_einem_zufalligen_typen_erwischt_aber_ich_kann_nicht_aufhoren_und_ficke_ihn_weiter_vor_ihren_augen_"
|
|
4
|
+
# This URL will be used for all tests
|
|
5
|
+
|
|
6
|
+
client = Client()
|
|
7
|
+
video = client.get_video(url)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_title():
|
|
11
|
+
assert isinstance(video.title, str) and len(video.title) > 0
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_uploader():
|
|
15
|
+
assert isinstance(video.author, Channel)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_length():
|
|
19
|
+
assert isinstance(video.length, str) and len(video.length) > 0
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_views():
|
|
23
|
+
assert isinstance(video.views, str) and len(video.views) > 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_comment_count():
|
|
27
|
+
assert isinstance(video.comment_count, str) and len(video.comment_count) > 0
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_likes():
|
|
31
|
+
assert isinstance(video.likes, str) and len(video.likes) > 0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_dislikes():
|
|
35
|
+
assert isinstance(video.dislikes, str) and len(video.dislikes) > 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_rating_votes():
|
|
39
|
+
assert isinstance(video.rating_votes, str) and len(video.rating_votes) > 0
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_description():
|
|
43
|
+
assert isinstance(video.description, str) and len(video.description) > 0
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_tags():
|
|
47
|
+
assert isinstance(video.tags, list) and len(video.tags) > 0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_thumbnail_url():
|
|
51
|
+
assert isinstance(video.thumbnail_url, str) and len(video.thumbnail_url) > 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_preview_video_url():
|
|
55
|
+
assert isinstance(video.preview_video_url, str) and len(video.preview_video_url) > 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_publish_date():
|
|
59
|
+
assert isinstance(video.publish_date, str) and len(video.publish_date) > 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_content_url():
|
|
63
|
+
assert isinstance(video.content_url, str) and len(video.content_url) > 0
|
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (C) 2024-2025 Johannes Habel
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
"""
|
|
17
|
+
import os
|
|
18
|
+
import math
|
|
19
|
+
import html
|
|
20
|
+
import httpx
|
|
21
|
+
import logging
|
|
22
|
+
import argparse
|
|
23
|
+
import threading
|
|
24
|
+
|
|
25
|
+
from functools import cached_property
|
|
26
|
+
from typing import Union, Generator, Optional
|
|
27
|
+
from base_api.base import BaseCore, setup_logger, Helper
|
|
28
|
+
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
import lxml
|
|
32
|
+
parser = "lxml" # Faster speeds, but more dependencies
|
|
33
|
+
|
|
34
|
+
except (ModuleNotFoundError, ImportError):
|
|
35
|
+
parser = "html.parser" # Fallback to classic HTML parser (will work fine)
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
from modules.consts import *
|
|
39
|
+
from modules.errors import *
|
|
40
|
+
from modules.sorting import *
|
|
41
|
+
|
|
42
|
+
except (ModuleNotFoundError, ImportError):
|
|
43
|
+
from .modules.consts import *
|
|
44
|
+
from .modules.errors import *
|
|
45
|
+
from .modules.sorting import *
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Video:
|
|
49
|
+
def __init__(self, url, core: Optional[BaseCore] = None):
|
|
50
|
+
"""
|
|
51
|
+
:param url: (str) The URL of the video
|
|
52
|
+
"""
|
|
53
|
+
self.core = core
|
|
54
|
+
self.url = self.check_url(url)
|
|
55
|
+
self.logger = setup_logger(name="XVIDEOS API - [Video]", log_file=None, level=logging.ERROR)
|
|
56
|
+
self.html_content = self.get_html_content()
|
|
57
|
+
self.soup = BeautifulSoup(self.html_content, parser)
|
|
58
|
+
if isinstance(self.html_content, httpx.Response):
|
|
59
|
+
if self.html_content.status_code == 404:
|
|
60
|
+
raise VideoUnavailable("The video is not available or the URL is incorrect.")
|
|
61
|
+
|
|
62
|
+
self.json_data = self.meta
|
|
63
|
+
self.quality_url_map = None
|
|
64
|
+
self.available_qualities = None
|
|
65
|
+
|
|
66
|
+
def enable_logging(self, log_file: str = None, level = None, log_ip: str = None, log_port: int = None):
|
|
67
|
+
self.logger = setup_logger(name="XVIDEOS API - [Video]", log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
68
|
+
|
|
69
|
+
@cached_property
|
|
70
|
+
def html_text(self) -> str:
|
|
71
|
+
r = self.core.fetch(self.url)
|
|
72
|
+
if isinstance(r, httpx.Response):
|
|
73
|
+
if r.status_code == 404:
|
|
74
|
+
raise VideoUnavailable("The video is not available or the URL is incorrect.")
|
|
75
|
+
return r.text
|
|
76
|
+
return r # assume already a string
|
|
77
|
+
|
|
78
|
+
@cached_property
|
|
79
|
+
def soup(self) -> BeautifulSoup:
|
|
80
|
+
# lxml is much faster than the default parser
|
|
81
|
+
return BeautifulSoup(self.html_text, parser)
|
|
82
|
+
|
|
83
|
+
@cached_property
|
|
84
|
+
def script_content(self) -> str:
|
|
85
|
+
# Find the one script we care about without reparsing
|
|
86
|
+
def desired(tag):
|
|
87
|
+
if tag.name != "script" or not tag.string:
|
|
88
|
+
return False
|
|
89
|
+
t = tag.string
|
|
90
|
+
return ("html5player" in t) and ("setVideoTitle" in t) and ("setVideoUrlLow" in t)
|
|
91
|
+
|
|
92
|
+
s = self.soup.find(desired)
|
|
93
|
+
return s.string if s and s.string else ""
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def check_url(cls, url) -> str:
|
|
97
|
+
"""
|
|
98
|
+
:param url: (str) The URL of the video
|
|
99
|
+
:return: (str) The URL of the video, if valid, otherwise raises InvalidUrl Exception
|
|
100
|
+
"""
|
|
101
|
+
match = REGEX_VIDEO_CHECK_URL.match(url)
|
|
102
|
+
if match:
|
|
103
|
+
return url
|
|
104
|
+
|
|
105
|
+
else:
|
|
106
|
+
raise InvalidUrl(f"Invalid Video URL: {url}")
|
|
107
|
+
|
|
108
|
+
@cached_property
|
|
109
|
+
def json_data(self) -> dict:
|
|
110
|
+
data = {}
|
|
111
|
+
for s in self.soup.select('script[type="application/ld+json"]'):
|
|
112
|
+
if not s.string:
|
|
113
|
+
continue
|
|
114
|
+
try:
|
|
115
|
+
data.update(json.loads(s.string))
|
|
116
|
+
except Exception:
|
|
117
|
+
continue
|
|
118
|
+
return data
|
|
119
|
+
|
|
120
|
+
def get_html_content(self) -> Union[str, httpx.Response]:
|
|
121
|
+
return self.core.fetch(self.url)
|
|
122
|
+
|
|
123
|
+
@cached_property
|
|
124
|
+
def meta(self) -> dict:
|
|
125
|
+
j = self.json_data
|
|
126
|
+
# Defensive access because JSON-LD varies
|
|
127
|
+
return {
|
|
128
|
+
"name": j.get("name"),
|
|
129
|
+
"description": j.get("description"),
|
|
130
|
+
"thumbnailUrl": (j.get("thumbnailUrl") or [None])[0] if isinstance(j.get("thumbnailUrl"), list) else j.get(
|
|
131
|
+
"thumbnailUrl"),
|
|
132
|
+
"uploadDate": j.get("uploadDate"),
|
|
133
|
+
"contentUrl": j.get("contentUrl"),
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
def get_segments(self, quality) -> list:
|
|
137
|
+
"""
|
|
138
|
+
:param quality: (str, Quality) The video quality
|
|
139
|
+
:return: (list) A list of segments (the .ts files)
|
|
140
|
+
"""
|
|
141
|
+
segments = self.core.get_segments(quality=quality, m3u8_url_master=self.m3u8_base_url)
|
|
142
|
+
return segments
|
|
143
|
+
|
|
144
|
+
def download(self, quality, path="./", callback=None, no_title=False, remux: bool = False,
|
|
145
|
+
callback_remux=None, start_segment: int = 0, stop_event: Optional[threading.Event] = None,
|
|
146
|
+
segment_state_path: Optional[str] = None, segment_dir: Optional[str] = None,
|
|
147
|
+
return_report: bool = False, cleanup_on_stop: bool = True, keep_segment_dir: bool = False
|
|
148
|
+
) -> bool:
|
|
149
|
+
"""
|
|
150
|
+
:param callback:
|
|
151
|
+
:param quality:
|
|
152
|
+
:param path:
|
|
153
|
+
:param no_title:
|
|
154
|
+
:param remux:
|
|
155
|
+
:param callback_remux:
|
|
156
|
+
:param start_segment:
|
|
157
|
+
:param stop_event:
|
|
158
|
+
:param segment_state_path:
|
|
159
|
+
:param segment_dir:
|
|
160
|
+
:param return_report:
|
|
161
|
+
:param cleanup_on_stop:
|
|
162
|
+
:param keep_segment_dir:
|
|
163
|
+
:return:
|
|
164
|
+
"""
|
|
165
|
+
if not no_title:
|
|
166
|
+
path = os.path.join(path, f"{self.title}.mp4")
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
return self.core.download(video=self, quality=quality, path=path, callback=callback, remux=remux,
|
|
170
|
+
callback_remux=callback_remux, start_segment=start_segment, stop_event=stop_event,
|
|
171
|
+
segment_state_path=segment_state_path, segment_dir=segment_dir,
|
|
172
|
+
return_report=return_report,
|
|
173
|
+
cleanup_on_stop=cleanup_on_stop, keep_segment_dir=keep_segment_dir)
|
|
174
|
+
|
|
175
|
+
except Exception: # I should improve this in the future
|
|
176
|
+
self.logger.warning("Video doesn't have an HLS stream. Using legacy downloading instead...")
|
|
177
|
+
self.core.legacy_download(path=path, callback=callback, url=self.cdn_url)
|
|
178
|
+
return True
|
|
179
|
+
|
|
180
|
+
@cached_property
|
|
181
|
+
def m3u8_base_url(self) -> str:
|
|
182
|
+
return REGEX_VIDEO_M3U8.search(self.script_content).group(1)
|
|
183
|
+
|
|
184
|
+
@cached_property
|
|
185
|
+
def title(self) -> str:
|
|
186
|
+
return html.unescape(self.meta["name"]) if self.meta["name"] else ""
|
|
187
|
+
|
|
188
|
+
@cached_property
|
|
189
|
+
def description(self) -> str:
|
|
190
|
+
return html.unescape(self.json_data["description"])
|
|
191
|
+
|
|
192
|
+
@cached_property
|
|
193
|
+
def thumbnail_url(self) -> str:
|
|
194
|
+
return self.json_data["thumbnailUrl"]
|
|
195
|
+
|
|
196
|
+
@cached_property
|
|
197
|
+
def preview_video_url(self) -> str:
|
|
198
|
+
thumb = html.unescape(self.json_data["thumbnailUrl"])[0]
|
|
199
|
+
base_url = re.sub(r'/thumbs(169)?(xnxx)?(l*|poster)/', '/videopreview/', thumb[:thumb.rfind("/")])
|
|
200
|
+
suffix = re.search(r'-(\d+)', base_url)
|
|
201
|
+
base_url = re.sub(r'-(\d+)', '', base_url) if suffix else base_url
|
|
202
|
+
return f"{base_url}_169{suffix.group(0) if suffix else ''}.mp4"
|
|
203
|
+
|
|
204
|
+
@cached_property
|
|
205
|
+
def publish_date(self) -> str:
|
|
206
|
+
return html.unescape(self.json_data["uploadDate"])
|
|
207
|
+
|
|
208
|
+
@cached_property
|
|
209
|
+
def content_url(self) -> str:
|
|
210
|
+
return html.unescape(self.json_data["contentUrl"])
|
|
211
|
+
|
|
212
|
+
@cached_property
|
|
213
|
+
def tags(self) -> list:
|
|
214
|
+
a_tags = self.soup.find_all('a', class_="is-keyword btn btn-default")
|
|
215
|
+
tags = []
|
|
216
|
+
for tag in a_tags:
|
|
217
|
+
tags.append(tag.text)
|
|
218
|
+
|
|
219
|
+
return tags
|
|
220
|
+
|
|
221
|
+
@cached_property
|
|
222
|
+
def views(self) -> str:
|
|
223
|
+
return self.soup.find('span', class_='icon-f icf-eye').next.text
|
|
224
|
+
|
|
225
|
+
@cached_property
|
|
226
|
+
def likes(self) -> str:
|
|
227
|
+
return self.soup.find('span', class_='rating-good-nbr').text
|
|
228
|
+
|
|
229
|
+
@cached_property
|
|
230
|
+
def dislikes(self) -> str:
|
|
231
|
+
return self.soup.find('span', class_='rating-bad-nbr').text
|
|
232
|
+
|
|
233
|
+
@cached_property
|
|
234
|
+
def rating_votes(self) -> str:
|
|
235
|
+
return self.soup.find('span', class_='rating-total-txt').text
|
|
236
|
+
|
|
237
|
+
@cached_property
|
|
238
|
+
def comment_count(self) -> str:
|
|
239
|
+
return self.soup.find('button', class_="comments tab-button").next.next.text
|
|
240
|
+
|
|
241
|
+
@cached_property
|
|
242
|
+
def author(self):
|
|
243
|
+
"""Returns the Channel object where the video was published on"""
|
|
244
|
+
link = self.soup.find("li", class_="main-uploader").find('a')["href"]
|
|
245
|
+
if not link.startswith("/profiles"):
|
|
246
|
+
return Channel(url=f"https://xvideos.com/channels{link}", core=self.core)
|
|
247
|
+
|
|
248
|
+
else:
|
|
249
|
+
return Channel(url=f"https://xvideos.com{link}", core=self.core)
|
|
250
|
+
|
|
251
|
+
@cached_property
|
|
252
|
+
def length(self) -> str:
|
|
253
|
+
return self.soup.find('span', class_="duration").text
|
|
254
|
+
|
|
255
|
+
@cached_property
|
|
256
|
+
def pornstars(self):
|
|
257
|
+
"""
|
|
258
|
+
Returns the Pornstar objects for the Pornstars that are featured in the video
|
|
259
|
+
"""
|
|
260
|
+
pornstars = self.soup.find_all('li', class_="model")
|
|
261
|
+
urls = []
|
|
262
|
+
for pornstar in pornstars:
|
|
263
|
+
urls.append(f"https://xvideos.com{pornstar.next['href']}")
|
|
264
|
+
|
|
265
|
+
for url in urls:
|
|
266
|
+
yield Pornstar(url=url, core=self.core)
|
|
267
|
+
|
|
268
|
+
@cached_property
|
|
269
|
+
def embed_url(self) -> str:
|
|
270
|
+
return REGEX_IFRAME.search(html.unescape(self.html_content)).group(1)
|
|
271
|
+
|
|
272
|
+
@cached_property
|
|
273
|
+
def cdn_url(self) -> str:
|
|
274
|
+
return self.json_data["contentUrl"]
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class Channel(Helper):
|
|
278
|
+
"""
|
|
279
|
+
Returns the Channel object for a Channel. Please note, that the Channel object and the Pornstar object
|
|
280
|
+
are almost identical, but I still differentiated them as two different classes, because TECHNICALLY they are
|
|
281
|
+
different things.
|
|
282
|
+
|
|
283
|
+
"""
|
|
284
|
+
def __init__(self, url: str, core: Optional[BaseCore], auto_init=True):
|
|
285
|
+
super().__init__(core=core, video=Video)
|
|
286
|
+
self.core = core
|
|
287
|
+
self.logger = setup_logger(name="XVIDEOS API - [Channel]", log_file=None, level=logging.ERROR)
|
|
288
|
+
if "/channels/" not in url and "profiles" not in url:
|
|
289
|
+
self.logger.warning("/channels/ not in URL. Trying to fix manually. This CAN lead to more errors!")
|
|
290
|
+
self.url = url.replace("xvideos.com/", "xvideos.com/channels/")
|
|
291
|
+
else:
|
|
292
|
+
self.url = url
|
|
293
|
+
|
|
294
|
+
base_content = self.core.fetch(f"{self.url}/videos/best/0")
|
|
295
|
+
about_me_html = self.core.fetch(f"{self.url}#_tabAboutMe")
|
|
296
|
+
self.bs4_about_me = BeautifulSoup(about_me_html, parser)
|
|
297
|
+
self.data = json.loads(base_content)
|
|
298
|
+
|
|
299
|
+
def enable_logging(self, name="XVIDEOS API - [Channel]", log_file=None, level=logging.DEBUG, log_ip: str = None, log_port: int = None):
|
|
300
|
+
self.logger = setup_logger(name=name, log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
301
|
+
|
|
302
|
+
@cached_property
|
|
303
|
+
def name(self) -> str:
|
|
304
|
+
return self.bs4_about_me.find('h2').find_all('strong', attrs={'class': 'text-danger'})[0].text
|
|
305
|
+
|
|
306
|
+
@cached_property
|
|
307
|
+
def thumbnail_url(self) -> str:
|
|
308
|
+
return self.bs4_about_me.find('div', attrs={'class': 'profile-pic'}).find_all('img')[0]['src']
|
|
309
|
+
|
|
310
|
+
@cached_property
|
|
311
|
+
def total_videos(self):
|
|
312
|
+
return int(self.data["nb_videos"])
|
|
313
|
+
|
|
314
|
+
@cached_property
|
|
315
|
+
def per_page(self):
|
|
316
|
+
return int(self.data["nb_per_page"])
|
|
317
|
+
|
|
318
|
+
@cached_property
|
|
319
|
+
def total_pages(self):
|
|
320
|
+
return math.ceil(self.total_videos / self.per_page)
|
|
321
|
+
|
|
322
|
+
def videos(self, pages: int = 0, videos_concurrency: int = None, pages_concurrency: int = None) -> Generator[Video, None, None]:
|
|
323
|
+
if pages > self.total_pages:
|
|
324
|
+
self.logger.warning(f"You want to fetch: {self.total_pages} pages but only: {self.total_pages} are available. Reducing!")
|
|
325
|
+
pages = self.total_pages
|
|
326
|
+
|
|
327
|
+
page_urls = [f"{self.url}/videos/best/{i}" for i in range(pages)] # Don't exceed total available pages
|
|
328
|
+
self.logger.debug(f"Processing: {len(page_urls)} pages...")
|
|
329
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
330
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
331
|
+
yield from self.iterator(page_urls=page_urls, videos_concurrency=videos_concurrency, pages_concurrency=pages_concurrency,
|
|
332
|
+
extractor=extractor_json)
|
|
333
|
+
|
|
334
|
+
@cached_property
|
|
335
|
+
def country(self) -> str:
|
|
336
|
+
return self.bs4_about_me.find(id="pinfo-country").span.text.strip()
|
|
337
|
+
|
|
338
|
+
@cached_property
|
|
339
|
+
def profile_hits(self) -> str:
|
|
340
|
+
return self.bs4_about_me.find(id="pinfo-profile-hits").span.text.strip()
|
|
341
|
+
|
|
342
|
+
@cached_property
|
|
343
|
+
def subscribers(self) -> str:
|
|
344
|
+
return self.bs4_about_me.find(id="pinfo-subscribers").span.text.strip()
|
|
345
|
+
|
|
346
|
+
@cached_property
|
|
347
|
+
def total_video_views(self) -> str:
|
|
348
|
+
return self.bs4_about_me.find(id="pinfo-video-views").span.text.strip()
|
|
349
|
+
|
|
350
|
+
@cached_property
|
|
351
|
+
def region(self) -> str:
|
|
352
|
+
return self.bs4_about_me.find(id="pinfo-region").span.text.strip()
|
|
353
|
+
|
|
354
|
+
@cached_property
|
|
355
|
+
def signed_up(self) -> str:
|
|
356
|
+
return self.bs4_about_me.find(id="pinfo-signedup").span.text.strip()
|
|
357
|
+
|
|
358
|
+
@cached_property
|
|
359
|
+
def last_activity(self) -> str:
|
|
360
|
+
return self.bs4_about_me.find(id="pinfo-lastactivity").span.text.strip()
|
|
361
|
+
|
|
362
|
+
@cached_property
|
|
363
|
+
def worked_for_with(self):
|
|
364
|
+
names = self.bs4_about_me.find(id="pinfo-workedfor").find_all('a')
|
|
365
|
+
links = [a['href'] for a in names]
|
|
366
|
+
for link in links:
|
|
367
|
+
if not "profile" in link:
|
|
368
|
+
return Channel(url=f"https://xvideos.com/channels{link}", core=self.core)
|
|
369
|
+
|
|
370
|
+
else:
|
|
371
|
+
return Channel(url=f"https://xvideos.com{link}", core=self.core)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
class Pornstar(Helper):
|
|
375
|
+
def __init__(self, url: str, core: Optional[BaseCore]):
|
|
376
|
+
super().__init__(core=core, video=Video)
|
|
377
|
+
self.core = core
|
|
378
|
+
self.url = self.check_url(url)
|
|
379
|
+
base_content = self.core.fetch(f"{self.url}/videos/best/0")
|
|
380
|
+
about_me_html = self.core.fetch(f"{self.url}#_tabAboutMe")
|
|
381
|
+
self.bs4_about_me = BeautifulSoup(about_me_html, "lxml")
|
|
382
|
+
self.data = json.loads(base_content)
|
|
383
|
+
self.logger = setup_logger(name="XVIDEOS API - [Pornstar]", log_file=None, level=logging.ERROR)
|
|
384
|
+
|
|
385
|
+
def enable_logging(self, log_file: str = None, level=None, log_ip: str = None, log_port: int = None):
|
|
386
|
+
self.logger = setup_logger(name="XVIDEOS API - [Pornstar]", log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
387
|
+
|
|
388
|
+
def check_url(self, url):
|
|
389
|
+
if ("/pornstars/" not in url) and ("/model/" not in url):
|
|
390
|
+
self.logger.error("URL doesn't contain '/pornstars/', seems like a channel URL or is generally invalid!")
|
|
391
|
+
raise InvalidPornstar(
|
|
392
|
+
"It seems like the Pornstar URL is invalid, please note, that channels are NOT supported!")
|
|
393
|
+
|
|
394
|
+
return url
|
|
395
|
+
|
|
396
|
+
@cached_property
|
|
397
|
+
def name(self) -> str:
|
|
398
|
+
return self.bs4_about_me.find('h2').find_all('strong', attrs={'class': 'text-danger'})[0].text
|
|
399
|
+
|
|
400
|
+
@cached_property
|
|
401
|
+
def thumbnail_url(self) -> str:
|
|
402
|
+
return self.bs4_about_me.find('div', attrs={'class': 'profile-pic'}).find_all('img')[0]['src']
|
|
403
|
+
|
|
404
|
+
@cached_property
|
|
405
|
+
def total_videos(self):
|
|
406
|
+
return int(self.data["nb_videos"])
|
|
407
|
+
|
|
408
|
+
@cached_property
|
|
409
|
+
def per_page(self):
|
|
410
|
+
return int(self.data["nb_per_page"])
|
|
411
|
+
|
|
412
|
+
@cached_property
|
|
413
|
+
def total_pages(self):
|
|
414
|
+
return math.ceil(self.total_videos / self.per_page)
|
|
415
|
+
|
|
416
|
+
def videos(self, pages: int = 0, videos_concurrency: int = None, pages_concurrency: int = None) -> Generator[Video, None, None]:
|
|
417
|
+
if pages > self.total_pages:
|
|
418
|
+
self.logger.warning(
|
|
419
|
+
f"You want to fetch: {self.total_pages} pages but only: {self.total_pages} are available. Reducing!")
|
|
420
|
+
pages = self.total_pages
|
|
421
|
+
|
|
422
|
+
page_urls = [f"{self.url}/videos/best/{i}" for i in range(pages)] # Don't exceed total available pages
|
|
423
|
+
self.logger.debug(f"Processing: {len(page_urls)} pages...")
|
|
424
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
425
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
426
|
+
yield from self.iterator(page_urls=page_urls, videos_concurrency=videos_concurrency, pages_concurrency=pages_concurrency,
|
|
427
|
+
extractor=extractor_json)
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
@cached_property
|
|
431
|
+
def gender(self) -> str:
|
|
432
|
+
return self.bs4_about_me.find(id="pinfo-sex").span.text.strip()
|
|
433
|
+
|
|
434
|
+
@cached_property
|
|
435
|
+
def age(self) -> str:
|
|
436
|
+
"""Returns the age of the Pornstar"""
|
|
437
|
+
age = self.bs4_about_me.find(id="pinfo-age").span.text.strip()
|
|
438
|
+
if int(age) < 18: # lmaooooo
|
|
439
|
+
raise "Wait what????"
|
|
440
|
+
|
|
441
|
+
return age
|
|
442
|
+
|
|
443
|
+
@cached_property
|
|
444
|
+
def country(self) -> str:
|
|
445
|
+
"""Returns the country of the Pornstar"""
|
|
446
|
+
return self.bs4_about_me.find(id="pinfo-country").span.text.strip()
|
|
447
|
+
|
|
448
|
+
@cached_property
|
|
449
|
+
def profile_hits(self) -> str:
|
|
450
|
+
"""Returns the current profile hits count (don't know what that is lol)"""
|
|
451
|
+
return self.bs4_about_me.find(id="pinfo-profile-hits").span.text.strip()
|
|
452
|
+
|
|
453
|
+
@cached_property
|
|
454
|
+
def subscriber_count(self) -> str:
|
|
455
|
+
"""Returns the current subscriber count of the pornstar"""
|
|
456
|
+
return self.bs4_about_me.find(id="pinfo-subscribers").span.text.strip()
|
|
457
|
+
|
|
458
|
+
@cached_property
|
|
459
|
+
def total_videos_views(self) -> str:
|
|
460
|
+
"""Returns the total video views of the pornstar of all videos combined"""
|
|
461
|
+
return self.bs4_about_me.find(id="pinfo-videos-views").span.text.strip()
|
|
462
|
+
|
|
463
|
+
@cached_property
|
|
464
|
+
def sign_up_date(self) -> str:
|
|
465
|
+
"""Returns the date where the pornstar signed up his / her account"""
|
|
466
|
+
return self.bs4_about_me.find(id="pinfo-signedup").span.text.strip()
|
|
467
|
+
|
|
468
|
+
@cached_property
|
|
469
|
+
def last_activity(self) -> str:
|
|
470
|
+
"""Returns the date of the last activity of the Pornstar"""
|
|
471
|
+
return self.bs4_about_me.find(id="pinfo-lastactivity").span.text.strip()
|
|
472
|
+
|
|
473
|
+
@cached_property
|
|
474
|
+
def video_tags(self) -> str:
|
|
475
|
+
"""Returns the video tags the pornstar is often featured in"""
|
|
476
|
+
return self.bs4_about_me.find(id="pinfo-video-tags").span.text.strip()
|
|
477
|
+
|
|
478
|
+
@cached_property
|
|
479
|
+
def worked_for_with(self) -> Generator[Channel, None, None]:
|
|
480
|
+
"""
|
|
481
|
+
Returns the channels the pornstar has worked with as a Channel object (Generator)
|
|
482
|
+
"""
|
|
483
|
+
names = self.bs4_about_me.find(id="pinfo-workedfor").find_all('a')
|
|
484
|
+
links = [a['href'] for a in names]
|
|
485
|
+
for link in links:
|
|
486
|
+
yield Channel(core=self.core, url=f"https://www.xvideos.com{link}")
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
class Client(Helper):
|
|
490
|
+
def __init__(self, core: Optional[BaseCore] = None):
|
|
491
|
+
super().__init__(core, video=Video)
|
|
492
|
+
self.core = core or BaseCore()
|
|
493
|
+
self.core.initialize_session()
|
|
494
|
+
self.logger = setup_logger(name="XVIDEOS API - [Client]", log_file=None, level=logging.ERROR)
|
|
495
|
+
|
|
496
|
+
def enable_logging(self, log_file: str = None, level=None, log_ip: str = None, log_port: int = None):
|
|
497
|
+
self.logger = setup_logger(name="XVIDEOS API - [Client]", log_file=log_file, level=level, http_ip=log_ip, http_port=log_port)
|
|
498
|
+
|
|
499
|
+
def get_video(self, url: str) -> Video:
|
|
500
|
+
"""
|
|
501
|
+
:param url: (str) The video URL
|
|
502
|
+
:return: (Video) The video object
|
|
503
|
+
"""
|
|
504
|
+
return Video(url, core=self.core)
|
|
505
|
+
|
|
506
|
+
def search(self, query: str, sorting_sort: Union[str, Sort.Sort_relevance] = Sort.Sort_relevance,
|
|
507
|
+
sorting_date: Union[str, SortDate] = SortDate.Sort_all,
|
|
508
|
+
sorting_time: Union[str, SortVideoTime] = SortVideoTime.Sort_all,
|
|
509
|
+
sort_quality: Union[str, SortQuality] = SortQuality.Sort_all,
|
|
510
|
+
pages: int = 2, videos_concurrency: int = None,
|
|
511
|
+
pages_concurrency: int = None) -> Generator[Video, None, None]:
|
|
512
|
+
|
|
513
|
+
query = query.replace(" ", "+")
|
|
514
|
+
p = urlparse(f"https://www.xvideos.com/")
|
|
515
|
+
qs = parse_qs(p.query)
|
|
516
|
+
queries = {
|
|
517
|
+
"k": query,
|
|
518
|
+
"sort": sorting_sort,
|
|
519
|
+
"datef": sorting_date,
|
|
520
|
+
"durf": sorting_time,
|
|
521
|
+
"quality": sort_quality
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
for key, value in queries.items():
|
|
525
|
+
if value:
|
|
526
|
+
qs[key] = [str(value)]
|
|
527
|
+
|
|
528
|
+
new_query = urlencode(qs, doseq=True)
|
|
529
|
+
url = urlunparse(p._replace(query=new_query))
|
|
530
|
+
page_urls = [f"{url}&p={p}" for p in range(pages)]
|
|
531
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
532
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
533
|
+
|
|
534
|
+
yield from self.iterator(page_urls=page_urls, extractor=extractor_html, videos_concurrency=videos_concurrency,
|
|
535
|
+
pages_concurrency=pages_concurrency)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
def get_playlist(self, url: str, pages: int = 2, videos_concurrency: int = None,
|
|
539
|
+
pages_concurrency: int = None) -> Generator[Video, None, None]:
|
|
540
|
+
page_urls = [f"{url}/{page}" for page in range(pages)]
|
|
541
|
+
|
|
542
|
+
for page in range(pages):
|
|
543
|
+
page_urls.append(f"{url}/{page}")
|
|
544
|
+
|
|
545
|
+
videos_concurrency = videos_concurrency or self.core.config.videos_concurrency
|
|
546
|
+
pages_concurrency = pages_concurrency or self.core.config.pages_concurrency
|
|
547
|
+
yield from self.iterator(page_urls=page_urls, extractor=extractor_html, videos_concurrency=videos_concurrency,
|
|
548
|
+
pages_concurrency=pages_concurrency)
|
|
549
|
+
|
|
550
|
+
def get_pornstar(self, url) -> Pornstar:
|
|
551
|
+
return Pornstar(url, core=self.core)
|
|
552
|
+
|
|
553
|
+
def get_channel(self, url) -> Channel:
|
|
554
|
+
return Channel(url, core=self.core)
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
def main():
|
|
558
|
+
parser = argparse.ArgumentParser(description="API Command Line Interface")
|
|
559
|
+
parser.add_argument("--download", metavar="URL (str)", type=str, help="URL to download from")
|
|
560
|
+
parser.add_argument("--quality", metavar="best,half,worst", type=str, help="The video quality (best,half,worst)",
|
|
561
|
+
required=True)
|
|
562
|
+
parser.add_argument("--file", metavar="Source to .txt file", type=str,
|
|
563
|
+
help="(Optional) Specify a file with URLs (separated with new lines)")
|
|
564
|
+
parser.add_argument("--output", metavar="Output directory", type=str, help="The output path (with filename)",
|
|
565
|
+
required=True)
|
|
566
|
+
parser.add_argument("--no-title", metavar="True,False", type=str,
|
|
567
|
+
help="Whether to apply video title automatically to output path or not", required=True)
|
|
568
|
+
|
|
569
|
+
args = parser.parse_args()
|
|
570
|
+
no_title = BaseCore().str_to_bool(args.no_title)
|
|
571
|
+
if args.download:
|
|
572
|
+
client = Client()
|
|
573
|
+
video = client.get_video(args.download)
|
|
574
|
+
video.download(quality=args.quality, path=args.output, no_title=no_title)
|
|
575
|
+
|
|
576
|
+
if args.file:
|
|
577
|
+
videos = []
|
|
578
|
+
client = Client()
|
|
579
|
+
|
|
580
|
+
with open(args.file, "r") as file:
|
|
581
|
+
content = file.read().splitlines()
|
|
582
|
+
|
|
583
|
+
for url in content:
|
|
584
|
+
videos.append(client.get_video(url))
|
|
585
|
+
|
|
586
|
+
for video in videos:
|
|
587
|
+
video.download(quality=args.quality, path=args.output, no_title=no_title)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
if __name__ == "__main__":
|
|
591
|
+
main()
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xvideos_api
|
|
3
|
+
Version: 1.8.2
|
|
4
|
+
Summary: A Python API for the Porn Site xvideos.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/xvideos_api
|
|
19
|
+
Provides-Extra: av
|
|
20
|
+
Provides-Extra: full
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
<h1 align="center">XVIDEOS API</h1>
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
<a href="https://pepy.tech/project/xvideos_api"><img src="https://static.pepy.tech/badge/xvideos_api" alt="Downloads"></a>
|
|
27
|
+
<a href="https://github.com/EchterAlsFake/xvideos_api/workflows/"><img src="https://github.com/EchterAlsFake/xvideos_api/workflows/CodeQL/badge.svg" alt="CodeQL Analysis"/></a>
|
|
28
|
+
<a href="https://echteralsfake.me/ci/xvideos_api/badge.svg"><img src="https://echteralsfake.me/ci/xvideos_api/badge.svg" alt="Sync 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 Channels
|
|
43
|
+
- Fetch Pornstars
|
|
44
|
+
- Search for videos
|
|
45
|
+
- Fetch playlists
|
|
46
|
+
- Built-in caching
|
|
47
|
+
- Easy interface
|
|
48
|
+
- Great type hinting
|
|
49
|
+
- Proxy support
|
|
50
|
+
- Very customizable
|
|
51
|
+
|
|
52
|
+
# Supported Platforms
|
|
53
|
+
This API has been tested and confirmed working on:
|
|
54
|
+
|
|
55
|
+
- Windows 11 (x64)
|
|
56
|
+
- macOS Sequoia (x86_64)
|
|
57
|
+
- Linux (Arch) (x86_64)
|
|
58
|
+
- Android 16 (aarch64)
|
|
59
|
+
|
|
60
|
+
# Quickstart
|
|
61
|
+
|
|
62
|
+
### Have a look at the [Documentation](https://github.com/EchterAlsFake/API_Docs/blob/master/Porn_APIs/XVideos.md) for more details
|
|
63
|
+
- Install the library with `pip install xvideos_api`
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from xvideos_api import Client
|
|
68
|
+
# Initialize a Client object
|
|
69
|
+
client = Client()
|
|
70
|
+
|
|
71
|
+
# Fetch a video
|
|
72
|
+
video_object = client.get_video("<insert_url_here>")
|
|
73
|
+
|
|
74
|
+
# Information from Video objects
|
|
75
|
+
print(video_object.title)
|
|
76
|
+
print(video_object.likes)
|
|
77
|
+
# Download the video
|
|
78
|
+
|
|
79
|
+
video_object.download(downloader="threaded", quality="best", path="your_output_path + filename")
|
|
80
|
+
|
|
81
|
+
# SEE DOCUMENTATION FOR MORE
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> [!NOTE]
|
|
85
|
+
> XVideos API can also be used from the command line. Do: xvideos_api -h to see the options
|
|
86
|
+
# Changelog
|
|
87
|
+
See [Changelog](https://github.com/EchterAlsFake/xvideos_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–2026 Johannes Habel
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
xvideos_api/__init__.py,sha256=JT-K7hK0Cfu1E2oncBp_OJkKaSnJDFrwQqQ-v0-KIZk,201
|
|
2
|
+
xvideos_api/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
xvideos_api/modules/consts.py,sha256=ZoUhbO54wpAo59mQd2pAFSfbx85GwnfOFcJpSYPa5Bw,1672
|
|
4
|
+
xvideos_api/modules/errors.py,sha256=7QhzC_w9QUSXd0pL4ppaynUmrqwSHPaHNSMC865dcS8,258
|
|
5
|
+
xvideos_api/modules/sorting.py,sha256=8EPRhLZT9XpLVPVkIaGd1cTh8x_OrwU46ESB9vgs-KM,672
|
|
6
|
+
xvideos_api/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
xvideos_api/tests/test_download.py,sha256=9myPH78NQjWzg_cyltg1R4l3PswdXT-Uax7Y5rlb66c,952
|
|
8
|
+
xvideos_api/tests/test_pornstar.py,sha256=kXYRDb5cXWRX_ewsGQXBQg8-MZC4yVUo2jTQQVJro1k,457
|
|
9
|
+
xvideos_api/tests/test_search.py,sha256=J-WTusjfu67nL2MqDB-lHy0O7TqOweIUwbGP4Mxo_IU,2411
|
|
10
|
+
xvideos_api/tests/test_video.py,sha256=_K1RlVPNmugZdXwVZoyMRwCLtseHNDH4EI-mitcld2E,1677
|
|
11
|
+
xvideos_api/xvideos_api.py,sha256=olznzwxFKxATAzANO1KuGr8tXNDYlLzN4T8TUycZWTU,23481
|
|
12
|
+
xvideos_api-1.8.2.dist-info/licenses/LICENSE,sha256=ohYRaFO0ISwaiv3fifo3YtRbSdlh1DtueZcn7DlUjFg,7369
|
|
13
|
+
xvideos_api-1.8.2.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
|
|
14
|
+
xvideos_api-1.8.2.dist-info/entry_points.txt,sha256=gyuLDgQrUnGPPQh3XT5wJzXk0tzfQuLW9upYDzMcYVw,62
|
|
15
|
+
xvideos_api-1.8.2.dist-info/METADATA,sha256=hSu8Jyxg0S7zf6JwDP7IPzEOQ5RH_NOW64_azxtL1rY,3565
|
|
16
|
+
xvideos_api-1.8.2.dist-info/RECORD,,
|
|
@@ -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.
|