-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeatSaberSongPuller.py
85 lines (68 loc) · 2.36 KB
/
BeatSaberSongPuller.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
import numpy as np
import os
import requests
import json
#rootdir = "D:\Oculus\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\CustomLevels"
rootdir = input("Enter location of 'CustomLevels' folder: ")
def fileLines(file):
line_count = 0
for line in file:
if line != "\n":
line_count += 1
return(line_count)
def songPuller(file):
with open(file, 'rt') as fl_lines:
lines = fl_lines.readlines()
count = fileLines(lines)
with open(file, 'rt') as fl:
text = fl.read()
if count <= 1:
modStartSn = 11
modEndSn = 1
modStartAn = 18
modEndAn = 1
modStartMn = 19
modEndMn = 1
else:
modStartSn = 12
modEndSn = 1
modStartAn = 19
modEndAn = 1
modStartMn = 20
modEndMn = 1
indxStartSn = text.index('songName')
indxEndSn = text.find(',', indxStartSn, len(text) )
songName = text[indxStartSn+modStartSn:indxEndSn-modEndSn]
indxStartAn = text.index('_songAuthorName')
indxEndAn = text.find(',', indxStartAn, len(text) )
artistName = text[indxStartAn+modStartAn:indxEndAn-modEndAn]
indxStartMn = text.index('_levelAuthorName')
indxEndMn = text.find(',', indxStartMn, len(text) )
modderName = text[indxStartMn+modStartMn:indxEndMn-modEndMn]
return(songName,artistName,modderName)
songList = {0: {'songName': 'test', 'artistName': 'test', 'modderName': 'test'}
}
i=0
for subdir, dirs, files in os.walk(rootdir):
if "info.dat" in files:
filePath = subdir + "\info.dat"
sN,aN,mN = songPuller(filePath)
songList[i] = {'songName': sN, 'artistName': aN, 'modderName': mN}
i += 1
continue
elif "Info.dat" in files:
filePath = subdir + "\Info.dat"
sN,aN,mN = songPuller(filePath)
songList[i] = {'songName': sN, 'artistName': aN, 'modderName': mN}
i +=1
continue
else:
continue
for songNum, songInfo in songList.items():
print(songInfo['songName'],",",songInfo['artistName'],",",songInfo['modderName'])
url = "https://api.beatsaver.com/search/text/0?q=24K%20Magic%2C%20Bruno%20Mars%2C%20BennyDaBeast&sortOrder=Relevance"
response = requests.get(url)
print(response.status_code)
response_json = response.json()
response_dict = json.loads(response_json)
print(response_dict)