-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgrowAccount.py
156 lines (138 loc) · 4.95 KB
/
growAccount.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import requests
import random
import time
import random
import db
LIMIT = 10000
# This is the result limit
try:
idList = []
for val in open("listOfClientIDs.txt").read().split("\n"):
if len(val) > 5:
idList.append(val)
if len(idList) == 0:
raise Exception("No Client IDs")
clientID = random.choice(idList)
except:
clientID = raw_input("Client ID: ")
try:
authCode = open("authCode.txt").read().split('\n')[0]
if len(authCode) == 0:
raise Exception("No Auth IDs")
except:
authCode = raw_input("Auth Code: ")
listOfAccts = ["nightcore-3"]
willFollow = 0
followingMin = 30
likesMin = 100
toFollow = []
listOfFollowings = []
# These are the people that the account is currently following
def getFollowingsCount():
res = requests.get("https://api-mobi.soundcloud.com/resolve?permalink_url=https%3A//soundcloud.com/user-367430385&client_id={}&format=json&app_version=1524734136".format(clientID))
return res.json()['followings_count']
def updateToFollow(followCount=None):
offset = None
url = "https://api-v2.soundcloud.com/users/38122545/followers?&limit=200&client_id={}".format(clientID)
while len(toFollow) < followCount:
try:
res = requests.get(url)
for val in res.json()['collection']:
#if (float(val['followings_count']) / float(val['followers_count']) * 100)
if (val['followings_count'] > followingMin) and (val['likes_count'] > likesMin):
if len(toFollow) <= followCount and (val['id'] not in db.DATABASE["followings"]):
toFollow.append(val['id'])
print("{} - {}".format(val['permalink_url'], val['id']))
url = res.json()['next_href'] + "&client_id={}".format(clientID)
except:
print res.json()
def updateCurrentFollowing(actID='438591654'):
followings = getFollowingsCount()
url = 'https://api-v2.soundcloud.com/users/{}/followings?limit={}&client_id={}'.format(actID, LIMIT, clientID)
while len(listOfFollowings) < followings:
try:
res = requests.get(url)
for val in res.json()['collection']:
listOfFollowings.append(val['id'])
url = res.json()['next_href'] + "&client_id={}".format(clientID)
except:
pass
print("Finished searching page")
def follow(idVal):
headers = {
'Pragma': 'no-cache',
'Origin': 'https://soundcloud.com',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,es-US;q=0.8,es;q=0.6,ru-BY;q=0.4,ru;q=0.2,en;q=0.2',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.113 Chrome/60.0.3112.113 Safari/537.36',
'Content-Type': 'application/json',
'Accept': 'application/json, text/javascript, */*; q=0.1',
'Cache-Control': 'no-cache',
'Authorization': authCode,
'Connection': 'keep-alive',
'Referer': 'https://soundcloud.com/',
}
sleepTime = round(random.uniform(1.0, 20.0), 2)
print("Following {} in {} Seconds".format(idVal, sleepTime))
time.sleep(sleepTime)
params = (
('client_id', clientID),
('app_version', '1525260260'),
('app_locale', 'en'),
)
data = 'null'
requests.post('https://api-v2.soundcloud.com/me/followings/{}'.format(idVal), headers=headers, params=params, data=data)
def unfollowUser(userID):
headers = {
'Pragma': 'no-cache',
'Origin': 'https://soundcloud.com',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,es-US;q=0.8,es;q=0.6,ru-BY;q=0.4,ru;q=0.2,en;q=0.2',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.113 Chrome/60.0.3112.113 Safari/537.36',
'Content-Type': 'application/json',
'Accept': 'application/json, text/javascript, */*; q=0.1',
'Cache-Control': 'no-cache',
'Authorization': authCode,
'Connection': 'keep-alive',
'Referer': 'https://soundcloud.com/',
}
sleepTime = round(random.uniform(1.0, 20.0), 2)
print("Unfollowing {} in {} Seconds".format(userID, sleepTime))
time.sleep(sleepTime)
params = (
('client_id', clientID),
('app_version', '1526649907'),
('app_locale', 'en'),
)
data = 'null'
response = requests.delete('https://api-v2.soundcloud.com/me/followings/{}'.format(userID), headers=headers, params=params, data=data)
print("Unfollowed: {}".format(userID))
def doAction(actionDict):
try:
if actionDict['Type'] == 'Unfollow':
unfollowUser(actionDict['User'])
else:
follow(actionDict['User'])
except:
print "Error"
if __name__ == '__main__':
tDict = []
'''updateCurrentFollowing()
# Updates list of users that are currently being followed
updateToFollow(int(raw_input("How many users do you want to follow: ")))
print len(toFollow)
for val in toFollow:
follow(val)'''
db.update()
# Updates the current database
followCount = int(raw_input("How many people do you want to follow? ")) + random.randint(1, 9)
unfollowCount = random.randint(1, 10) + followCount
for val in db.grabAllFollowings()[:unfollowCount]:
tDict.append({"Type": "Unfollow", "User": val['id']})
updateToFollow(followCount)
for val in toFollow:
tDict.append({"Type": "Follow", "User": val})
random.shuffle(tDict)
for val in tDict:
doAction(val)
db.update()