mirror of
https://github.com/solero/houdini.git
synced 2024-11-28 08:27:18 +00:00
Perform regex match before trying to determine song length
This commit is contained in:
parent
91f287087f
commit
e5c9a4b57a
@ -207,15 +207,15 @@ async def handle_load_music_track(p, owner_id: int, track_id: int):
|
|||||||
@handlers.player_in_room(SoundStudio.DeckRoomId)
|
@handlers.player_in_room(SoundStudio.DeckRoomId)
|
||||||
@handlers.cooldown()
|
@handlers.cooldown()
|
||||||
async def handle_save_my_music_track(p, track_name, track_pattern, track_hash):
|
async def handle_save_my_music_track(p, track_name, track_pattern, track_hash):
|
||||||
|
pattern_regex = r'^([0-9a-fA-F]+,[0-9a-fA-F]+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$'
|
||||||
|
if not re.match(pattern_regex, track_pattern):
|
||||||
|
return
|
||||||
|
|
||||||
encoded_track_pattern = encode_music_track(track_pattern)
|
encoded_track_pattern = encode_music_track(track_pattern)
|
||||||
song_length = determine_song_length(track_pattern)
|
song_length = determine_song_length(track_pattern)
|
||||||
if encoded_track_pattern != track_hash or song_length > 180:
|
if encoded_track_pattern != track_hash or song_length > 180:
|
||||||
return
|
return
|
||||||
|
|
||||||
pattern_regex = r'^([0-9a-fA-F]+,[0-9a-fA-F]+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$'
|
|
||||||
if not re.match(pattern_regex, track_pattern):
|
|
||||||
return
|
|
||||||
|
|
||||||
track_count = await db.select([db.func.count(PenguinTrack.id)])\
|
track_count = await db.select([db.func.count(PenguinTrack.id)])\
|
||||||
.where(PenguinTrack.owner_id == p.id).gino.scalar()
|
.where(PenguinTrack.owner_id == p.id).gino.scalar()
|
||||||
if track_count >= 12:
|
if track_count >= 12:
|
||||||
|
Loading…
Reference in New Issue
Block a user