Compare commits
2 Commits
65a2288bea
...
ddf120566f
Author | SHA1 | Date |
---|---|---|
catsimple | ddf120566f | |
catsimple | 4d3626bbfd |
|
@ -37,6 +37,9 @@ https://github.com/Binaryify/NeteaseCloudMusicApi
|
|||
- 播放网易云音乐歌手 `cloudmusic://163/artist/playlist?id=2116`
|
||||
- 播放喜马拉雅专辑 `cloudmusic://xmly/playlist?id=258244`
|
||||
|
||||
> **指定URL播放**
|
||||
- [x] `cloudmusic://play/url?url=流媒体链接&song=歌曲名&singer=歌手&picurl=缩略图链接`
|
||||
|
||||
> **搜索播放**
|
||||
|
||||
- [x] 音乐搜索播放 `cloudmusic://play/song?kv=关键词`
|
||||
|
@ -62,4 +65,4 @@ https://github.com/Binaryify/NeteaseCloudMusicApi
|
|||
<img src="https://ha.jiluxinqing.com/img/alipay.png" align="left" height="160" width="160" alt="支付宝" title="支付宝"> | <img src="https://ha.jiluxinqing.com/img/wechat.png" align="left" height="160" width="160" alt="微信支付" title="微信">
|
||||
|
||||
#### 关注我的微信订阅号,了解更多HomeAssistant相关知识
|
||||
<img src="https://ha.jiluxinqing.com/img/wechat-channel.png" height="160" alt="HomeAssistant家庭助理" title="HomeAssistant家庭助理">
|
||||
<img src="https://ha.jiluxinqing.com/img/wechat-channel.png" height="160" alt="HomeAssistant家庭助理" title="HomeAssistant家庭助理">
|
||||
|
|
|
@ -5,6 +5,7 @@ from urllib.parse import urlparse, parse_qs, parse_qsl, quote
|
|||
from homeassistant.util.json import save_json
|
||||
from custom_components.ha_cloud_music.http_api import http_get
|
||||
from .utils import parse_query
|
||||
from .models.music_info import MusicInfo, MusicSource
|
||||
|
||||
from homeassistant.components import media_source
|
||||
from homeassistant.components.media_player import (
|
||||
|
@ -115,7 +116,7 @@ class CloudMusicRouter():
|
|||
play_radio = f'{play_protocol}radio'
|
||||
play_xmly = f'{play_protocol}xmly'
|
||||
play_fm = f'{play_protocol}fm'
|
||||
|
||||
play_url = f'{play_protocol}url'
|
||||
|
||||
|
||||
async def async_browse_media(media_player, media_content_type, media_content_id):
|
||||
|
@ -185,8 +186,8 @@ async def async_browse_media(media_player, media_content_type, media_content_id)
|
|||
#'thumbnail': 'http://p1.music.126.net/9M-U5gX1gccbuBXZ6JnTUg==/109951165264087991.jpg'
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 扩展资源
|
||||
children.extend([
|
||||
|
@ -697,7 +698,7 @@ async def async_browse_media(media_player, media_content_type, media_content_id)
|
|||
return library_info
|
||||
|
||||
if media_content_id.startswith(CloudMusicRouter.fm_playlist):
|
||||
|
||||
|
||||
library_info = BrowseMedia(
|
||||
media_class=MEDIA_CLASS_DIRECTORY,
|
||||
media_content_id=media_content_id,
|
||||
|
@ -724,7 +725,7 @@ async def async_browse_media(media_player, media_content_type, media_content_id)
|
|||
|
||||
#================= 喜马拉雅
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
''' ================== 播放音乐 ================== '''
|
||||
|
@ -795,7 +796,24 @@ async def async_play_media(media_player, cloud_music, media_content_id):
|
|||
playlist = await cloud_music.async_play_radio(keywords)
|
||||
elif media_content_id.startswith(CloudMusicRouter.play_singer):
|
||||
playlist = await cloud_music.async_play_singer(keywords)
|
||||
|
||||
|
||||
##播放指定URL
|
||||
elif media_content_id.startswith(CloudMusicRouter.play_url):
|
||||
id = '1'
|
||||
url = urlparse(media_content_id)
|
||||
query = parse_query(url.query)
|
||||
song = query.get('song')
|
||||
singer = query.get('singer')
|
||||
album = song
|
||||
duration = '1000000000'
|
||||
url = query.get('url')
|
||||
picUrl = query.get('picurl') # 提取缩略图URL
|
||||
|
||||
|
||||
if url is not None:
|
||||
media_player.playlist = [ MusicInfo(id, song, singer, album, duration, url, picUrl, MusicSource.URL.value) ]
|
||||
media_player.playindex = 0
|
||||
return 'playlist'
|
||||
|
||||
if playlist is not None:
|
||||
media_player.playindex = playindex
|
||||
|
|
Loading…
Reference in New Issue