univk-audio


Nameunivk-audio JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/Exponefrv1/univk_audio
SummaryAn 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.
upload_time2023-08-10 18:37:53
maintainer
docs_urlNone
authorUnik
requires_python>=3.7
license
keywords vk audio music songs search download free univk vk_audio
VCS
bugtrack_url
requirements aiofiles aiohttp aiosignal anyio async-timeout attrs beautifulsoup4 bs4 certifi charset-normalizer colorama frozenlist h11 httpcore httpx idna iniconfig lxml multidict packaging pluggy pytest pytest-asyncio sniffio soupsieve yarl
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Logo](https://i.imgur.com/68Yy80c.png)
# 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
*   [aiofiles](https://pypi.org/project/aiofiles/)
*   [aiohttp](https://pypi.org/project/aiohttp/)
*   [beautifulsoup4](https://pypi.org/project/beautifulsoup4/)
*   [httpx](https://pypi.org/project/httpx/)
*   [lxml](https://pypi.org/project/lxml/)
 
## Installation
```
pip install univk_audio
```

## Getting started

### Get authorization cookies

#### As class object:

```python3
# 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:

```python3
# 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:

```python3
# 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:

```python3
# 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:

```python3
# 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](https://t.me/AnemoneSong)
*   I don't ask for donations or something.
*   Any questions, suggestions and crit are welcome.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Exponefrv1/univk_audio",
    "name": "univk-audio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "vk audio music songs search download free univk vk_audio",
    "author": "Unik",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/64/02/18f53460fe1ac1e1df0dac3121c57dc272630bee9635c008778458e04244/univk_audio-1.0.2.tar.gz",
    "platform": null,
    "description": "![Logo](https://i.imgur.com/68Yy80c.png)\r\n# Search and download songs from VK easily with univk_audio\r\nAn 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.\r\n\r\n## Key features\r\n\r\n*   Doesn't require a VK Audio API token\r\n*   Login + password authorization\r\n*   Searching for songs without specific query rules\r\n*   Downloading songs\r\n*   Supports async\r\n\r\n## Requirements\r\n*   [aiofiles](https://pypi.org/project/aiofiles/)\r\n*   [aiohttp](https://pypi.org/project/aiohttp/)\r\n*   [beautifulsoup4](https://pypi.org/project/beautifulsoup4/)\r\n*   [httpx](https://pypi.org/project/httpx/)\r\n*   [lxml](https://pypi.org/project/lxml/)\r\n \r\n## Installation\r\n```\r\npip install univk_audio\r\n```\r\n\r\n## Getting started\r\n\r\n### Get authorization cookies\r\n\r\n#### As class object:\r\n\r\n```python3\r\n# examples/auth_example.py\r\nimport asyncio\r\nfrom univk_audio import AsyncVKAuth\r\n\r\n# Example with class object, needs to close session manually\r\n\r\nasync def get_auth_cookies_example():\r\n    login: str = \"79998887776\"\r\n    password: str = \"password\"\r\n\r\n    # user_agent is optional:\r\n    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\"\r\n\r\n    auth = AsyncVKAuth(login = login, password = password, user_agent = user_agent)\r\n\r\n    # .get_auth_cookies Returns a string with cookies\r\n    # path is optional, if specified - saves cookies in file\r\n\r\n    cookies = await auth.get_auth_cookies(path = \"cookies.txt\")\r\n    await auth.close()\r\n\r\n    print(cookies)\r\n\r\nasyncio.run(get_auth_cookies_example())\r\n```\r\n\r\n#### Async with:\r\n\r\n```python3\r\n# examples/auth_with_example.py\r\nimport asyncio\r\nfrom univk_audio import AsyncVKAuth\r\n\r\n# Example with 'async with' construction, that closes session automatically\r\n\r\nasync def get_auth_cookies_with_example():\r\n    login: str = \"79998887776\"\r\n    password: str = \"password\"\r\n\r\n    # user_agent is optional:\r\n    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\"\r\n\r\n    async with AsyncVKAuth(login = login, password = password, user_agent = user_agent) as auth:\r\n\r\n        # .get_auth_cookies Returns a string with cookies\r\n        # path is optional, if specified - saves cookies in file\r\n\r\n        cookies = await auth.get_auth_cookies(path = \"cookies.txt\") \r\n\r\n        print(cookies)\r\n\r\nasyncio.run(get_auth_cookies_with_example())\r\n```\r\n\r\n### Search for songs\r\n\r\n#### As class object:\r\n\r\n```python3\r\n# examples/search_example.py\r\nimport asyncio\r\nfrom univk_audio import AsyncVKMusic\r\n\r\n# Example with class object, needs to close session manually\r\n\r\nasync def search_example():\r\n    cookies: str = \"Your cookies from auth. See -> examples/auth_example.py\"\r\n\r\n    # user_agent is optional:\r\n    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\"\r\n\r\n    music = AsyncVKMusic(cookies = cookies, user_agent = user_agent)\r\n\r\n    # .search Returns a Dict[str, str]\r\n    # {\"*song-title*\": \"*download-link*\"}\r\n\r\n    search_results = await music.search(query = \"Imagine Dragons - Bones\")\r\n    await music.close()\r\n\r\n    for title, download_link in search_results.items():\r\n        print(f\"{title}\\n{download_link}\\n\" + \"-\" * 15)\r\n\r\nasyncio.run(search_example())\r\n```\r\n\r\n#### Async with:\r\n\r\n```python3\r\n# examples/search_with_example.py\r\nimport asyncio\r\nfrom univk_audio import AsyncVKMusic\r\n\r\n# Example with 'async with' construction, that closes session automatically\r\n\r\nasync def search_with_example():\r\n    cookies: str = \"Your cookies from auth. See -> auth_example.py\"\r\n\r\n    # user_agent is optional:\r\n    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\"\r\n\r\n    async with AsyncVKMusic(cookies = cookies, user_agent = user_agent) as music:\r\n\r\n        # .search Returns a Dict[str, str]\r\n        # {\"*song-title*\": \"*download-link*\"}\r\n\r\n        search_results = await music.search(query = \"Imagine Dragons - Bones\")\r\n        for title, download_link in search_results.items():\r\n            print(f\"{title}\\n{download_link}\\n\" + \"-\" * 15)\r\n\r\nasyncio.run(search_with_example())\r\n```\r\n\r\n### Search and download songs\r\n\r\n#### General example of downloading songs from search results:\r\n\r\n```python3\r\n# examples/search_and_download_example.py\r\nimport asyncio\r\nfrom univk_audio import AsyncVKMusic\r\n\r\n# General example of downloading songs from search results\r\n\r\nasync def search_and_download_example():\r\n    cookies: str = \"Your cookies from auth. See -> auth_example.py\"\r\n\r\n    # user_agent is optional:\r\n    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\"\r\n\r\n    async with AsyncVKMusic(cookies = cookies, user_agent = user_agent) as music:\r\n\r\n        # Returns a Dict[str, str]\r\n        # {\"*song-title*\": \"*download-link*\"}\r\n\r\n        search_results = await music.search(query = \"Imagine Dragons - Bones\")\r\n\r\n        for title, download_link in search_results.items():\r\n            print(\"Downloading...\\n\" + f\"{title}\\n{download_link}\")\r\n\r\n            is_downloaded = await music.download(link = download_link, path = f\"songs/{title}.mp3\")\r\n\r\n            if is_downloaded:\r\n                print(f\"File saved as {title}.mp3\\n\" + \"-\" * 15)\r\n\r\nasyncio.run(search_and_download_example())\r\n```\r\n\r\n## License\r\n```univk_audio``` is offered under MIT License.\r\nFree copying and use is allowed.\r\n\r\n## Source code\r\nhttps://github.com/Exponefrv1/univk_audio\r\n\r\n## Author\r\nDiscord: autumnale  \r\nTelegram: [@AnemoneSong](https://t.me/AnemoneSong)\r\n*   I don't ask for donations or something.\r\n*   Any questions, suggestions and crit are welcome.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "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.",
    "version": "1.0.2",
    "project_urls": {
        "Author": "https://t.me/AnemoneSong",
        "Homepage": "https://github.com/Exponefrv1/univk_audio",
        "Issues": "https://github.com/Exponefrv1/univk_audio/issues"
    },
    "split_keywords": [
        "vk",
        "audio",
        "music",
        "songs",
        "search",
        "download",
        "free",
        "univk",
        "vk_audio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc5a03720c97ab5896fe0c13320e59680d8bcaca1b6716b25a83fab39aba3314",
                "md5": "b1dd3a7f3058dcf8f45469bf3c76e588",
                "sha256": "69510e58df25c239a8c42956e930825352a69e1996b36a62840ed67f3f894097"
            },
            "downloads": -1,
            "filename": "univk_audio-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b1dd3a7f3058dcf8f45469bf3c76e588",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 12502,
            "upload_time": "2023-08-10T18:37:51",
            "upload_time_iso_8601": "2023-08-10T18:37:51.853406Z",
            "url": "https://files.pythonhosted.org/packages/dc/5a/03720c97ab5896fe0c13320e59680d8bcaca1b6716b25a83fab39aba3314/univk_audio-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "640218f53460fe1ac1e1df0dac3121c57dc272630bee9635c008778458e04244",
                "md5": "410896c3ebde77b44def0633cc7ec219",
                "sha256": "5461ef25df1e5bd8a8bf01fff02b34c7eaa36930a03fdd955b79fcc1c735fe92"
            },
            "downloads": -1,
            "filename": "univk_audio-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "410896c3ebde77b44def0633cc7ec219",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11081,
            "upload_time": "2023-08-10T18:37:53",
            "upload_time_iso_8601": "2023-08-10T18:37:53.313732Z",
            "url": "https://files.pythonhosted.org/packages/64/02/18f53460fe1ac1e1df0dac3121c57dc272630bee9635c008778458e04244/univk_audio-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-10 18:37:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Exponefrv1",
    "github_project": "univk_audio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "aiofiles",
            "specs": [
                [
                    "==",
                    "23.2.1"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    "==",
                    "3.8.5"
                ]
            ]
        },
        {
            "name": "aiosignal",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "anyio",
            "specs": [
                [
                    "==",
                    "3.7.1"
                ]
            ]
        },
        {
            "name": "async-timeout",
            "specs": [
                [
                    "==",
                    "4.0.2"
                ]
            ]
        },
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "23.1.0"
                ]
            ]
        },
        {
            "name": "beautifulsoup4",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        },
        {
            "name": "bs4",
            "specs": [
                [
                    "==",
                    "0.0.1"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2023.7.22"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "colorama",
            "specs": [
                [
                    "==",
                    "0.4.6"
                ]
            ]
        },
        {
            "name": "frozenlist",
            "specs": [
                [
                    "==",
                    "1.4.0"
                ]
            ]
        },
        {
            "name": "h11",
            "specs": [
                [
                    "==",
                    "0.14.0"
                ]
            ]
        },
        {
            "name": "httpcore",
            "specs": [
                [
                    "==",
                    "0.17.3"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "==",
                    "0.24.1"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.4"
                ]
            ]
        },
        {
            "name": "iniconfig",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "lxml",
            "specs": [
                [
                    "==",
                    "4.9.3"
                ]
            ]
        },
        {
            "name": "multidict",
            "specs": [
                [
                    "==",
                    "6.0.4"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "23.1"
                ]
            ]
        },
        {
            "name": "pluggy",
            "specs": [
                [
                    "==",
                    "1.2.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "7.4.0"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    "==",
                    "0.21.1"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "soupsieve",
            "specs": [
                [
                    "==",
                    "2.4.1"
                ]
            ]
        },
        {
            "name": "yarl",
            "specs": [
                [
                    "==",
                    "1.9.2"
                ]
            ]
        }
    ],
    "lcname": "univk-audio"
}
        
Elapsed time: 0.10014s