mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-17 08:35:08 -04:00

* Add SSL verification configuration option - Add `verify_ssl` parameter to DownloadsConfig to control SSL certificate verification - Update client methods to use the new SSL verification setting - Add CLI option `--no-ssl-verify` to disable SSL verification - Implement SSL verification support across various clients and network requests - Add test suite to validate SSL verification configuration * Enhance SSL certificate handling with certifi support - Add new `ssl_utils.py` module for SSL certificate management - Implement optional certifi package support for improved certificate verification - Add utility functions for creating SSL contexts and handling connector kwargs - Update various clients to use new SSL utility functions - Add helpful error messaging for SSL certificate verification issues - Include optional certifi dependency in pyproject.toml * Enhance SSL verification tests and configuration support - Add comprehensive test suite for SSL verification utilities - Implement tests for SSL context creation and configuration - Update test configuration to include verify_ssl option - Add test coverage for SSL verification across different clients and methods - Improve error handling and testing for SSL-related configurations * run ruff format * Fix ruff checks --------- Co-authored-by: Nathan Thomas <nathanthomas707@gmail.com>
28 lines
804 B
Python
28 lines
804 B
Python
from string import printable
|
|
|
|
from pathvalidate import sanitize_filename, sanitize_filepath # type: ignore
|
|
|
|
ALLOWED_CHARS = set(printable)
|
|
|
|
|
|
# TODO: remove this when new pathvalidate release arrives with https://github.com/thombashi/pathvalidate/pull/48
|
|
def truncate_str(text: str) -> str:
|
|
str_bytes = text.encode()
|
|
str_bytes = str_bytes[:255]
|
|
return str_bytes.decode(errors="ignore")
|
|
|
|
|
|
def clean_filename(fn: str, restrict: bool = False) -> str:
|
|
path = truncate_str(str(sanitize_filename(fn)))
|
|
if restrict:
|
|
path = "".join(c for c in path if c in ALLOWED_CHARS)
|
|
|
|
return path
|
|
|
|
|
|
def clean_filepath(fn: str, restrict: bool = False) -> str:
|
|
path = str(sanitize_filepath(fn))
|
|
if restrict:
|
|
path = "".join(c for c in path if c in ALLOWED_CHARS)
|
|
|
|
return path
|