Skip to content

Commit 2990bb7

Browse files
bakatroublepython273
authored andcommitted
Add method for retrieving audio directly by owner and id
1 parent b58931f commit 2990bb7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

vk_api/audio.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ def search_iter(self, q, offset=0):
212212

213213
offset += 50
214214

215+
def get_audio_by_id(self, owner_id, audio_id):
216+
response = self._vk.http.get(
217+
'https://m.vk.com/audio{}_{}'.format(owner_id, audio_id),
218+
allow_redirects=False
219+
)
220+
bs = BeautifulSoup(response.text, 'html.parser')
221+
link = bs.select_one('.ai_body input[type=hidden]').attrs['value']
222+
return decode_audio_url(link, self.user_id)
223+
215224

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

0 commit comments

Comments
 (0)