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.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xigua-0.1.13.tar.gz | 30.4 kB | Without provenance | Details for xigua-0.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xigua-0.1.13-py3-none-any.whl | Python 3 | none | any | Details for xigua-0.1.13-py3-none-any.whl |
Total release size: 63.2 kB
Release files / xigua-0.1.13.tar.gz
| Download URL | xigua-0.1.13.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
069bc729198f3b9086934847dfcc3295b265a36d44b362fcbbbb0b992f7b6524
|
|
BLAKE2b-256 checksum How to use checksums |
711ea5b4aa7b7464d0bdd7c810da2946a019d6c01c2c32601e2f24cc75fa903d
|
| 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.13-py3-none-any.whl
| Download URL | xigua-0.1.13-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22f9ee843154d82df8edbdcfeb8cfe084048bf18c783323859ddbf11083139a6
|
|
BLAKE2b-256 checksum How to use checksums |
93995f3773f269624540c6344835841dcd46080feaa8e7554c8e079d21a50782
|
| 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.13
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.