f
This commit is contained in:
@@ -1174,7 +1174,7 @@ def hydrus_export(args, _parser) -> int:
|
||||
return 1
|
||||
ffmpeg_metadata = prepare_ffmpeg_metadata(metadata_payload)
|
||||
|
||||
def _normalise_ext(value: Optional[str]) -> Optional[str]:
|
||||
def _normalize_ext(value: Optional[str]) -> Optional[str]:
|
||||
if not value:
|
||||
return None
|
||||
cleaned = value.strip()
|
||||
@@ -1271,7 +1271,7 @@ def hydrus_export(args, _parser) -> int:
|
||||
log(f"{exc}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
source_suffix = _normalise_ext(getattr(args, "source_ext", None))
|
||||
source_suffix = _normalize_ext(getattr(args, "source_ext", None))
|
||||
if source_suffix and source_suffix.lower() == ".bin":
|
||||
source_suffix = None
|
||||
|
||||
@@ -1313,7 +1313,7 @@ def hydrus_export(args, _parser) -> int:
|
||||
) else None
|
||||
if isinstance(entries, list) and entries:
|
||||
entry = entries[0]
|
||||
ext_value = _normalise_ext(
|
||||
ext_value = _normalize_ext(
|
||||
entry.get("ext") if isinstance(entry,
|
||||
dict) else None
|
||||
)
|
||||
@@ -1328,7 +1328,7 @@ def hydrus_export(args, _parser) -> int:
|
||||
if os.environ.get("DOWNLOW_DEBUG"):
|
||||
log(f"hydrus metadata fetch failed: {exc}", file=sys.stderr)
|
||||
if not resolved_suffix:
|
||||
fallback_suffix = _normalise_ext(original_suffix)
|
||||
fallback_suffix = _normalize_ext(original_suffix)
|
||||
if fallback_suffix and fallback_suffix.lower() == ".bin":
|
||||
fallback_suffix = None
|
||||
resolved_suffix = fallback_suffix or ".hydrus"
|
||||
@@ -2098,9 +2098,9 @@ def _generate_hydrus_url_variants(url: str) -> List[str]:
|
||||
alternate_scheme = "https" if parsed.scheme == "http" else "http"
|
||||
push(urlunsplit((alternate_scheme, parsed.netloc, parsed.path, parsed.query, parsed.fragment)))
|
||||
|
||||
normalised_netloc = parsed.netloc.lower()
|
||||
if normalised_netloc and normalised_netloc != parsed.netloc:
|
||||
push(urlunsplit((parsed.scheme, normalised_netloc, parsed.path, parsed.query, parsed.fragment)))
|
||||
normalized_netloc = parsed.netloc.lower()
|
||||
if normalized_netloc and normalized_netloc != parsed.netloc:
|
||||
push(urlunsplit((parsed.scheme, normalized_netloc, parsed.path, parsed.query, parsed.fragment)))
|
||||
|
||||
if parsed.path:
|
||||
trimmed_path = parsed.path.rstrip("/")
|
||||
@@ -2377,7 +2377,7 @@ def fetch_hydrus_metadata_by_url(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
hashes: Optional[List[str]] = None
|
||||
file_ids: Optional[List[int]] = None
|
||||
matched_url = None
|
||||
normalised_reported = None
|
||||
normalized_reported = None
|
||||
seen: Set[str] = set()
|
||||
queue = deque()
|
||||
for variant in _generate_hydrus_url_variants(url):
|
||||
@@ -2404,11 +2404,11 @@ def fetch_hydrus_metadata_by_url(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
response_hashes_list: List[str] = []
|
||||
response_file_ids_list: List[int] = []
|
||||
if isinstance(response, dict):
|
||||
normalised_value = response.get("normalised_url")
|
||||
if isinstance(normalised_value, str):
|
||||
trimmed = normalised_value.strip()
|
||||
normalized_value = response.get("normalized_url")
|
||||
if isinstance(normalized_value, str):
|
||||
trimmed = normalized_value.strip()
|
||||
if trimmed:
|
||||
normalised_reported = normalised_reported or trimmed
|
||||
normalized_reported = normalized_reported or trimmed
|
||||
if trimmed not in seen:
|
||||
queue.append(trimmed)
|
||||
for redirect_key in ("redirect_url", "url"):
|
||||
@@ -2478,7 +2478,7 @@ def fetch_hydrus_metadata_by_url(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
}
|
||||
result = fetch_hydrus_metadata(followup_payload)
|
||||
result["matched_url"] = matched_url or url
|
||||
result["normalised_url"] = normalised_reported or matched_url or url
|
||||
result["normalized_url"] = normalized_reported or matched_url or url
|
||||
result["tried_urls"] = tried_variants
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user