j
This commit is contained in:
@@ -542,6 +542,53 @@ class HydrusNetwork:
|
||||
}
|
||||
return self._post("/add_tags/add_tags", data=body)
|
||||
|
||||
def mutate_tags_by_key(
|
||||
self,
|
||||
hash: Union[str,
|
||||
Iterable[str]],
|
||||
service_key: str,
|
||||
*,
|
||||
add_tags: Optional[Iterable[str]] = None,
|
||||
remove_tags: Optional[Iterable[str]] = None,
|
||||
) -> dict[str,
|
||||
Any]:
|
||||
"""Add or remove tags with a single /add_tags/add_tags call.
|
||||
|
||||
Hydrus Client API: POST /add_tags/add_tags
|
||||
Use `service_keys_to_actions_to_tags` so the client can apply additions
|
||||
and removals in a single request (action '0' = add, '1' = remove).
|
||||
"""
|
||||
hash_list = self._ensure_hashes(hash)
|
||||
def _clean(tags: Optional[Iterable[str]]) -> list[str]:
|
||||
if not tags:
|
||||
return []
|
||||
clean_list: list[str] = []
|
||||
for tag in tags:
|
||||
if not isinstance(tag, str):
|
||||
continue
|
||||
text = tag.strip()
|
||||
if not text:
|
||||
continue
|
||||
clean_list.append(text)
|
||||
return clean_list
|
||||
|
||||
actions: dict[str, list[str]] = {}
|
||||
adds = _clean(add_tags)
|
||||
removes = _clean(remove_tags)
|
||||
if adds:
|
||||
actions["0"] = adds
|
||||
if removes:
|
||||
actions["1"] = removes
|
||||
if not actions:
|
||||
return {}
|
||||
body = {
|
||||
"hashes": hash_list,
|
||||
"service_keys_to_actions_to_tags": {
|
||||
str(service_key): actions
|
||||
},
|
||||
}
|
||||
return self._post("/add_tags/add_tags", data=body)
|
||||
|
||||
def associate_url(self,
|
||||
file_hashes: Union[str,
|
||||
Iterable[str]],
|
||||
|
||||
@@ -7,13 +7,15 @@ API docs: https://docs.alldebrid.com/#general-informations
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
from SYS.logger import log, debug
|
||||
import time
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
|
||||
from typing import Any, Dict, Optional, Set, List, Sequence, Tuple
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from SYS.logger import log, debug
|
||||
from SYS.rich_display import show_provider_config_panel
|
||||
from .HTTP import HTTPClient
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -1035,6 +1037,7 @@ def unlock_link_cmdlet(result: Any, args: Sequence[str], config: Dict[str, Any])
|
||||
api_key = _get_alldebrid_api_key_from_config(config)
|
||||
|
||||
if not api_key:
|
||||
show_provider_config_panel("alldebrid", ["api_key"])
|
||||
log(
|
||||
"AllDebrid API key not configured (provider.alldebrid.api_key)",
|
||||
file=sys.stderr
|
||||
|
||||
Reference in New Issue
Block a user