Thursday, January 26, 2012

VKDownloader Python Script

VK is the largest European social network with more than a 100 million active users. It's similar to facebook. There's a video section where we can stream or download it.
Here's a simple python script to grab the download link for the video you want.

#!/usr/bin/python

import sys, re, urllib2


if len(sys.argv) < 2:
    print """    
      ## Usage : python vkdownloader.py "Url" ##
    --------------------------------------
        ## by p0pc0rn 2012 ##

          
    
          """
    sys.exit(0)

url = sys.argv[1]
url2 = sys.argv[1]
url3 = sys.argv[1]

find = re.compile("var video_host = '(.*?)';")
find2 = re.compile("var video_uid = '(.*?)';")
find3 = re.compile("var video_vtag = '(.*?)';")
data = urllib2.urlopen(url).read()
data2 = urllib2.urlopen(url2).read()
data3 = urllib2.urlopen(url3).read()
result = find.search(data)
result2 = find2.search(data2)
result3 = find3.search(data3)

print 'Download link for 360p => ' + result.group(1) +'u'+result2.group(1)+'/video/'+ result3.group(1)+'.360.mp4'
print 'Download link for 480p => ' + result.group(1) +'u'+result2.group(1)+'/video/'+ result3.group(1)+'.480.mp4'
print 'Download link for 720p => ' + result.group(1) +'u'+result2.group(1)+'/video/'+ result3.group(1)+'.720.mp4'

Save the code as vkdownloader.py. You'll need python of course to run the script :)

How to use?
1 - Grab the video URL by right click on the video and copy url code.

2 - Paste the link as the instruction in the script.

3 - The results will be appear for 360,480, and 720 version.( not all video supported for higher resolution )

4 - Copy the link and you can download using your download manager.


Thanks,
p0pc0rn
Share:

0 comments: