-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmule_runner.py
More file actions
71 lines (61 loc) · 2.14 KB
/
smule_runner.py
File metadata and controls
71 lines (61 loc) · 2.14 KB
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
# smule runner.py
from base_classes.smule import *
def getPerformances(handle):
API_URL = f"https://www.smule.com/s/profile/performance/{handle}/sing"
userProfile = requests.get(API_URL)
userProfile = userProfile.json()["list"]
performances = list(map(lambda performanceJSON: performanceJSON["performance_key"], userProfile))
return performances
def getPerformanceJson(perf_key):
API_URL = f"https://www.smule.com/p/{perf_key}/json"
performanceJSON = requests.get(API_URL)
performanceJSON = performanceJSON.json()
return(smule_performance(performanceJSON))
def getUserInfoFromAPI(username):
API_URL = f"https://www.smule.com/s/user_profiles/{username}/json"
userJson = requests.get(API_URL)
userJson = userJson.json()
userProfile = list(map(smule_user_api, userJson))[0]
return userProfile
def userLookupAPI_Print(user_id):
userinfo = getUserInfoFromAPI(user_id)
userinfostring = f"""
account_id: {userinfo.account_id}
handle: {userinfo.handle}
pfp_url: {userinfo.pic_url}
blurb: {userinfo.blurb}
"""
print(userinfostring)
def userLookup_Print(username):
perfs = getPerformances(username)
perfdata = list(map(getPerformanceJson, perfs))
for data in perfdata:
info = generateTextInfo(data)
for j in info:
print(j)
def generateTextInfo(obj):
performance_info = f"""
performance key: {obj.performance_key}
type: {obj.type}
title: {obj.title}
artist: {obj.message}
message: {obj.message}
created_at: {obj.created_at}
ensemble_type: {obj.ensemble_type}
app_uid: {obj.app_uid} [{DeviceMap[obj.app_uid]}]"""
yield performance_info
owner_info = f"""
account_id: {obj.owner.account_id}
handle: {obj.owner.handle}
pic_url: {obj.owner.pic_url}
verified_type {obj.owner.verified_type}
coords: {obj.owner.lat}, {obj.owner.lon}"""
yield owner_info
users_info = list(map(lambda userObj: f"""
account_id: {userObj.account_id}
handle: {userObj.handle}
pic_url: {userObj.pic_url}
verified_type {userObj.verified_type}
coords: {userObj.lat}, {userObj.lon}""", obj.other_performers))
for userinfo in users_info:
yield userinfo