From 11283026c67d22240071e49c0c7a12ab5720506f Mon Sep 17 00:00:00 2001 From: Zak <60068872+Zakovskiy@users.noreply.github.com> Date: Sat, 4 Mar 2023 21:37:09 +0300 Subject: [PATCH 1/5] Creating and editing an audio in the web version. Added a function for uploading and editing audio in the web version of the site. --- vk_api/audio.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/vk_api/audio.py b/vk_api/audio.py index 0589755..7c620b0 100644 --- a/vk_api/audio.py +++ b/vk_api/audio.py @@ -16,6 +16,7 @@ from .audio_url_decoder import decode_audio_url from .exceptions import AccessDenied from .utils import set_cookies_from_list +from .upload import FilesOpener RE_ALBUM_ID = re.compile(r'act=audio_playlist(-?\d+)_(\d+)') RE_ACCESS_HASH = re.compile(r'access_hash=(\w+)') @@ -252,6 +253,90 @@ def search_user(self, owner_id=None, q=''): else: return [] + def edit_audio(self, audio_id: int, owner_id: int, hash: str, performer: str, title: str, text: str = "", genre: int = 1001): + """ Редактировать аудиозапись + + :param audio_id: ID аудиозаписи + :param owner_id: ID владельца (отрицательные значения для групп) + :param hash: хэш для редактирования аудиозаписи + :param performer: название аудиозаписи + :param title: заголовок аудиозаписи + :param test: текст аудиозаписи + """ + data = { + 'al': 1, + 'act': 'edit_audio', + 'aid': audio_id, + 'oid': owner_id, + 'force_edit_hash': '', + 'hash': hash, + 'performer': performer, + 'text': text, + 'title': title, + 'genre': genre + } + response = self._vk.http.post( + 'https://vk.com/al_audio.php', + data=data + ) + json_response = json.loads(response.text.replace('