Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Jan 31, 2024
1 parent 7758499 commit 59759c8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ a website. Contact me at my E-Mail, and I'll take this Repository immediately of


```python
from xnxx_api.xnxx_api import Client, Quality
from xnxx_api.xnxx_api import Client, Quality, threaded
# Initialize a Client object
client = Client()

Expand All @@ -38,7 +38,7 @@ print(video_object.title)
print(video_object.likes)
# Download the video

video_object.download(quality=Quality.BEST, output_path="your_output_path + filename")
video_object.download(downloader=threaded, quality=Quality.BEST, output_path="your_output_path + filename")

# SEE DOCUMENTATION FOR MORE
```
Expand All @@ -50,7 +50,7 @@ See [Changelog](https://github.com/EchterAlsFake/xnxx_api/blob/master/README/Cha
Do you see any issues or having some feature requests? Simply open an Issue or talk
in the discussions.

Pull requests are also welcome, but please avoid bs4 and use regex :)
Pull requests are also welcome.

# License
Licensed under the LGPLv3 License
Expand Down
4 changes: 4 additions & 0 deletions README/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

- Initial release

# 1.1

- You can now pass `quality` and `threading` argument as a string, instead of object.
- : See Documentation - `Locals`
7 changes: 3 additions & 4 deletions README/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XNXX API Documentation

> - Version 1.0
> - Version 1.1
> - Author: Johannes Habel
> - Copryight (C) 2024
> - License: GPL 3
Expand Down Expand Up @@ -134,6 +134,5 @@ There are three quality types:
- Quality.HALF
- Quality.WORST

I think they explain themselves really good :)


> - You can also pass a string instead of a Quality object. e.g instead of `Quality.BEST`, you can say `best`
> - Same goes for threading modes. Instead of `download.threaded` you can just say `threaded` as a string
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="xnxx_api",
version="1.0",
version="1.1",
packages=find_packages(),
install_requires=[
"requests", "bs4", "lxml", "ffmpeg-progress-yield"
Expand Down
34 changes: 28 additions & 6 deletions xnxx_api/xnxx_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def get_available_qualities(self):
self.available_qualities = list(quality_url_map.keys())
return self.available_qualities

def get_m3u8_by_quality(self, quality: Quality):
def get_m3u8_by_quality(self, quality):
quality = self.fix_quality(quality)

self.get_available_qualities()
base_qualities = ["250p", "360p", "480p", "720p", "1080p"]
if quality == Quality.BEST:
Expand All @@ -118,7 +120,10 @@ def get_m3u8_by_quality(self, quality: Quality):

return self.quality_url_map.get(selected_quality)

def get_segments(self, quality: Quality):
def get_segments(self, quality):

quality = self.fix_quality(quality)

# Some inspiration from PHUB (xD)
base_url = self.m3u8_base_url
new_segment = self.get_m3u8_by_quality(quality)
Expand Down Expand Up @@ -216,6 +221,23 @@ def callback(self, pos, total):
:return:
"""

@classmethod
def fix_quality(cls, quality):
# Needed for Porn Fetch

if isinstance(quality, Quality):
return quality

else:
if str(quality) == "best":
return Quality.BEST

elif str(quality) == "half":
return Quality.HALF

elif str(quality) == "worst":
return Quality.WORST

def download(self, downloader, quality, output_path, callback=None):
"""
:param callback:
Expand All @@ -224,17 +246,18 @@ def download(self, downloader, quality, output_path, callback=None):
:param output_path:
:return:
"""
quality = self.fix_quality(quality)

if callback is None:
callback = Callback.text_progress_bar

if downloader == default:
if downloader == default or str(downloader) == "default":
default(video=self, quality=quality, path=output_path, callback=callback)

elif downloader == threaded:
elif downloader == threaded or str(downloader) == "threaded":
threaded(video=self, quality=quality, path=output_path, callback=callback)

elif downloader == FFMPEG:
elif downloader == FFMPEG or str(downloader) == "FFMPEG":
FFMPEG(video=self, quality=quality, path=output_path, callback=callback)


Expand All @@ -243,4 +266,3 @@ class Client:
@classmethod
def get_video(cls, url):
return Video(url)

0 comments on commit 59759c8

Please sign in to comment.