spothomelight 0.1.0__py3-none-any.whl → 1.0.1__py3-none-any.whl
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.
- {spothomelight-0.1.0.dist-info → spothomelight-1.0.1.dist-info}/METADATA +154 -147
- {spothomelight-0.1.0.dist-info → spothomelight-1.0.1.dist-info}/RECORD +6 -5
- spothomelight-1.0.1.dist-info/licenses/LICENSE +21 -0
- {spothomelight-0.1.0.dist-info → spothomelight-1.0.1.dist-info}/WHEEL +0 -0
- {spothomelight-0.1.0.dist-info → spothomelight-1.0.1.dist-info}/entry_points.txt +0 -0
- {spothomelight-0.1.0.dist-info → spothomelight-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -1,147 +1,154 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: spothomelight
|
|
3
|
-
Version: 0.1
|
|
4
|
-
Summary: Sync Spotify cover color to Home Assistant via Webhook
|
|
5
|
-
Author-email: "ZGQ Inc." <zgqinc@gmail.com>
|
|
6
|
-
Project-URL: Homepage, https://
|
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Requires-Python: >=3.8
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spothomelight
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Sync Spotify cover color to Home Assistant via Webhook
|
|
5
|
+
Author-email: "ZGQ Inc." <zgqinc@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/ZGQ-inc/SpotHomeLight
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: spotipy
|
|
15
|
+
Requires-Dist: colorgram.py
|
|
16
|
+
Requires-Dist: Pillow
|
|
17
|
+
Requires-Dist: appdirs
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# SpotHomeLight 🎵🏠💡
|
|
21
|
+
|
|
22
|
+
**SpotHomeLight** 是一个轻量级的 Python 服务,用于将 Spotify 当前播放封面的主色调同步到 Home Assistant。
|
|
23
|
+
|
|
24
|
+
它运行在你的家用服务器(Linux 或 Windows)上,通过 K-Means 聚类算法提取封面颜色,并通过 Webhook 实时推送到 Home Assistant,让你的智能灯光跟随音乐氛围律动。
|
|
25
|
+
|
|
26
|
+
## ✨ 功能特性
|
|
27
|
+
|
|
28
|
+
* **跨平台支持**:完美支持 Linux (Systemd) 和 Windows (计划任务)。
|
|
29
|
+
* **无头模式设计**:专为无显示器的家用服务器设计,支持终端内完成 OAuth 认证。
|
|
30
|
+
* **智能取色**:使用 K-Means 聚类算法提取最主要颜色,并进行缩略图预处理以降低 CPU 占用。
|
|
31
|
+
* **开机自启**:内置一键配置开机自动运行 (`-a`)。
|
|
32
|
+
* **低资源占用**:去重机制,仅在切歌时进行下载和计算。
|
|
33
|
+
|
|
34
|
+
## 🛠️ 前置要求
|
|
35
|
+
|
|
36
|
+
1. **Home Assistant**: 一个运行中的 HA 实例。
|
|
37
|
+
2. **Spotify 开发者账号**: 用于获取 API 凭证。
|
|
38
|
+
|
|
39
|
+
## 📦 安装
|
|
40
|
+
|
|
41
|
+
使用 pip 安装:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install spothomelight
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 🚀 快速开始
|
|
48
|
+
|
|
49
|
+
### 准备 Spotify API
|
|
50
|
+
|
|
51
|
+
1. 登录 [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/).
|
|
52
|
+
2. 创建一个新的 App (例如命名为 `SpotHomeLight`)。
|
|
53
|
+
3. 将 Redirect URI 设置为:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
http://127.0.0.1:29092/callback
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. 记下 **Client ID** 和 **Client Secret**。
|
|
60
|
+
|
|
61
|
+
### 初始化配置
|
|
62
|
+
|
|
63
|
+
运行以下命令打开配置文件:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
spothomelight -c
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
conf描述:
|
|
70
|
+
|
|
71
|
+
```ini
|
|
72
|
+
[SPOTIFY]
|
|
73
|
+
client_id = Client ID
|
|
74
|
+
client_secret = Client Secret
|
|
75
|
+
redirect_uri = 重定向URI(一般不需要修改,除非你知道自己在干什么。)
|
|
76
|
+
|
|
77
|
+
[HOME_ASSISTANT]
|
|
78
|
+
ha_url = Home Assistant 地址(局域网/广域网)
|
|
79
|
+
webhook_id = 从 Home Assistant 获取的 Webhook ID
|
|
80
|
+
|
|
81
|
+
[GENERAL]
|
|
82
|
+
interval = 循环周期(秒)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 配置 Home Assistant
|
|
86
|
+
|
|
87
|
+
登录 Home Assistant 后台,设置,自动化与场景,创建自动化,创建新的自动化,右上角三点菜单,YAML 编辑,将下面的yaml粘贴进去,保存。
|
|
88
|
+
|
|
89
|
+
右上角三点菜单,可视化编辑,复制 每当 里面的 Webhook ID,注意不要点复制按钮,那会复制API地址,需要选中输入框的内容并复制。
|
|
90
|
+
|
|
91
|
+
就执行 的实体删除pending,添加目标,选择自己的RGB灯,保存。
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
alias: Spotify Cover Sync
|
|
95
|
+
description: ""
|
|
96
|
+
mode: restart
|
|
97
|
+
trigger:
|
|
98
|
+
- platform: webhook
|
|
99
|
+
webhook_id: ""
|
|
100
|
+
local_only: true
|
|
101
|
+
condition: []
|
|
102
|
+
action:
|
|
103
|
+
- service: light.turn_on
|
|
104
|
+
target:
|
|
105
|
+
entity_id: light.pending
|
|
106
|
+
data:
|
|
107
|
+
rgb_color: "{{ trigger.json.rgb }}"
|
|
108
|
+
brightness_pct: 100
|
|
109
|
+
transition: 2
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 首次运行与认证
|
|
113
|
+
|
|
114
|
+
在终端运行:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
spothomelight
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
考虑到服务器通常没有浏览器,程序会打印一个认证 URL。
|
|
121
|
+
|
|
122
|
+
1. 复制该 URL 到你电脑的浏览器中打开。
|
|
123
|
+
2. 登录并点击“同意”。
|
|
124
|
+
3. 浏览器会跳转到一个 `127.0.0.1` 的无法连接页面。
|
|
125
|
+
4. 复制浏览器地址栏中完整的 URL。
|
|
126
|
+
5. 回到服务器终端,粘贴 URL 并回车。
|
|
127
|
+
|
|
128
|
+
认证成功后,程序应该开始监控并在终端输出日志,观察输出是否正常。
|
|
129
|
+
|
|
130
|
+
### 第五步:设置开机自启
|
|
131
|
+
|
|
132
|
+
确认运行正常后,Ctrl+C 停止程序,然后运行:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
spothomelight -a
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
* **Linux**: 会自动创建并启用 Systemd User Service。
|
|
139
|
+
* **Windows**: 会自动创建 Windows 计划任务(登录时运行)。
|
|
140
|
+
|
|
141
|
+
停止服务:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
spothomelight -s
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 🐛 已知问题
|
|
148
|
+
|
|
149
|
+
* **取色结果与客户端不一致**:
|
|
150
|
+
本工具目前使用 **K-Means 聚类算法** 来提取封面主色调。由于 Spotify 官方客户端的动态取色算法(涉及饱和度筛选、亮度平衡、以及如何排除纯黑/纯白背景等逻辑)并未公开且较为复杂,**本工具计算出的颜色可能与你在 Spotify 电脑或手机端看到的背景色存在差异**。
|
|
151
|
+
|
|
152
|
+
## 📝 License
|
|
153
|
+
|
|
154
|
+
MIT License. Copyright (c) 2026 ZGQ Inc.
|
|
@@ -6,8 +6,9 @@ spothomelight/main.py,sha256=jX8esko2yj8c09HKBb1qmQloWE0mUQEc0F_CL27l5t8,1377
|
|
|
6
6
|
spothomelight/service.py,sha256=jrlnIn9LL1YIEUrWoiVzPQgEFNvh0L0QBUSqNBMvAOg,1649
|
|
7
7
|
spothomelight/utils.py,sha256=TnGji05MKMTsoqWUq5wFPx6jLthqA-KWVH-dCu5VbIc,1814
|
|
8
8
|
spothomelight/utils_median_cut.py,sha256=9sqUBk0ZpHWwfoPl4YPRcljE_K05w8trZFQo8bVCMds,1991
|
|
9
|
-
spothomelight-0.1.
|
|
10
|
-
spothomelight-0.1.
|
|
11
|
-
spothomelight-0.1.
|
|
12
|
-
spothomelight-0.1.
|
|
13
|
-
spothomelight-0.1.
|
|
9
|
+
spothomelight-1.0.1.dist-info/licenses/LICENSE,sha256=_r815CZLcqdQJmXH7FeFNoBT8gmiGtsdqo4aynUS-DM,1065
|
|
10
|
+
spothomelight-1.0.1.dist-info/METADATA,sha256=Sl-lIhnLB9Pl9Fk1LY6xya3JNPu4zY4SI0D5dN1cpq4,4545
|
|
11
|
+
spothomelight-1.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
+
spothomelight-1.0.1.dist-info/entry_points.txt,sha256=f9haGAoi-aXDTCkoxuSkdN78sHbvfbrr9gwaOIewuvw,58
|
|
13
|
+
spothomelight-1.0.1.dist-info/top_level.txt,sha256=70ecLHIP1BNR5ZLYC-IfQ6ceydH0AZaDGIoH_wGrQZY,14
|
|
14
|
+
spothomelight-1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZGQ Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|