Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import webbrowser
- import urllib2
- import lxml
- import lxml.html
- #our functions to check program
- def CheckInet():
- print "Checking connection"
- try:
- response = urllib2.urlopen('http://www.ru', timeout = 1)
- print "[SUCCCESS] Internet connection is established"
- return True
- except urllib2.URLError as err:
- pass
- print "[FAILED]Failed to establish the connection"
- return False
- def CheckWget():
- print "Checking wget"
- try:
- open ('/usr/bin/wget')
- print "[SUCCCESS] Wget was found"
- return True
- except IOError as err:
- print "[FAILED]Failed to locate wget"
- return False
- print "Starting grabVK 2.0"
- #checking
- checkInet = CheckInet()
- checkWget = CheckWget()
- if checkInet != True:
- exit()
- if checkWget != True:
- exit()
- print "Checking process finished. Starting downloading"
- #copying authkey
- webbrowser.open_new_tab("http://api.vkontakte.ru/oauth/authorize?client_id=2223684&scope=audio&redirect_uri=http://api.vk.com/blank.html&display=page&response_type=token")
- print "Please copy access token from webpage address after authenticating on VK page in your browser"
- access_token= raw_input("access_token: ")
- print "Please copy expire time from webpage address after authenticating on VK page in your browser"
- expires_in = raw_input("expires_in: ")
- print "Please copy your id from webpage address after authenticating on VK page in your browser"
- user_id = raw_input ("user_id: ")
- #get playlist
- url = "https://api.vkontakte.ru/method/audio.get.xml?uid=" + user_id + "&access_token=" + access_token
- page = urllib2.urlopen(url)
- html = page.read()
- print "[SUCCCESS] Getting playlist"
- #creating vars for playlist
- artist_list = []
- title_list = []
- url_list = []
- num = 0
- #get artists
- doc = lxml.html.document_fromstring(html)
- for artist in doc.cssselect('artist'):
- artist_list.append(artist.text)
- num = num + 1
- print "[SUCCCESS] Getting artist"
- #get titles
Advertisement
Add Comment
Please, Sign In to add comment