Getting a direct link to vkontakte video

Foreword


Hello. In this article I will share with you perhaps the only way to get a link to a video from a contact.
It all started when, during the development of my android client, I needed the function of playing and downloading videos. And for this, a link is naturally needed. And as you know, the maximum that we can get is a link to a page with a player, from where you can get a direct link.
Then I started googling on this topic, but I did not find anything sensible.
And then I decided to come up with my own way to get it.

What i came up with


The first thing I noticed was the VK Saver program. And in particular on their website. Everything happens there in this way:
1) You install the program, which later integrates into the browser.
2) Now, when you go to the page with the video, the s button appears below, which leads to a link of the form v.audiovkontakte.ru/video-xxxxx (xxxxxx is the id of this video.)
3) On this page, you can watch and download this video by clicking on a special button)

Having rummaged in the source code of this page I found something:

Here is this element: Pay attention to the line And here we notice the link 465.gt3.vkadre.ru/assets/videos/750c48ae2867-92359355.vk.flv By clicking on it, we will upload the video!

не дай Бог такое приснится!


flashvars="height=345&width=460&file=http://465.gt3.vkadre.ru/assets/videos/750c48ae2867-92359355.vk.flv&image=http://465.gt3.vkadre.ru/assets/thumbnails/750c48ae2867-92359355.320.vk.jpg&displayheight=345&searchbar=false"





In theory, this is what we need.
And an ordinary user can easily download the video without even having to go into the source code.
But for my purposes this was clearly not suitable.
Although at first glance everything was elementary: We get the id video, build a link to v.audiovkontakte.ru, and parse the source code with the help of the regular ones for the presence of the link we need.
But the first problem showed up when I tried to collect the link and follow it.
But for some reason I was immediately thrown onto the main page of the site.
It turns out that the transition is possible only by pressing the button.
So I had to put off this idea.
But I still have the format of the direct link to the video.
And everything seems to be fine, but the origin of one line remains unknown to us:
465.gt3.vkadre.ru/assets/videos 750c48ae2867 -92359355.vk.flv
Most likely this is some kind of hash or identifier for this record, and how to get it is unknown.

Having completely despaired, I decided to look at the player for the last time, the link to which we can get either by clicking on the button to share> Get the video code (
), or by sending a request to the API, which, I think, will be more relevant.

I was interested in the following block:



And if you check it for matches with the same hash, then it will be here: value = “uid = 0 & vid = 161693266 & oid = 13257647 & host = 465.gt3.vkadre.ru & vtag = 750c48ae2867 - <ag = 1423ac11 & vkid = 92359355 &

Excellent ! This tells us that we can still get a direct link!

Link Acquisition Algorithm



1) Using a request to the API we get the video id and a link to the player
2) Using the regulars we parse the code for the presence of the line with the vtag parameter and pull out the identifier
3) We build the direct link:
465.gt3.vkadre.ru/assets/videos/ identifier- id videozapisi.vk.format

Also popular now: