dfdfdf
This commit is contained in:
@@ -388,25 +388,55 @@ class HydrusNetwork:
|
||||
results[file_hash] = self._post("/add_url/associate_url", data=body)
|
||||
return {"batched": results}
|
||||
|
||||
def set_notes(self, file_hashes: Union[str, Iterable[str]], notes: dict[str, str], service_name: str) -> dict[str, Any]:
|
||||
def set_notes(
|
||||
self,
|
||||
file_hash: str,
|
||||
notes: dict[str, str],
|
||||
*,
|
||||
merge_cleverly: bool = False,
|
||||
extend_existing_note_if_possible: bool = True,
|
||||
conflict_resolution: int = 3,
|
||||
) -> dict[str, Any]:
|
||||
"""Add or update notes associated with a file.
|
||||
|
||||
Hydrus Client API: POST /add_notes/set_notes
|
||||
Required JSON args: {"hash": <sha256 hex>, "notes": {name: text}}
|
||||
"""
|
||||
if not notes:
|
||||
raise ValueError("notes mapping must not be empty")
|
||||
hashes = self._ensure_hashes(file_hashes)
|
||||
body = {"hashes": hashes, "service_names_to_notes": {service_name: notes}}
|
||||
|
||||
file_hash = str(file_hash or "").strip().lower()
|
||||
if not file_hash:
|
||||
raise ValueError("file_hash must not be empty")
|
||||
|
||||
body: dict[str, Any] = {"hash": file_hash, "notes": notes}
|
||||
|
||||
if merge_cleverly:
|
||||
body["merge_cleverly"] = True
|
||||
body["extend_existing_note_if_possible"] = bool(extend_existing_note_if_possible)
|
||||
body["conflict_resolution"] = int(conflict_resolution)
|
||||
return self._post("/add_notes/set_notes", data=body)
|
||||
|
||||
def delete_notes(
|
||||
self,
|
||||
file_hashes: Union[str, Iterable[str]],
|
||||
file_hash: str,
|
||||
note_names: Sequence[str],
|
||||
service_name: str,
|
||||
) -> dict[str, Any]:
|
||||
names = [name for name in note_names if name]
|
||||
"""Delete notes associated with a file.
|
||||
|
||||
Hydrus Client API: POST /add_notes/delete_notes
|
||||
Required JSON args: {"hash": <sha256 hex>, "note_names": [..]}
|
||||
"""
|
||||
names = [str(name) for name in note_names if str(name or "").strip()]
|
||||
if not names:
|
||||
raise ValueError("note_names must not be empty")
|
||||
hashes = self._ensure_hashes(file_hashes)
|
||||
body = {"hashes": hashes, "service_names_to_deleted_note_names": {service_name: names}}
|
||||
return self._post("/add_notes/set_notes", data=body)
|
||||
|
||||
file_hash = str(file_hash or "").strip().lower()
|
||||
if not file_hash:
|
||||
raise ValueError("file_hash must not be empty")
|
||||
|
||||
body = {"hash": file_hash, "note_names": names}
|
||||
return self._post("/add_notes/delete_notes", data=body)
|
||||
|
||||
def get_file_relationships(self, file_hash: str) -> dict[str, Any]:
|
||||
query = {"hash": file_hash}
|
||||
|
||||
Reference in New Issue
Block a user