feature/sponsorblock #17
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -25,9 +25,11 @@
|
||||
"metallum",
|
||||
"musify",
|
||||
"OKBLUE",
|
||||
"pathvalidate",
|
||||
"Referer",
|
||||
"sponsorblock",
|
||||
"tracksort",
|
||||
"translit",
|
||||
"unmap",
|
||||
"youtube"
|
||||
]
|
||||
|
@ -16,6 +16,7 @@ from .cache import Cache
|
||||
from .rotating import RotatingProxy
|
||||
from ..objects import Target
|
||||
from ..utils import request_trace
|
||||
from ..utils.string_processing import shorten_display_url
|
||||
from ..utils.config import main_settings
|
||||
from ..utils.support_classes.download_result import DownloadResult
|
||||
from ..utils.hacking import merge_args
|
||||
@ -149,8 +150,6 @@ class Connection:
|
||||
exclude_headers: List[str] = None,
|
||||
**kwargs
|
||||
) -> Optional[requests.Response]:
|
||||
trace_string = f"{method} {url} \t{'[stream]' if kwargs.get('stream', False) else ''}"
|
||||
|
||||
if method is None:
|
||||
raise AttributeError("method is not set.")
|
||||
method = method.upper()
|
||||
@ -163,6 +162,7 @@ class Connection:
|
||||
current_kwargs.update(**kwargs)
|
||||
|
||||
parsed_url = urlparse(url)
|
||||
trace_string = f"{method} {shorten_display_url(url)} \t{'[stream]' if kwargs.get('stream', False) else ''}"
|
||||
|
||||
if not raw_headers:
|
||||
_headers = copy.copy(self.HEADER_VALUES)
|
||||
|
@ -178,3 +178,9 @@ def match_length(length_1: int | None, length_2: int | None) -> bool:
|
||||
if length_1 is None or length_2 is None:
|
||||
return True
|
||||
return abs(length_1 - length_2) <= ALLOWED_LENGTH_DISTANCE
|
||||
|
||||
def shorten_display_url(url: str, max_length: int = 150, chars_at_end: int = 4, shorten_string: str = "[...]") -> str:
|
||||
if len(url) <= max_length + chars_at_end + len(shorten_string):
|
||||
return url
|
||||
|
||||
return url[:max_length] + shorten_string + url[-chars_at_end:]
|
||||
|
Loading…
Reference in New Issue
Block a user