narcoticfresh / shotwell
一个提供简单API访问Shotwell(默认Ubuntu图片管理器)sqlite数据库的PHP库。
v0.9.0
2016-06-12 17:44 UTC
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^5.4
- squizlabs/php_codesniffer: ^2.6
This package is auto-updated.
Last update: 2024-09-05 10:04:37 UTC
README
这是一个用于处理Shotwell(Ubuntu默认照片管理器)sqlite数据库的简单PHP库。
基本功能
为什么会有这个库?
我使用Shotwell来管理我的图片和视频(拥有大量收藏),我认为它非常棒!
我发现我需要使用存储在Shotwell数据库中的数据(顺便说一下,通常位于~/.local/share/shotwell/data/photo.db)来编写一些脚本(比如用我在Shotwell中给出的标签标记视频文件 - 似乎它无法做到的事情)。
最初我很高兴我所积累的所有数据都是可重用的格式(一个SQLite数据库),但我很快就对那个数据库的结构感到困惑。不同媒体类型(视频/照片)的存储和关系相当不寻常。
为了使事情简单化,创建了这个小型库。
这个库是否功能全面?
不是。它只是一个简单的东西,隐藏了一些Shotwell的内部复杂性,然后返回数据库内容的普通数组。
我不需要更多 - 我想过创建自定义模型来表示数据结构,但这没有意义。此外,只实现了我需要的函数(主要是关于基本操作和标记)。
为什么会有这个库?
它只在这里,因为我需要在多个我的私人项目中使用这个库。为了使那个依赖关系更简单,它必须上传到Packagist,所以它必须放在某个地方。所以那个地方就是这里。
安装
只需使用composer,查看Packagist页面。
要求如下
composer require narcoticfresh/shotwell
使用示例
<?php // make sure composer autoloader is there require_once 'vendor/autoload.php'; $shotwell = new \Narcoticfresh\Shotwell\Api('/home/user/.local/share/shotwell/data/photo.db'); // get everything $items = $shotwell->getAll(); // get only photos $items = $shotwell->getAllPhotos(); // get only videos $items = $shotwell->getAllVideos(); // get by a tag $items = $shotwell->getItemsByTag('diving'); // get all tags $tags = $shotwell->getAllTags(); // set tag on an object $shotwell->setItemTags('my-object-id', ['tag1', 'tag2']); // set item rating $shotwell->setItemRating('my-object-id', 3);
还有更多函数,请查看类文件...