-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvkMusicDwn.py
62 lines (58 loc) · 2.46 KB
/
vkMusicDwn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
import download
import vk_auth
import urllib2
import os
import time
import getpass
# Path to download folder
dpath = '/music/'
### This block uncommented if you want put email and
### password from keyboard
email = raw_input("Email: ")
password = getpass.getpass()
### This block for static email and password
###
#email = 'email'
#password = 'password'
bitrate = 230
usersmusic = raw_input("Download users playlist? ( yes/no ): ")
if usersmusic.lower() == "n" or usersmusic.lower() == "no":
# different search can be splitted by '|'.
search = download.firstLetter(raw_input("What do want to find: ")).decode('utf-8')
scount = raw_input("How many songs do want to download: ")
offset = raw_input("Put offset: ")
start_time = time.time()
for s in search.split('|'):
searching = urllib2.quote(s.encode('utf-8'))
s = download.remSym(s)
access_token, user_id = vk_auth.auth(email, password, "3164037", "10")
download.doSearch(access_token, user_id, scount, searching, dpath + s, offset, False, bitrate)
bq = open(dpath + s + "/Bad Quality Songs.txt" + searching, 'r')
bqlist = bq.readlines()
bq.close()
for i in bqlist:
download.doSearch(access_token, user_id, 7, urllib2.quote(i.strip()), dpath + s, 0, i.split(" - ")[0], bitrate)
if os.path.exists(dpath + s):
for i in os.listdir(dpath + s + '/'):
if i.startswith("Bad Quality Songs.txt"):
os.remove(dpath + s + "/" + i)
print "Finish"
else:
if usersmusic.lower() == "y" or usersmusic.lower() == "yes":
access_token, user_id = vk_auth.auth(email, password, "3164037", "10")
download.usersMusic(access_token, user_id, 'myplaylist', dpath + 'myplaylist', False, bitrate)
search = 'myplaylist'
searching = 'myplaylist'
bq = open(dpath + search + "/Bad Quality Songs.txt" + searching, 'r')
bqlist = bq.readlines()
bq.close()
for i in bqlist:
download.doSearch(access_token, user_id, 11, urllib2.quote(i.strip()), dpath + search, 0, i.split(" - ")[0], bitrate)
if os.path.exists(dpath + search):
for i in os.listdir(dpath + search + '/'):
if i.startswith("Bad Quality Songs.txt"):
os.remove(dpath + search + "/" + i)
print "Finish"
else:
print "Please answer yes/y or no/n"