Skip to content

Commit

Permalink
Add vk and ok video support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 31, 2020
1 parent 8fb7130 commit e42b541
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion custom_components/yandex_station/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,23 @@ def play_video_by_descriptor(provider: str, item_id: str):
'music.yandex': re.compile(
r'https://music\.yandex\.ru/.*(artist|track|album)/(\d+)'),
'kinopoisk.id': re.compile(r'https?://www\.kinopoisk\.ru/film/(\d+)/'),
'yavideo': re.compile(
r'(https?://ok\.ru/video/\d+|https?://vk.com/video-?[0-9_]+)'),
'vk': re.compile(r'https://vk\.com/.*(video-?[0-9_]+)'),
}


async def get_media_payload(text: str, session):
for k, v in RE_MEDIA.items():
m = v.search(text)
if m:
if k in ('youtube', 'kinopoisk', 'strm'):
if k in ('youtube', 'kinopoisk', 'strm', 'yavideo'):
return play_video_by_descriptor(k, m[1])

elif k == 'vk':
url = 'https://vk.com/' + m[1]
return play_video_by_descriptor('yavideo', url)

elif k == 'music.yandex.playlist':
uid = await get_userid_v2(session, m[1])
if uid:
Expand Down

0 comments on commit e42b541

Please sign in to comment.