mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
misc refactors and docstrings addition
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
"""
|
||||
This library contains all the functions related to tracks.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from app import models, instances
|
||||
from app.lib import albumslib
|
||||
from app.helpers import remove_duplicates
|
||||
from app import api
|
||||
from app import api, helpers
|
||||
from progress.bar import Bar
|
||||
|
||||
|
||||
def create_all_tracks() -> List[models.Track]:
|
||||
"""
|
||||
Gets all songs under the ~/ directory.
|
||||
"""
|
||||
print("Getting all songs...")
|
||||
tracks: list[models.Track] = []
|
||||
|
||||
timer = helpers.Timer()
|
||||
|
||||
_bar = Bar("Creating tracks", max=len(api.DB_TRACKS))
|
||||
for track in api.DB_TRACKS:
|
||||
try:
|
||||
os.chmod(track["filepath"], 0o755)
|
||||
@@ -23,9 +31,12 @@ def create_all_tracks() -> List[models.Track]:
|
||||
track["image"] = album.image
|
||||
|
||||
tracks.append(models.Track(track))
|
||||
_bar.next()
|
||||
|
||||
api.TRACKS.clear()
|
||||
api.TRACKS.extend(tracks)
|
||||
_bar.finish()
|
||||
print(f"Created all songs in {timer.stop()}")
|
||||
|
||||
|
||||
def get_album_tracks(albumname, artist):
|
||||
@@ -43,4 +54,4 @@ def get_track_by_id(trackid: str) -> models.Track:
|
||||
"""Returns api track matching an id"""
|
||||
for track in api.TRACKS:
|
||||
if track.id == trackid:
|
||||
return track
|
||||
return track
|
||||
|
||||
Reference in New Issue
Block a user