Search and download songs from VK easily with univk_audio
An easy-to-use library that allows you to search and download audio from VK, bypassing the restriction on obtaining a token to use the VK audio API.
Key features
- Doesn't require a VK Audio API token
- Login + password authorization
- Searching for songs without specific query rules
- Downloading songs
- Supports async
Requirements
Installation
pip install univk_audio
Getting started
Get authorization cookies
As class object:
# examples/auth_example.py
import asyncio
from univk_audio import AsyncVKAuth
# Example with class object, needs to close session manually
async def get_auth_cookies_example():
login: str = "79998887776"
password: str = "password"
# user_agent is optional:
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
auth = AsyncVKAuth(login = login, password = password, user_agent = user_agent)
# .get_auth_cookies Returns a string with cookies
# path is optional, if specified - saves cookies in file
cookies = await auth.get_auth_cookies(path = "cookies.txt")
await auth.close()
print(cookies)
asyncio.run(get_auth_cookies_example())
Async with:
# examples/auth_with_example.py
import asyncio
from univk_audio import AsyncVKAuth
# Example with 'async with' construction, that closes session automatically
async def get_auth_cookies_with_example():
login: str = "79998887776"
password: str = "password"
# user_agent is optional:
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
async with AsyncVKAuth(login = login, password = password, user_agent = user_agent) as auth:
# .get_auth_cookies Returns a string with cookies
# path is optional, if specified - saves cookies in file
cookies = await auth.get_auth_cookies(path = "cookies.txt")
print(cookies)
asyncio.run(get_auth_cookies_with_example())
Search for songs
As class object:
# examples/search_example.py
import asyncio
from univk_audio import AsyncVKMusic
# Example with class object, needs to close session manually
async def search_example():
cookies: str = "Your cookies from auth. See -> examples/auth_example.py"
# user_agent is optional:
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
music = AsyncVKMusic(cookies = cookies, user_agent = user_agent)
# .search Returns a Dict[str, str]
# {"*song-title*": "*download-link*"}
search_results = await music.search(query = "Imagine Dragons - Bones")
await music.close()
for title, download_link in search_results.items():
print(f"{title}\n{download_link}\n" + "-" * 15)
asyncio.run(search_example())
Async with:
# examples/search_with_example.py
import asyncio
from univk_audio import AsyncVKMusic
# Example with 'async with' construction, that closes session automatically
async def search_with_example():
cookies: str = "Your cookies from auth. See -> auth_example.py"
# user_agent is optional:
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
async with AsyncVKMusic(cookies = cookies, user_agent = user_agent) as music:
# .search Returns a Dict[str, str]
# {"*song-title*": "*download-link*"}
search_results = await music.search(query = "Imagine Dragons - Bones")
for title, download_link in search_results.items():
print(f"{title}\n{download_link}\n" + "-" * 15)
asyncio.run(search_with_example())
Search and download songs
General example of downloading songs from search results:
# examples/search_and_download_example.py
import asyncio
from univk_audio import AsyncVKMusic
# General example of downloading songs from search results
async def search_and_download_example():
cookies: str = "Your cookies from auth. See -> auth_example.py"
# user_agent is optional:
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
async with AsyncVKMusic(cookies = cookies, user_agent = user_agent) as music:
# Returns a Dict[str, str]
# {"*song-title*": "*download-link*"}
search_results = await music.search(query = "Imagine Dragons - Bones")
for title, download_link in search_results.items():
print("Downloading...\n" + f"{title}\n{download_link}")
is_downloaded = await music.download(link = download_link, path = f"songs/{title}.mp3")
if is_downloaded:
print(f"File saved as {title}.mp3\n" + "-" * 15)
asyncio.run(search_and_download_example())
License
univk_audio is offered under MIT License.
Free copying and use is allowed.
Source code
https://github.com/Exponefrv1/univk_audio
Author
Discord: autumnale
Telegram: @AnemoneSong
- I don't ask for donations or something.
- Any questions, suggestions and crit are welcome.
Metadata
Release files for univk-audio 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| univk_audio-1.0.3.tar.gz | 12.0 kB | Without provenance | Details for univk_audio-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| univk_audio-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for univk_audio-1.0.3-py3-none-any.whl |
Total release size: 25.3 kB
Release files / univk_audio-1.0.3.tar.gz
| Download URL | univk_audio-1.0.3.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0c806c6b4005aeee6b49292ee6e552121a5dd92b38c9eb2d67211292bce8745
|
|
BLAKE2b-256 checksum How to use checksums |
1c35a3b5cb99cdf7c19cfdaf8c10998120108834f750279f62cdd92de2e94a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / univk_audio-1.0.3-py3-none-any.whl
| Download URL | univk_audio-1.0.3-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
993459b108cd6a6d01c9ac2ac42fae859691304907fd5ef495798f3c6542b76b
|
|
BLAKE2b-256 checksum How to use checksums |
20b4f1404016ecb0a4c75c9c331f7f62afbe0c8564bf51b1acb2c1fbf6b615b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for univk-audio 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.