Skip to main content

xigua — 小工具集

各类实用小功能,按模块组织,持续扩展。

已包含模块

media — 本地图片/视频元数据

读取本地图片或视频的全部元数据(中文键名输出)。

from xigua.media import MediaMetadataService

# 读取为字典
data = MediaMetadataService.read("/path/to/photo.jpg")

# 直接格式化输出
print(MediaMetadataService.format_file("/path/to/clip.mp4", fmt="text"))
print(MediaMetadataService.format_file("/path/to/clip.mp4", fmt="yaml", include_md5=False))

命令行:

xigua-media /path/to/photo.jpg
xigua-media /path/to/clip.mp4 --fmt text --no-md5

依赖说明:

  • 图片:Pillow(HEIC/HEIF 需 pip install xigua[heif])
  • 视频:系统需安装 ffprobe

media.hls — 本地 HLS 多码率转码

from xigua.media.hls import transcode_local_hls, select_hls_rungs

master, tmp = transcode_local_hls("/path/to/video.mov")
if master:
    print(master)
    tmp.cleanup()

转码进度条需 pip install xigua[hls](rich)。

log — 通用日志器

标准库 logging 的轻量封装,提供上下文绑定、稳定哈希采样、敏感字段脱敏、JSON/文本输出等能力,方法签名与 logging.Logger 保持一致(支持 %s 占位符延迟格式化、exc_info)。

from xigua.log import get_logger, LoggerConfig

logger = get_logger(
    "my_app",
    config=LoggerConfig(
        level="INFO",
        console=True,
        file_path="logs/app.log",   # 不设置则不写文件,不产生磁盘副作用
        log_format="json",          # "text" 或 "json"
        sample_rate=0.5,            # DEBUG/INFO 采样率,WARNING 及以上始终记录
        sensitive_fields=["password", "token"],
    ),
)

logger.info("处理请求 user_id=%s", 123, extra={"request_id": "abc"})

with logger.context(request_id="abc-123"):
    logger.info("子任务开始")

with logger.timeit("批处理耗时"):
    do_work()

try:
    risky()
except Exception:
    logger.exception("处理失败")

同一个 name 重复调用 get_logger() 会复用同一实例(类似 logging.getLogger)。也可以省略 config,改用 LoggerConfig.from_env() 支持的 XIGUA_LOG_* 环境变量(如 XIGUA_LOG_LEVEL、XIGUA_LOG_FORMAT、XIGUA_LOG_SAMPLE_RATE 等)按环境切换配置。

安装

pip install xigua
pip install xigua[heif]   # 支持 HEIC/HEIF
pip install xigua[hls]    # HLS 转码进度条

发布

cd /Users/xigua/pypi-publish
./publish xigua --bump patch

Metadata

Release files for xigua 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xigua 0.1.12
File Size Uploaded Provenance Actions
xigua-0.1.12.tar.gz 28.9 kB Without provenance Details for xigua-0.1.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xigua 0.1.12
File Interpreter ABI Platform Actions
xigua-0.1.12-py3-none-any.whl Python 3 none any Details for xigua-0.1.12-py3-none-any.whl

Total release size: 60.7 kB

Release files / xigua-0.1.12.tar.gz

Download URL xigua-0.1.12.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f9cb7e0103587fab8bd99b6a252cab4725e53bd6a2376aed710be8ffc5a6a8a9
BLAKE2b-256 checksum
How to use checksums
ce0a05a4b8dae5a961fece31dff3e242255e9d7458b7c5c34a380fb214843224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / xigua-0.1.12-py3-none-any.whl

Download URL xigua-0.1.12-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9a13f03ab99588d1de240db3406d1e47bc250916af9d526c34c6f087ac7efab
BLAKE2b-256 checksum
How to use checksums
9a3f74745bdf89433b8a89ce2ba3490ce4089b1eb681cea8a2851d9a73471a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for xigua 0.1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page