Skip to content

Commit

Permalink
Получение аудиозаписей из поста пользователя или сообщества (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertyadrian authored and python273 committed Jan 4, 2020
1 parent e4de7ad commit 7005df7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions vk_api/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def __init__(self, vk):
self.user_id = vk.method('users.get')[0]['id']
self._vk = vk

self._vk.http.cookies.update({
'remixmdevice': '1920/1080/1/!!-!!!!'
})

def get_iter(self, owner_id=None, album_id=None, access_hash=None):
""" Получить список аудиозаписей пользователя (по частям)
Expand Down Expand Up @@ -221,6 +225,24 @@ def get_audio_by_id(self, owner_id, audio_id):
link = bs.select_one('.ai_body input[type=hidden]').attrs['value']
return decode_audio_url(link, self.user_id)

def get_post_audio(self, owner_id, post_id):
""" Получить список аудиозаписей из поста пользователя или группы
:param owner_id: ID владельца (отрицательные значения для групп)
:param post_id: ID поста
"""
response = self._vk.http.get(
'https://m.vk.com/wall{}_{}'.format(owner_id, post_id)
)

tracks = scrap_data(
response.text,
self.user_id,
filter_root_el={'class': 'audios_list'}
)

return tracks


def scrap_data(html, user_id, filter_root_el=None, convert_m3u8_links=True):
""" Парсинг списка аудиозаписей из html страницы """
Expand Down

0 comments on commit 7005df7

Please sign in to comment.