Skip to content

Commit f1fbf6b

Browse files
committed
- release v4.8.1
1 parent 607fb2b commit f1fbf6b

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "phub"
3-
version = "4.8.0"
3+
version = "4.8.1"
44
description = "An API for Pornhub"
55
authors = [
66
{name = 'Egsagon', email = "[email protected]"},
@@ -13,7 +13,7 @@ classifiers = [
1313
"Development Status :: 4 - Beta",
1414
"Programming Language :: Python"
1515
]
16-
dependencies = ["httpx[brotli,socks]", "ffmpeg-progress-yield", "eaf_base_api"]
16+
dependencies = ["httpx[brotli,socks]", "eaf_base_api"]
1717
requires-python = ">=3.9"
1818

1919

src/phub/objects/video.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
if TYPE_CHECKING:
2020
from ..core import Client
21-
from ..utils import Quality
2221

2322

2423
class Video:
@@ -226,7 +225,9 @@ def get_m3u8_urls(self) -> dict:
226225
def download(self,
227226
path: Union[str, os.PathLike],
228227
downloader: Union[Callable, str] = "threaded",
229-
quality: Quality | str = 'best',
228+
quality: str = 'best',
229+
remux: bool = False,
230+
display_remux: Callable[[int, int], None] = None,
230231
*,
231232
display: Callable[[int, int], None] = display.default()) -> str:
232233
'''
@@ -237,6 +238,8 @@ def download(self,
237238
quality (Quality | str | int): The video quality.
238239
downloader (Callable): The download backend.
239240
display (Callable): The progress display.
241+
remux (bool): Whether to remux the video from MPEG-TS to MP4 (h264)
242+
display_remux (Callable[[int, int], None], optional): The display backend for remuxing.
240243
241244
Returns:
242245
str: The downloader video path.
@@ -249,37 +252,14 @@ def download(self,
249252
self.logger.info('Starting download for %s at %s', self, path)
250253

251254
try:
252-
self.client.core.download(video=self, quality=quality, path=path, callback=display, downloader=downloader)
255+
self.client.core.download(video=self, quality=quality, path=path, callback=display, downloader=downloader,
256+
remux=remux, callback_remux=display_remux)
253257

254258
except Exception as e:
255259
self.logger.error(f"An error occured while downloading video {e}")
256260

257261
return path
258262

259-
def get_direct_url(self, quality: Quality) -> str:
260-
'''
261-
Get the direct video URL given a specific quality.
262-
263-
Args:
264-
quality (Quality): The video quality.
265-
266-
Returns:
267-
str: The direct url.
268-
'''
269-
270-
from ..utils import Quality
271-
qual = Quality(quality)
272-
273-
# Get remote
274-
sources = self.fetch('page@mediaDefinitions')
275-
remote = [s for s in sources if 'remote' in s][0]['videoUrl']
276-
277-
# Parse quality
278-
quals = {int(s['quality']): s['videoUrl']
279-
for s in self.client.call(remote).json()}
280-
281-
return qual.select(quals)
282-
283263
# === Interaction methods === #
284264

285265
def _assert_internal_success(self, res: dict) -> None:

src/phub/tests/test_video.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def test_video_information():
2323
embed = video.embed
2424
image = video.image.url
2525
id = video.id
26-
26+
assert isinstance(video.download(path="./", quality="best", remux=True), str)
27+
assert isinstance(video.download(path="./", quality="beest"), str)
2728
assert isinstance(title, str) and len(title) > 3
2829
assert isinstance(likes, int) and len(str(likes)) >= 1
2930
assert isinstance(dislikes, int) and len(str(dislikes)) >= 1

0 commit comments

Comments
 (0)