Skip to content

Commit

Permalink
Add support links to audiobooks #572
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Nov 23, 2024
1 parent a81fa9b commit 0a621ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ sequence:
- Альбом на Яндекс.Музыке - [пример](https://music.yandex.ru/album/2150009)
- Исполнитель на Яндекс.Музыке - [пример](https://music.yandex.ru/artist/41114)
- Плейлист на Яндекс.Музыке - [пример](https://music.yandex.ru/users/music.partners/playlists/2050)
- Аудиокнига на Яндекс.Музыке - [пример](https://music.yandex.ru/album/24151605)
- Аудиокнига на Яндекс.Книгах - [пример](https://books.yandex.ru/audiobooks/cZduXKir)

Только на устройствах с экраном (большая Станция или Модуль)

Expand Down
16 changes: 16 additions & 0 deletions custom_components/yandex_station/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def play_video_by_descriptor(provider: str, item_id: str):
r"(https?://ok\.ru/video/\d+|https?://vk.com/video-?[0-9_]+)"
),
"vk": re.compile(r"https://vk\.com/.*(video-?[0-9_]+)"),
"bookmate": re.compile(r"https://books\.yandex\.ru/audiobooks/(\w+)"),
}


Expand Down Expand Up @@ -224,6 +225,21 @@ async def get_media_payload(session, text: str) -> dict | None:
except:
return None

elif k == "bookmate":
try:
r = await session.post(
"https://api-gateway-rest.bookmate.yandex.net/audiobook/album",
json={"audiobook_uuid": m[1]},
)
resp = await r.json()
return {
"command": "playMusic",
"type": "album",
"id": resp["album_id"],
}
except:
return None

return None


Expand Down

0 comments on commit 0a621ac

Please sign in to comment.