電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>用Rust編寫的Homebridge Spotify插件

用Rust編寫的Homebridge Spotify插件

2022-04-21 | zip | 0.01 MB | 次下載 | 免費(fèi)

資料介紹

授權(quán)協(xié)議 MIT License
開發(fā)語言 JavaScript
軟件類型 開源軟件
所屬分類 其他開源、 物聯(lián)網(wǎng)

軟件簡介

homebridge-rusty-spotify

Spotify plugin for Homebridge written in Rust. The plugin requires a Spotify Premium account.

Installation and Setup

  1. Install Homebridge: sudo npm install -g homebridge
  2. Install the plugin: sudo npm install -g homebridge-rusty-spotify
  3. Register the plugin as app in the Spotify Developer Dashboard
    1. Login
    2. Select "Create a client ID"
    3. Provide a name and description in the pop-up; click "Next"
    4. Copy the "Client ID" and "Client Secret" which will be required in the following configuration step
    5. Click "Edit Settings"
    6. Add http://localhost/callback as "Redirect URI" and save
  4. Configure the plugin using the generated client ID and client secret (see Configuration)

Configuration

The generate_config script can be used to generate the config. It requires for the client_id, client_secret and Spotify username needs to be set since those are required to authenticate to the Spotify Web API. To run the script, make sure to have Python 3 and the spotipy library installed.

Running the script will open a web browser asking to authenticate to Spotify which is required to retrieve the refresh_token.

$ ./generate_config --help
usage: generate_config [-h] [--client_id CLIENT_ID]
                       [--client_secret CLIENT_SECRET]
                       [--redirect_uri REDIRECT_URI] [--username USERNAME]

Script to retrieve an access and refresh token for using the Spotify API

optional arguments:
  -h, --help            show this help message and exit
  --client_id CLIENT_ID, --client-id CLIENT_ID
                        Spotify client ID
  --client_secret CLIENT_SECRET, --client-secret CLIENT_SECRET
                        Spotify client secret
  --redirect_uri REDIRECT_URI, --redirect-uri REDIRECT_URI
                        Redirect URI
  --username USERNAME   Spotify username


$ ./generate_config --client_id=<client_id> --client_secret=<client_secret> --username=<username>
  {
    "platform": "Spotify",
    "name": "Spotify",
    "service_type": "light",    // "light" or "speaker"; Speaker is not supported by HomeKit
    "client_id": "",
    "client_secret": "",
    "refresh_token": ""
  }

The generated config needs to copied to the Homebridge config file (e.g. ~/.homebridge/config.json). For example:

//...
"platforms": [
  {
    "platform": "Spotify",
    "name": "Spotify",
    "service_type": "light",    // "light" or "speaker"; Speaker is not supported by HomeKit
    "client_id": "",
    "client_secret": "",
    "refresh_token": "",
  }
]
//...

service_type specifies whether Spotify devices should use the Lightbulb or Speaker service. If service_type is not specified, "light" will be used by default. HomeKit currently does not support Speaker services and will show "This accessory is not certified and may not work reliably with HomeKit".

Usage

Add the plugin in the Home app. The plugin will automatically discover available Spotify devices and add them as accessories. Turning a Spotify accessory on will resume playing music on the device, turning off the accessory will pause the music. The accessory also allows to change the playback volume.

Accessories get refreshed every 10 seconds (or as specified in the configuration file).

Development

  1. Install the Rust toolchain, wasm-pack, cargo-generate and npm by following this guide
  2. Clone the repository
  3. Run make
    • This will create a pkg/ directory containing all the generated nodejs files
  4. Copy the generated files to a device/directory that can be discovered by Homebridge
  5. Switch to the directory and run npm install to install all required dependencies
  6. Run Homebridge in debug mode and specify the directory with the plugin files: DEBUG=* homebridge -D -P /path/to/plugin/homebridge-rusty-spotify

A blog post about writing plugins for Homebridge and specifically this plugin has been published here.

?

評論

查看更多

下載排行

本周

  1. 1UHV系列雷電沖擊電壓發(fā)生器試驗裝置詳細(xì)說明使用
  2. 1.07 MB   |  16次下載  |  免費(fèi)
  3. 2介紹一些常用的電子元器件
  4. 3.20 MB   |  4次下載  |  免費(fèi)
  5. 3RS-485收發(fā)器CMT83086的高可靠性全雙工隔離特性及其應(yīng)用
  6. 888.28 KB  |  2次下載  |  免費(fèi)
  7. 4PNE20080EPE超快恢復(fù)整流器規(guī)格書
  8. 275.29KB   |  1次下載  |  免費(fèi)
  9. 5半導(dǎo)體存儲電路講課資料
  10. 17.38 MB   |  1次下載  |  免費(fèi)
  11. 6RS-485高可靠性隔離半雙工收發(fā)器CMT83085/CMT83087的技術(shù)規(guī)范及應(yīng)用場景
  12. 0.99 MB  |  1次下載  |  免費(fèi)
  13. 7適用于3級電動汽車充電站的雙向雙有源電橋參考設(shè)計
  14. 6.26 MB   |  1次下載  |  免費(fèi)
  15. 8STM32系列產(chǎn)品選型-中文
  16. 1.81 MB  |  1次下載  |  免費(fèi)

本月

  1. 1DeepSeek:從入門到精通
  2. 5.36 MB   |  75次下載  |  1 積分
  3. 2OAH0428最新規(guī)格書(中文)
  4. 2.52 MB   |  27次下載  |  10 積分
  5. 3UHV系列雷電沖擊電壓發(fā)生器試驗裝置詳細(xì)說明使用
  6. 1.07 MB   |  16次下載  |  免費(fèi)
  7. 4麻將機(jī)升降電路
  8. 0.12 MB   |  5次下載  |  1 積分
  9. 5中興通訊的PCB設(shè)計規(guī)范
  10. 23.03 MB   |  5次下載  |  5 積分
  11. 6Altium-常用3D封裝庫(Step)接插件篇
  12. 4.95 MB   |  5次下載  |  免費(fèi)
  13. 7PNE20040CPE-Q雙共陰極超快恢復(fù)整流器規(guī)格書
  14. 275.16KB   |  4次下載  |  免費(fèi)
  15. 8介紹一些常用的電子元器件
  16. 3.20 MB   |  4次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935124次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關(guān)降壓/升壓雙向直流/直流轉(zhuǎn)換器 PCB layout 設(shè)計
  4. 1.48MB  |  420063次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233088次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費(fèi)下載
  8. 340992  |  191370次下載  |  10 積分
  9. 5十天學(xué)會AVR單片機(jī)與C語言視頻教程 下載
  10. 158M  |  183336次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81583次下載  |  10 積分
  13. 7Keil工具M(jìn)DK-Arm免費(fèi)下載
  14. 0.02 MB  |  73814次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65988次下載  |  10 積分