Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
/ vk-music-rb Public archive

Ruby library to work with popular Russian network audios. VK stands for Very Kool btw

License

Notifications You must be signed in to change notification settings

fizvlad/vk-music-rb

Repository files navigation

Gem GitHub Workflow Status Lines of code Gem

VkMusic

vk_music gem is a library to work with audios on popular Russian social network

Installation

Add this line to your application's Gemfile:

gem 'vk_music'

And then execute:

$ bundle

Or install it using gem:

$ gem install vk_music

Usage

You can take a look on documentation at rubydoc.

Logging in

Firstly, it is required to create new VkMusic::Client instance and provide login credentials:

client = VkMusic::Client.new(username: "+79991234567", password: "password")

Search

You can search audios using Client#find:

audios = client.find("Acid Spit - Mega Drive")

You can also search for playlists using same method:

playlists = client.find("Jazz", type: :playlist)

Playlists

You can load playlist audios with Client#playlist

playlist = client.playlist(url: "link")

User or group audios

You can load profile audios with Client#audios

playlist = client.audios(owner_id: 8024985)

Wall audios

You can load audios from profile wall with Client#wall

playlist = client.wall(owner_id: 8024985)

Audios from post

You can load up to 10 audios attached to some post. Those audios will be returned as array:

audios = client.post(url: "link")

Artist audios

You can get up to 50 top audios of particular artist:

audios = client.artist(url: "link")

Getting audio URL

To get audio URL you should go through following chain:

  1. Get audio ID
  2. Get audio encrypted URL
  3. Get audio decrypted URL

Usually most of audios already go with ID. Getting encrypted URL requires additional request to web, so it is performed with Client#update_urls, which will mutate provided array of audios:

client.update_urls(audios_array)

After this you can get decrypted URL using Audio#url

Development

Feel free to add features. However, please make sure all your code is covered with tests.

Testing

This gem uses rspec and vcr for easy testing. Be careful, though, running rspec in clean repo may result in lot of requests to web and rate limiting or ban

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fizvlad/vk-music-rb/issues.

License

The gem is available as open source under the terms of the MIT License.