-
Notifications
You must be signed in to change notification settings - Fork 1
/
manual.py
87 lines (69 loc) · 2.56 KB
/
manual.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
# console only ver for now
import os, sys, json, re
from ossapi import Score, enums, mod
from osuapi import getUser, getBeatmap, convertURL
from imagegen import imageGen
def manual():
score = Score()
pattern = re.compile('https:\/\/osu\.ppy\.sh\/(b|beatmaps|beatmapsets)\/+')
while True:
beatmapurl = input('Enter the URL of the beatmap: ')
if pattern.match(beatmapurl):
break
else:
print('Invalid beatmap URL.')
# https://circleguard.github.io/ossapi/_modules/ossapi/ossapiv2.html#Ossapi
beatmap = getBeatmap(beatmapurl)
score.__setattr__('beatmap', beatmap)
score.__setattr__(
'beatmapset',
beatmap.beatmapset()) # necessary for background downlaod
pattern = re.compile('https:\/\/osu\.ppy\.sh\/(u|users)\/[0-9]+')
while True:
userurl = input('Enter the URL of the user: ')
if pattern.match(userurl):
break
else:
print('Invalid user URL.')
score.__setattr__('user_id', convertURL(userurl)[0])
score.__setattr__('_user', getUser(userurl)) # weird
pp = input('Enter the pp value of the score, or leave blank.\n> ')
if pp:
score.__setattr__('pp', float(pp))
while True:
acc = input('Enter the accuracy value of the score.\n> ')
if not acc:
print('Enter a value.')
else:
break
score.__setattr__('accuracy', float(acc) / 100)
while True:
combo = input('Enter the combo value of the score.\n> ')
if not combo:
print('Enter a value.')
else:
break
score.__setattr__('max_combo', int(combo))
while True:
grade = input(
'Enter the letter grade value. ex: X, SH, A, C, XH\nFor more info, see https://circleguard.github.io/ossapi/appendix.html#ossapi.enums.Grade\n> '
)
if not grade:
print('Enter a value.')
else:
break
score.__setattr__('rank', enums.Grade(grade))
mods = input(
'Enter the mods used. For NM, leave blank. ex: HR, HDDT, EZDTFL\nFor more info, see https://circleguard.github.io/ossapi/_modules/ossapi/mod.html\n> '
)
if not mods:
mods = 'NM'
score.__setattr__('mods', mod.Mod(mods))
if score.mods.value != 0:
sr = input('Enter the mod weighted star rating of the beatmap.\n> ')
if sr:
score.beatmap.__setattr__('difficulty_rating', sr)
print('Generating image...')
outputpath = imageGen(score)
print(f'image saved as {outputpath}')
# manual()