trailsnap-cli 0.3.9__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/PKG-INFO +1 -1
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/pyproject.toml +1 -1
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/cli.py +1 -1
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/utils.py +9 -1
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap_cli.egg-info/PKG-INFO +1 -1
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/README.md +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/setup.cfg +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/__init__.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/albums.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/config.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/folders.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/locations.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/medias.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/people.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/photos.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/commands/tags.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap/output.py +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap_cli.egg-info/SOURCES.txt +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap_cli.egg-info/dependency_links.txt +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap_cli.egg-info/entry_points.txt +0 -0
- {trailsnap_cli-0.3.9 → trailsnap_cli-0.4.0}/trailsnap_cli.egg-info/top_level.txt +0 -0
|
@@ -8,7 +8,7 @@ sys.path.insert(0, str(Path(__file__).parent))
|
|
|
8
8
|
from commands import config, photos, tags, albums, locations, people, folders, medias
|
|
9
9
|
from output import set_formatter, OutputFormatter
|
|
10
10
|
|
|
11
|
-
VERSION = "0.
|
|
11
|
+
VERSION = "0.4.0"
|
|
12
12
|
|
|
13
13
|
def main():
|
|
14
14
|
if hasattr(sys.stdout, "reconfigure"):
|
|
@@ -64,7 +64,15 @@ def make_request(endpoint, params=None, method="GET", response_type="json"):
|
|
|
64
64
|
try:
|
|
65
65
|
with urllib.request.urlopen(req) as response:
|
|
66
66
|
if response_type == "json":
|
|
67
|
-
|
|
67
|
+
result = json.loads(response.read().decode("utf-8"))
|
|
68
|
+
# 处理可能返回的统一结构 {"code": ..., "msg": ..., "data": ...}
|
|
69
|
+
if isinstance(result, dict) and "code" in result and "msg" in result:
|
|
70
|
+
if result["code"] not in (200, 0):
|
|
71
|
+
print(f"API 请求失败: {result.get('msg', '未知错误')} (错误码: {result['code']})")
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
# 如果有 data 字段,则返回 data,否则返回整个结构(兼容部分可能只需要成功状态的情况)
|
|
74
|
+
return result.get("data", result)
|
|
75
|
+
return result
|
|
68
76
|
elif response_type == "text":
|
|
69
77
|
return response.read().decode("utf-8")
|
|
70
78
|
if response_type == "bytes":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|