Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
fc0e9514
Commit
fc0e9514
authored
Oct 11, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add preview time for tja files
parent
4b986c62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
app.py
app.py
+33
-6
No files found.
app.py
View file @
fc0e9514
...
@@ -60,6 +60,26 @@ def get_osu_key(osu, section, key, default=None):
...
@@ -60,6 +60,26 @@ def get_osu_key(osu, section, key, default=None):
return
default
return
default
def
get_tja_preview
(
tja
):
tja_lines
=
open
(
tja
,
'r'
)
.
read
()
.
replace
(
'
\x00
'
,
''
)
.
split
(
'
\n
'
)
for
line
in
tja_lines
:
line
=
line
.
strip
()
if
':'
in
line
:
name
,
value
=
line
.
split
(
':'
,
1
)
if
name
.
lower
()
==
'demostart'
:
value
=
value
.
strip
()
try
:
value
=
float
(
value
)
except
ValueError
:
pass
else
:
return
int
(
value
*
1000
)
elif
line
.
lower
()
==
'#start'
:
break
return
0
@
app
.
teardown_appcontext
@
app
.
teardown_appcontext
def
close_connection
(
exception
):
def
close_connection
(
exception
):
db
=
getattr
(
g
,
'_database'
,
None
)
db
=
getattr
(
g
,
'_database'
,
None
)
...
@@ -85,6 +105,13 @@ def route_api_songs():
...
@@ -85,6 +105,13 @@ def route_api_songs():
categories
[
cat
[
0
]]
=
{
'title'
:
cat
[
1
],
'title_en'
:
cat
[
2
]}
categories
[
cat
[
0
]]
=
{
'title'
:
cat
[
1
],
'title_en'
:
cat
[
2
]}
songs_out
=
[]
songs_out
=
[]
for
song
in
songs
:
for
song
in
songs
:
type
=
song
[
9
]
if
type
==
"tja"
:
if
os
.
path
.
isfile
(
'public/songs/
%
s/main.tja'
%
song
[
0
]):
preview
=
get_tja_preview
(
'public/songs/
%
s/main.tja'
%
song
[
0
])
else
:
preview
=
0
else
:
osus
=
[
osu
for
osu
in
os
.
listdir
(
'public/songs/
%
s'
%
song
[
0
])
if
osu
in
[
'easy.osu'
,
'normal.osu'
,
'hard.osu'
,
'oni.osu'
]]
osus
=
[
osu
for
osu
in
os
.
listdir
(
'public/songs/
%
s'
%
song
[
0
])
if
osu
in
[
'easy.osu'
,
'normal.osu'
,
'hard.osu'
,
'oni.osu'
]]
if
osus
:
if
osus
:
osud
=
parse_osu
(
'public/songs/
%
s/
%
s'
%
(
song
[
0
],
osus
[
0
]))
osud
=
parse_osu
(
'public/songs/
%
s/
%
s'
%
(
song
[
0
],
osus
[
0
]))
...
@@ -103,7 +130,7 @@ def route_api_songs():
...
@@ -103,7 +130,7 @@ def route_api_songs():
'preview'
:
preview
,
'preview'
:
preview
,
'category'
:
category_out
[
'title'
],
'category'
:
category_out
[
'title'
],
'category_en'
:
category_out
[
'title_en'
],
'category_en'
:
category_out
[
'title_en'
],
'type'
:
song
[
9
]
,
'type'
:
type
,
'offset'
:
song
[
10
]
'offset'
:
song
[
10
]
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment