@@ -30,19 +30,15 @@ def get(self, owner_id=None, album_id=None, offset=0):
3030 )
3131 elif owner_id is not None and album_id is not None :
3232 raise TypeError ('get() too many arguments' )
33- if album_id is not None and get_albums is True :
34- raise TypeError ('get() too many arguments' )
3533
36- id = owner_id
34+ user_id = owner_id
3735 url = 'https://m.vk.com/audios{}'
3836 if album_id is not None :
39- id = album_id
37+ user_id = album_id
4038 url = 'https://m.vk.com/audio?act=audio_playlist{}'
41- if get_albums is True :
42- url = 'https://m.vk.com/audio?act=audio_playlists{}'
4339
4440 response = self ._vk .http .get (
45- url .format (id ),
41+ url .format (user_id ),
4642 params = {
4743 'offset' : offset
4844 },
@@ -52,14 +48,36 @@ def get(self, owner_id=None, album_id=None, offset=0):
5248 if not response .text :
5349 raise AccessDenied (
5450 'You don\' t have permissions to browse {}\' s audio' .format (
55- id
51+ user_id
5652 )
5753 )
5854
59- if get_albums :
60- return scrap_albums (response .text )
6155 return scrap_data (response .text )
6256
57+ def get_albums (self , owner_id , offset = 0 ):
58+ """ Получить список альбомов пользователя
59+
60+ :param owner_id: ID владельца (отрицательные значения для групп)
61+ :param offset: смещение
62+ """
63+
64+ response = self ._vk .http .get (
65+ 'https://m.vk.com/audio?act=audio_playlists{}' .format (owner_id ),
66+ params = {
67+ 'offset' : offset
68+ },
69+ allow_redirects = False
70+ )
71+
72+ if not response .text :
73+ raise AccessDenied (
74+ 'You don\' t have permissions to browse {}\' s albums' .format (
75+ owner_id
76+ )
77+ )
78+
79+ return scrap_albums (response .text )
80+
6381 def search_user (self , owner_id , q = '' ):
6482 """ Искать по аудиозаписям пользователя
6583
0 commit comments