f
This commit is contained in:
@@ -558,15 +558,15 @@ class Folder(Store):
|
||||
|
||||
if url:
|
||||
try:
|
||||
debug(
|
||||
f"[Folder.add_file] merging {len(url)} URLs for {file_hash}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
from SYS.metadata import normalize_urls
|
||||
|
||||
existing_meta = db.get_metadata(file_hash) or {}
|
||||
existing_urls = normalize_urls(existing_meta.get("url"))
|
||||
incoming_urls = normalize_urls(url)
|
||||
debug(
|
||||
f"[Folder.add_file] merging {len(incoming_urls)} URLs for {file_hash}: {incoming_urls}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
changed = False
|
||||
for entry in list(incoming_urls or []):
|
||||
if not entry:
|
||||
@@ -580,7 +580,7 @@ class Folder(Store):
|
||||
{"url": existing_urls},
|
||||
)
|
||||
debug(
|
||||
f"[Folder.add_file] URLs merged for {file_hash}",
|
||||
f"[Folder.add_file] URLs merged for {file_hash}: {existing_urls}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
except Exception as exc:
|
||||
|
||||
@@ -1670,16 +1670,23 @@ class HydrusNetwork(Store):
|
||||
|
||||
raw_urls: Any = meta.get("known_urls"
|
||||
) or meta.get("urls") or meta.get("url") or []
|
||||
|
||||
def _is_url(s: Any) -> bool:
|
||||
if not isinstance(s, str):
|
||||
return False
|
||||
v = s.strip().lower()
|
||||
return bool(v and ("://" in v or v.startswith(("magnet:", "torrent:"))))
|
||||
|
||||
if isinstance(raw_urls, str):
|
||||
val = raw_urls.strip()
|
||||
return [val] if val else []
|
||||
return [val] if _is_url(val) else []
|
||||
if isinstance(raw_urls, list):
|
||||
out: list[str] = []
|
||||
for u in raw_urls:
|
||||
if not isinstance(u, str):
|
||||
continue
|
||||
u = u.strip()
|
||||
if u:
|
||||
if u and _is_url(u):
|
||||
out.append(u)
|
||||
return out
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user