Skip to content

Commit

Permalink
Fix redirect property
Browse files Browse the repository at this point in the history
  • Loading branch information
Egsago-n committed Aug 11, 2024
1 parent e38985e commit de8b8e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python"
]
dependencies = ["requests", "ffmpeg-progress-yield"]
dependencies = ["httpx[brotli,socks]", "ffmpeg-progress-yield"]
requires-python = ">=3.9"

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/phub/modules/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def default(video: Video,
try:
segment = video.client.call(url, throw = False, timeout = 4, silent = True)

if segment.ok:
if segment.is_success:
buffer += segment.content
callback(i + 1, length)
break
Expand Down
5 changes: 3 additions & 2 deletions src/phub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'''

import math
import httpx
import logging
from typing import Generator, Iterable, Iterator, Union

Expand Down Expand Up @@ -234,10 +235,10 @@ def head(client: object, url: str) -> Union[str, bool]:
str | bool: The redirect URL if success, False otherwise.
'''

res = client.call(url, 'HEAD', throw = False, silent = True)
res: httpx.Response = client.call(url, 'HEAD', throw = False, silent = True)

# Make sure we were not redirected
if res.ok and res.url.endswith(url):
if res.is_success and not res.has_redirect_location:
return res.url
return False

Expand Down

0 comments on commit de8b8e5

Please sign in to comment.