mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
rewrite some for loops with UseBisection
This commit is contained in:
@@ -34,7 +34,7 @@ def initialize() -> None:
|
||||
albumslib.create_everything()
|
||||
folderslib.run_scandir()
|
||||
playlistlib.create_all_playlists()
|
||||
functions.reindex_tracks()
|
||||
# functions.reindex_tracks()
|
||||
|
||||
|
||||
initialize()
|
||||
|
||||
+10
-10
@@ -12,7 +12,7 @@ from app.lib import playlistlib
|
||||
from flask import Blueprint
|
||||
from flask import request
|
||||
|
||||
from app.helpers import create_new_date
|
||||
from app.helpers import UseBisection, create_new_date
|
||||
|
||||
playlist_bp = Blueprint("playlist", __name__, url_prefix="/")
|
||||
|
||||
@@ -78,13 +78,12 @@ def add_track_to_playlist(playlist_id: str):
|
||||
|
||||
@playlist_bp.route("/playlist/<playlistid>")
|
||||
def get_single_p_info(playlistid: str):
|
||||
for p in api.PLAYLISTS:
|
||||
if p.playlistid == playlistid:
|
||||
tracks = p.get_tracks()
|
||||
return {
|
||||
"info": serializer.Playlist(p),
|
||||
"tracks": tracks,
|
||||
}
|
||||
p = UseBisection(api.PLAYLISTS, "playlistid", [playlistid])()
|
||||
playlist: models.Playlist = p[0]
|
||||
|
||||
if playlist is not None:
|
||||
tracks = playlist.get_tracks()
|
||||
return {"info": serializer.Playlist(playlist), "tracks": tracks}
|
||||
|
||||
return {"info": {}, "tracks": []}
|
||||
|
||||
@@ -106,9 +105,10 @@ def update_playlist(playlistid: str):
|
||||
"thumb": None,
|
||||
}
|
||||
|
||||
for p in api.PLAYLISTS:
|
||||
if p.playlistid == playlistid:
|
||||
p = UseBisection(api.PLAYLISTS, "playlistid", [playlistid])()
|
||||
p: models.Playlist = p[0]
|
||||
|
||||
if playlist is not None:
|
||||
if image:
|
||||
image_, thumb_ = playlistlib.save_p_image(image, playlistid)
|
||||
playlist["image"] = image_
|
||||
|
||||
Reference in New Issue
Block a user