How to download music from vk.com with python



Being a user on vk.com, I have music saved on my profile. Although I can directly listen to my songs, the social network does not offer any kind of way through which one can download the music on their local machine.


As a fan of slavic rap, I had to find a way to download music from vk.com. Although there are easier ways, through browser extensions and online platforms, I chose to put my coding skills in practice.



Fortunately for me, a good python project already exists on github; it's under the name of VK-Songs. It's main purpose is to offer the python user a direct way to download music from vk.com.


Download music from vk.com on Windows


First of all, download the project from github. I prefer to directly download it as a zip archive, although the git option is available.


Once you have managed to extract the archive, launch a fresh cmd shell, and  navigate to the root of the project VK-Songs with the help of the cd command.


cd C:\Users\User\Desktop\VK-Songs-master\VK-Songs-master



Then create a fresh virtual environment with the help of one of the following python versions.

python3.5

python3.6

python3.7


Personally I am running the project on python3.7


python -m venv env



After having created and activated the virtual environment, install the whole package dependencies with the help of the command shown below.


pip install colorama requests vk_api bs4 pyinquirer pyfiglet pathvalidate eyed3


On success, you should be able to launch the app with the command shown below.


python vk_songs\app.py


The app will prompt for the username and password. Make sure to correctly provide such credentials so you can authenticate to vk.com.


On successful authentication, the following menu will appear.



With the help of the arrow keys, you can easily get your audios as a list, albums and even do a global search through a specific query string.


For example, to get the the user's community's audios, just hit the Return key and then provide the specific id, which can be found at the end of the user's profile url.




On success, a whole list of music will be displayed on the console.




It's possible to select an audio for download, or multiple ones. The app is self explanatory. Just select them with the help of the Space button.




Download music from vk.com on OS X


As for the OS X, the application fails to offer an interactive interface. The process of music downloading should be done manually through different pieces of python code.

 

Once you have managed to download the source code from github, launch a fresh console and navigate to the root of the project.

 

Then create a fresh virtual environment and install the whole package dependencies with the help of the pip utility.


pip install colorama requests vk_api bs4 pyinquirer pyfiglet pathvalidate eyed3


Once you have successfully installed the dependencies, launch a fresh python shell while being at the root of the project and do the following import.



from app import VkSongs


Create a fresh object.

vk_obj = VkSongs()

Authenticate to the vk.com with the help of the following piece of python code.


vk_obj.login(login_user='your_username', login_pass='your_pass')


Get the list of your music with the help of the following command.


songs  = vk_obj.get()


Identify your song with the title.


for song in songs:print(song.title)


Once you have identified it, pass the object app.VkSong to the method download.


vk_obj.download(song=songs[0])


On success you should get a boolean value of True.

 

Download music from vk.com on Ubuntu

 

 

Being a python based project, the process for downloading music from vk.com on Ubuntu is the same as the one we illustrated for OS X. 







Final thoughts

Through this article you learned how to download music from vk.com with the help of python.


Feel free to follow my work on Instagram.

© 2020 Copyright by orthodoxpirate.blogspot.com
All Rights Reserved

2 comments:

  1. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. python mobile app development

    ReplyDelete

Powered by Blogger.