Package: univk-audio
Search and download songs from VK easily with univk_audioAn 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 featuresDoesn't require a VK Audio API tokenLogin + password authorizationSearching for songs without specific query rulesDownloading songsSupports asyncRequirementsaiofilesaiohttpbeautifulsoup4httpxlxmlInstallationpip install univk_audioGetting startedGet authorization cookiesAs class object:# examples/auth_example.pyimportasynciofromunivk_audioimportAsyncVKAuth# Example with class object, needs to close session manuallyasyncdefget_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 filecookies=awaitauth.get_auth_cookies(path="cookies.txt")awaitauth.close()print(cookies)asyncio.run(get_auth_cookies_example())Async with:# examples/auth_with_example.pyimportasynciofromunivk_audioimportAsyncVKAuth# Example with 'async with' construction, that closes session automaticallyasyncdefget_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"asyncwithAsyncVKAuth(login=login,password=password,user_agent=user_agent)asauth:# .get_auth_cookies Returns a string with cookies# path is optional, if specified - saves cookies in filecookies=awaitauth.get_auth_cookies(path="cookies.txt")print(cookies)asyncio.run(get_auth_cookies_with_example())Search for songsAs class object:# examples/search_example.pyimportasynciofromunivk_audioimportAsyncVKMusic# Example with class object, needs to close session manuallyasyncdefsearch_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=awaitmusic.search(query="Imagine Dragons - Bones")awaitmusic.close()fortitle,download_linkinsearch_results.items():print(f"{title}\n{download_link}\n"+"-"*15)asyncio.run(search_example())Async with:# examples/search_with_example.pyimportasynciofromunivk_audioimportAsyncVKMusic# Example with 'async with' construction, that closes session automaticallyasyncdefsearch_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"asyncwithAsyncVKMusic(cookies=cookies,user_agent=user_agent)asmusic:# .search Returns a Dict[str, str]# {"*song-title*": "*download-link*"}search_results=awaitmusic.search(query="Imagine Dragons - Bones")fortitle,download_linkinsearch_results.items():print(f"{title}\n{download_link}\n"+"-"*15)asyncio.run(search_with_example())Search and download songsGeneral example of downloading songs from search results:# examples/search_and_download_example.pyimportasynciofromunivk_audioimportAsyncVKMusic# General example of downloading songs from search resultsasyncdefsearch_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"asyncwithAsyncVKMusic(cookies=cookies,user_agent=user_agent)asmusic:# Returns a Dict[str, str]# {"*song-title*": "*download-link*"}search_results=awaitmusic.search(query="Imagine Dragons - Bones")fortitle,download_linkinsearch_results.items():print("Downloading...\n"+f"{title}\n{download_link}")is_downloaded=awaitmusic.download(link=download_link,path=f"songs/{title}.mp3")ifis_downloaded:print(f"File saved as{title}.mp3\n"+"-"*15)asyncio.run(search_and_download_example())Licenseunivk_audiois offered under MIT License.
Free copying and use is allowed.Source codehttps://github.com/Exponefrv1/univk_audioAuthorDiscord: autumnaleTelegram:@AnemoneSongI don't ask for donations or something.Any questions, suggestions and crit are welcome.