From 59759c886afec179de3f6e293285b559d0bcf3c3 Mon Sep 17 00:00:00 2001 From: Johannes Habel Date: Wed, 31 Jan 2024 20:13:15 +0100 Subject: [PATCH] 1.1 --- README.md | 6 +++--- README/Changelog.md | 4 ++++ README/Documentation.md | 7 +++---- setup.py | 2 +- xnxx_api/xnxx_api.py | 34 ++++++++++++++++++++++++++++------ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 02609da..68268b3 100644 --- a/README.md +++ b/README.md @@ -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() @@ -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 ``` @@ -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 diff --git a/README/Changelog.md b/README/Changelog.md index 3ccd71a..875a6ba 100644 --- a/README/Changelog.md +++ b/README/Changelog.md @@ -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` diff --git a/README/Documentation.md b/README/Documentation.md index 08a6858..676d63f 100644 --- a/README/Documentation.md +++ b/README/Documentation.md @@ -1,6 +1,6 @@ # XNXX API Documentation -> - Version 1.0 +> - Version 1.1 > - Author: Johannes Habel > - Copryight (C) 2024 > - License: GPL 3 @@ -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 diff --git a/setup.py b/setup.py index c10b790..6c2bbc8 100644 --- a/setup.py +++ b/setup.py @@ -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" diff --git a/xnxx_api/xnxx_api.py b/xnxx_api/xnxx_api.py index 5576c07..fcf226b 100644 --- a/xnxx_api/xnxx_api.py +++ b/xnxx_api/xnxx_api.py @@ -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: @@ -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) @@ -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: @@ -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) @@ -243,4 +266,3 @@ class Client: @classmethod def get_video(cls, url): return Video(url) -