-
Notifications
You must be signed in to change notification settings - Fork 325
Add support for downloading Music Albums #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
vk_api/audio.py
Outdated
| """ | ||
|
|
||
| if owner_id is None and album_id is None: | ||
| raise TypeError("get() missing 1 required argument: 'album_id' or 'owner_id'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Наверное слишком длинно, нужно чтобы короче 80 символов. И поменять на одинарные кавычки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
хм, а где брать id альбомов? |
|
ID альбома из 2х частей состоит: Пример альбома: -56703560_85005375 |
|
Сами альбомы можно или руками в профиле создавать, или в сообществах искать. Сейчас исполнители очень активно фишку использовать начали |
|
Наверное тогда стоит добавить загрузку списка альбомов пользователя/группы, иначе как-то не много смысла |
|
Логично, сейчас запилим 😃 |
|
Парсер альбомов сообщества / пользователя готов. Поиск работать отказался. Запрос: act=audio_playlists-28905875&q=kizaru. В вебе отлично ищет, через |
|
Нужно отдельным методом сделать, все засовывать в одну функцию - не очень |
|
ну там только урлы меняются, не хотелось копипастить. самого напрягло ) может, вынести в метод с параметрами просто? |
|
Просто вынеси в отдельный метод получение альбомов. То что код повторяться будет в методах - это окей |
|
Разделил поиск альбомов и поиск треков в разные методы. Поиск треков у пользователя и поиск треков в альбоме решил оставить в общем методе, ибо это одно и то же по сути |
vk_api/audio.py
Outdated
| if not response.text: | ||
| raise AccessDenied( | ||
| 'You don\'t have permissions to browse {}\'s audio'.format( | ||
| id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id shadowed built-in name id
| """ Получить список аудиозаписей пользователя | ||
| :param owner_id: ID владельца (отрицательные значения для групп) | ||
| :param album_id: ID альбома (отрицательные значения для групп) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ID альбомов тоже отрицательные?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, я писал же выше
vk_api/audio.py
Outdated
| url = 'https://m.vk.com/audios{}' | ||
| if album_id is not None: | ||
| user_id = album_id | ||
| url = 'https://m.vk.com/audio?act=audio_playlist{}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можешь вместо этого сделать
if album_id is not None:
url = 'https://m.vk.com/audio?act=audio_playlist{}'.format(album_id)
else:
url = 'https://m.vk.com/audios{}'.format(owner_id)
и убрать .format(user_id) ниже из запроса. Из AccessDenied можно убрать user_id тоже
|
Еще пример нужно пофиксить. Думаю еще можно проще сделать - типа получение списка альбомов пользователя и получение списка аудио первого альбома |
|
сделано, сэр |
examples/get_album_audio.py
Outdated
| break | ||
|
|
||
| for album in temp_albums: | ||
| albums.append(album) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
albums += temp_albums
|
|
||
| offset += len(temp_albums) | ||
|
|
||
| print('\nLast 5:') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
последние 5 альбомов пользователя
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
там ниже [:5], значит первые?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну по сути то они первые, ибо отображаются альбомы сверху-вниз. от последнего к первому.
examples/get_album_audio.py
Outdated
|
|
||
| # Ищем треки последнего альбома | ||
| print('\nSearch for', albums[0]['title']) | ||
| tracks = vkaudio.get(album_id=albums[0]['id'][25:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[25:]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ой я идиот, это надо было в audio.py вынести. там у айдишника в начале мусор на 25 символов (что-то вроде audioplaylistblablabla)
|
надо научится спать по ночам, с головой проблемы уже |
examples/get_album_audio.py
Outdated
|
|
||
|
|
||
| def main(): | ||
| """ Пример составления топа исполнителей для альбома вк """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо бы обновить под новый смысл примера
|
Merge it 😄 |
|
Не было времени затестить, вроде все норм 👍 |
|
если что-то и не работает - будет второй ПР, я на базе этой фичи сейчас качалку делаю ) |
Добавил поддержку загрузки альбомов, для них введён отдельный аргумент (как в старой версии API):
album_idЗагрузка по профилю (
owner_id) остаётся на месте и всё так же чудесно работаетПрикрепляю example для теста