From a13af98b932a568e7748ece0ef7bd78b97fd546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8A=E6=99=9A=E6=89=93=E8=80=81=E8=99=8E?= Date: Thu, 2 Apr 2026 01:57:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E6=8A=95=E7=A8=BF]=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC:=20=E7=9B=B8=E5=86=8C=E7=85=A7=E7=89=87?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=20=E2=80=94=20by=20=E4=BB=8A=E6=99=9A?= =?UTF-8?q?=E6=89=93=E8=80=81=E8=99=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/basic/script_mngcmh7k.py | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 script_library/scripts/basic/script_mngcmh7k.py diff --git a/script_library/scripts/basic/script_mngcmh7k.py b/script_library/scripts/basic/script_mngcmh7k.py new file mode 100644 index 0000000..9a6f1d0 --- /dev/null +++ b/script_library/scripts/basic/script_mngcmh7k.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +相册照片统计脚本 +统计相册中的照片数量,并按类型分类 +""" + +import photos +import dialogs +import console +from datetime import datetime + +def main(): + """主函数:统计相册照片""" + console.clear() + print("📸 相册照片统计") + print("=" * 40) + + # 检查相册权限 + if not photos.is_available(): + print("❌ 无法访问相册,请检查权限设置") + dialogs.alert("权限错误", "无法访问相册,请检查App权限设置") + return + + print("正在扫描相册...") + + try: + # 获取所有照片 + all_photos = photos.get_assets(media_type='photo', limit=0) + total_count = len(all_photos) + + # 获取所有视频 + all_videos = photos.get_assets(media_type='video', limit=0) + video_count = len(all_videos) + + # 获取所有媒体(照片+视频) + all_media = photos.get_assets(media_type='all', limit=0) + media_count = len(all_media) + + print(f"✅ 扫描完成!") + print() + + # 显示统计结果 + print("📊 统计结果:") + print(f" 照片数量:{total_count} 张") + print(f" 视频数量:{video_count} 个") + print(f" 媒体总数:{media_count} 个") + print() + + # 如果有照片,显示一些详细信息 + if total_count > 0: + # 获取最近的照片 + recent_photos = photos.get_recent_images(count=min(5, total_count)) + print("📅 最近的照片:") + for i, asset in enumerate(recent_photos, 1): + try: + # 尝试获取日期信息 + if hasattr(asset, 'creation_date'): + # 确保 creation_date 是 datetime 对象 + from datetime import datetime + if isinstance(asset.creation_date, (int, float)): + # 如果是时间戳,转换为 datetime + date_obj = datetime.fromtimestamp(asset.creation_date) + date_str = date_obj.strftime("%Y-%m-%d %H:%M") + else: + # 假设是 datetime 对象 + date_str = asset.creation_date.strftime("%Y-%m-%d %H:%M") + else: + date_str = "未知日期" + except: + date_str = "日期未知" + + # 获取照片尺寸 + width = getattr(asset, 'pixel_width', '未知') + height = getattr(asset, 'pixel_height', '未知') + print(f" {i}. {date_str} - {width}x{height}") + + # 获取相册信息 + print() + print("📁 相册信息:") + albums = photos.get_albums() + smart_albums = photos.get_smart_albums() + + print(f" 普通相册:{len(albums)} 个") + print(f" 智能相册:{len(smart_albums)} 个") + + # 显示一些特殊相册 + special_albums = [] + try: + screenshots = photos.get_screenshots_album() + if screenshots: + special_albums.append(f"截屏 ({screenshots.count} 张)") + except: + pass + + try: + recently_added = photos.get_recently_added_album() + if recently_added: + special_albums.append(f"最近添加 ({recently_added.count} 张)") + except: + pass + + try: + selfies = photos.get_selfies_album() + if selfies: + special_albums.append(f"自拍 ({selfies.count} 张)") + except: + pass + + if special_albums: + print(f" 特殊相册:{', '.join(special_albums)}") + + print() + print("=" * 40) + print("📱 操作提示:") + print(" 1. 要查看照片详情,可以使用 photos.pick_image()") + print(" 2. 要拍照,可以使用 photos.capture_image()") + print(" 3. 要保存图片到相册,可以使用 photos.save_image()") + + # 显示弹窗总结 + summary = f""" +照片统计完成! + +📸 照片:{total_count} 张 +🎬 视频:{video_count} 个 +📁 相册:{len(albums)} 个普通相册 + {len(smart_albums)} 个智能相册 + +点击确定继续... + """ + dialogs.alert("相册统计结果", summary.strip()) + + except Exception as e: + print(f"❌ 发生错误:{e}") + dialogs.alert("错误", f"统计相册时发生错误:{e}") + +if __name__ == "__main__": + main() \ No newline at end of file From 4de3b18c3dbc898424c28507d11efb3b4a676eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8A=E6=99=9A=E6=89=93=E8=80=81=E8=99=8E?= Date: Thu, 2 Apr 2026 01:57:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E6=8A=95=E7=A8=BF]=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20index.json:=20=E6=B7=BB=E5=8A=A0=20=E7=9B=B8=E5=86=8C?= =?UTF-8?q?=E7=85=A7=E7=89=87=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script_library/index.json | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/script_library/index.json b/script_library/index.json index f58a8cc..6ce1352 100644 --- a/script_library/index.json +++ b/script_library/index.json @@ -1,7 +1,7 @@ { "format_version": 1, - "data_version": 54, - "updated": "2026-04-01T17:44:05.067Z", + "data_version": 55, + "updated": "2026-04-01T17:57:54.047Z", "announcement": null, "categories": [ { @@ -1237,6 +1237,29 @@ "updated": null, "status": "removed", "lines": 18 + }, + { + "id": "script_mngcmh7k", + "name": "相册照片统计", + "name_en": "相册照片统计", + "desc": "可以统计你相册的所有照片,并分类显示", + "desc_en": "可以统计你相册的所有照片,并分类显示", + "category": "basic", + "file": "scripts/basic/script_mngcmh7k.py", + "thumbnail": null, + "version": 1, + "file_type": "py", + "author": "今晚打老虎", + "author_en": "今晚打老虎", + "tags": [ + "community" + ], + "requires": [], + "min_app_version": "1.5.0", + "added": "2026-04-01", + "updated": null, + "status": "active", + "lines": 138 } ] }