Skip to content

Commit 6dfc0c4

Browse files
committed
- added some method I need for Porn Fetch
1 parent 4e072ab commit 6dfc0c4

3 files changed

Lines changed: 26 additions & 70 deletions

File tree

eporner_api/eporner_api.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,7 @@ def author(self) -> str:
333333
self.logger.error("Couldn't find author. Please report this!")
334334
return None
335335

336-
def direct_download_link(self, quality, mode) -> str:
337-
"""
338-
Returns the direct download URL for a given quality (best/half/worst or a specific resolution).
339-
:param quality: 'best', 'half', 'worst', or a specific resolution like '720', '720p', 1080, etc.
340-
:param mode: The mode to filter links by (e.g., 'video')
341-
:return: str
342-
"""
336+
def _direct_download_quality_map(self, mode) -> dict[int, str]:
343337
if not self.enable_html:
344338
raise HTML_IS_DISABLED("HTML content is disabled! See Documentation for more details")
345339

@@ -369,6 +363,25 @@ def direct_download_link(self, quality, mode) -> str:
369363
height = int(m.group(1)) # e.g., 1080
370364
quality_to_url[height] = href # last one wins; order doesn't matter
371365

366+
return quality_to_url
367+
368+
def video_qualities(self, mode=Encoding.mp4_h264) -> list:
369+
"""
370+
Returns the available direct download qualities for a given mode.
371+
:param mode: The mode to filter links by (e.g., 'video')
372+
:return: list
373+
"""
374+
quality_to_url = self._direct_download_quality_map(mode)
375+
return sorted(quality_to_url.keys())
376+
377+
def direct_download_link(self, quality, mode) -> str:
378+
"""
379+
Returns the direct download URL for a given quality (best/half/worst or a specific resolution).
380+
:param quality: 'best', 'half', 'worst', or a specific resolution like '720', '720p', 1080, etc.
381+
:param mode: The mode to filter links by (e.g., 'video')
382+
:return: str
383+
"""
384+
quality_to_url = self._direct_download_quality_map(mode)
372385
if not quality_to_url:
373386
raise NotAvailable(f"No URLs available for mode '{mode}'")
374387

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "Eporner_API"
7-
version = "1.9.6"
7+
version = "1.9.7"
88
description = "A Python API for the Porn Site Eporner.com"
99
readme = { file = "README.md", content-type = "text/markdown" }
1010
requires-python = ">=3.9" # 3.9 due to httpx requirements

uv.lock

Lines changed: 5 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)