📜 ⬆️ ⬇️

Getting a direct link to vkontakte video

Foreword


Hello. In this article I will share with you perhaps the only way to get the link to the video from the contact.
It all started when I needed to play and download video in the process of developing my android client. And for this, the link is naturally necessary. And as you know, the maximum that we can get is a link to a page with a player, from where you'll get a direct link to horseradish
Then I started to google on this topic, but found nothing sensible.
And then I decided to think of my way of getting it.

What did i come up with


First of all, I drew attention to the program VK Saver. And in particular on their website. Everything happens in this way:
1) You install a program that later integrates into the browser.
2) Now, when you enter the video page, a button s appears below you, which leads to a link like 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 the special button)

Having rummaged in the source code of this page I found something:
')
Here is this element:

 <form action="/download.php?type=vks&host=465.gt3.vkadre.ru&no_flv=0&vtag=750c48ae2867-&vkid=92359355&uid=0&hd=0&plugin_hash=202cb962ac59075b964b07152d234b70&plugin_ver=3.1.110425.1262&vvideo_id=161693266&artist_name=&clip_name=%25ED%25E5%2B%25E4%25E0%25E9%2B%25C1%25EE%25E3%2B%25F2%25E0%25EA%25EE%25E5%2B%25EF%25F0%25E8%25F1%25ED%25E8%25F2%25F1%25FF%2521" target="_blank" method="POST"><div class="clip_name"><strong>    !</strong></div><div id="player"><embed src="/images/player/player.swf" width="460" height="345" allowscriptaccess="always" allowfullscreen="true" 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" /></div><div class="download_url"><a href="javascript:document.forms[0].submit();" onclick="p = document.getElementById('player'); if (p) {p.style.display = 'none'; p.style.display = 'block'; p.innerHTML = p.innerHTML + ' '}" title=""></a> 


Pay attention to the line
 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" 


And here we notice the link 465.gt3.vkadre.ru/assets/videos/750c48ae2867-92359355.vk.flv

Moving on it, we will upload a video!
In theory, this is what we need.
And the average user can easily download the video, even without getting into the source code.
But for my purposes it clearly did not fit.
Although at first glance everything was elementary: Get the id video, build the link to v.audiovkontakte.ru, and parse with the help of the regulars source code for the link we need.
But the first problem came to light when I tried to compile a link and click on 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 a button.
So I had to postpone this idea.
But I still have the format of a 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 it is some kind of hash or identifier of this record, and how to get it is unknown.

Desperate, I decided to look at the player for the last time, the link to which we can get or by clicking on the button share> Get the video code (
 <iframe src="http://vkontakte.ru/video_ext.php?oid=13257647&id=161693266&hash=5817a3ba0588efa8&sd" width="607" height="360" frameborder="0"></iframe> 
), or by sending a request to the API, which, I think, will be more relevant.

I was interested in the following block:

 <param name="flashvars" value="uid=0&vid=161693266&oid=13257647&host=465.gt3.vkadre.ru&vtag=750c48ae2867-&ltag=1423ac11&vkid=92359355&md_title=%D0%BD%D0%B5+%D0%B4%D0%B0%D0%B9+%D0%91%D0%BE%D0%B3+%D1%82%D0%B0%D0%BA%D0%BE%D0%B5+%D0%BF%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D1%82%D1%81%D1%8F%21&md_author=%D0%94%D0%B8%D0%BC%D0%BE%D0%BD+%D0%A8%D0%B8%D1%80%D0%BE%D0%BA%D0%BE%D0%B2&hd=0&no_flv=0&hd_def=-1&dbg_on=0&t=&thumb=http://465.gt3.vkadre.ru/assets/thumbnails/1423ac1192359355.460.vk.jpg&hash=3b900fad1e7a6c5606e40e31273ca26d&hash2=5817a3ba0588efa8&is_vk=0&is_ext=1&lang_volume_on=%D0%92%D0%BA%D0%BB%D1%8E%D1%87%D0%B8%D1%82%D1%8C+%D0%B7%D0%B2%D1%83%D0%BA&lang_volume_off=%D0%A3%D0%B1%D1%80%D0%B0%D1%82%D1%8C+%D0%B7%D0%B2%D1%83%D0%BA&lang_volume=%D0%93%D1%80%D0%BE%D0%BC%D0%BA%D0%BE%D1%81%D1%82%D1%8C&lang_hdsd=%D0%A1%D0%BC%D0%B5%D0%BD%D0%B8%D1%82%D1%8C+%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%BE&lang_fullscreen=%D0%9D%D0%B0+%D0%B2%D0%B5%D1%81%D1%8C+%D1%8D%D0%BA%D1%80%D0%B0%D0%BD&lang_window=%D0%A1%D0%B2%D0%B5%D1%80%D0%BD%D1%83%D1%82%D1%8C&lang_rotate=%D0%9F%D0%BE%D0%B2%D0%B5%D1%80%D0%BD%D1%83%D1%82%D1%8C&video_play_hd=%D0%A1%D0%BC%D0%BE%D1%82%D1%80%D0%B5%D1%82%D1%8C+%D0%B2+%D0%B2%D1%8B%D1%81%D0%BE%D0%BA%D0%BE%D0%BC+%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B5&video_stop_loading=%D0%9E%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%B8%D1%82%D1%8C+%D0%B7%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D1%83&video_player_version=%D0%92%D0%9A%D0%BE%D0%BD%D1%82%D0%B0%D0%BA%D1%82%D0%B5+%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE+%D0%BF%D0%BB%D0%B5%D0%B5%D1%80+&video_player_author=%D0%90%D0%B2%D1%82%D0%BE%D1%80+%D0%BF%D0%BB%D0%B5%D0%B5%D1%80%D0%B0+-+%D0%90%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B9+%D0%A5%D0%B0%D1%80%D1%8C%D0%BA%D0%BE%D0%B2&goto_orig_video=%D0%9F%D0%B5%D1%80%D0%B5%D0%B9%D1%82%D0%B8+%D0%BA+%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D0%B8&video_get_video_code=%D0%9A%D0%BE%D0%BF%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D1%82%D1%8C+%D0%BA%D0%BE%D0%B4+%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE&video_load_error=%D0%92%D0%B8%D0%B4%D0%B5%D0%BE%D1%84%D0%B0%D0%B9%D0%BB+%D0%B5%D1%89%D0%B5+%D0%BD%D0%B5+%D0%B7%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%B8%D0%BB%D1%81%D1%8F+%D0%B8%D0%BB%D0%B8+%D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80+%D1%81+%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE%D1%84%D0%B0%D0%B9%D0%BB%D0%BE%D0%BC+%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D0%BE+%D0%BD%D0%B5%D0%B4%D0%BE%D1%81%D1%82%D1%83%D0%BF%D0%B5%D0%BD&video_get_current_url=%D0%9A%D0%BE%D0%BF%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D1%82%D1%8C+%D1%81%D1%81%D1%8B%D0%BB%D0%BA%D1%83+%D0%BD%D0%B0+%D0%BA%D0%B0%D0%B4%D1%80"></param> 


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

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

Algorithm for getting links



1) Using the request to the API, we get the video id and link to the player
2) With the help of regular parsing code for the presence of a line with the vtag parameter and pull out the identifier
3) Build a direct link:
465.gt3.vkadre.ru/assets/videos/ id-id video.vk.format

Source: https://habr.com/ru/post/135323/


All Articles