move to xxh3 hashing algorithm

+ port: search
This commit is contained in:
cwilvx
2024-07-03 11:12:06 +03:00
parent ff7343a7be
commit a5634f267f
16 changed files with 322 additions and 182 deletions
+11 -6
View File
@@ -112,21 +112,26 @@ class Album:
Runs all the checks to determine the type of album.
"""
if self.is_single(tracks, singleTrackAsSingle):
return "single"
self.type = "single"
return
if self.is_soundtrack():
return "soundtrack"
self.type = "soundtrack"
return
if self.is_live_album():
return "live album"
self.type = "live album"
return
if self.is_compilation():
return "compilation"
self.type = "compilation"
return
if self.is_ep():
return "ep"
self.type = "ep"
return
return "album"
self.type = "album"
def is_soundtrack(self) -> bool:
"""
+6 -12
View File
@@ -5,6 +5,7 @@ from pathlib import Path
from typing import Any
from app import settings
from app.utils.auth import get_current_userid
@dataclass(slots=True)
@@ -16,10 +17,10 @@ class Playlist:
last_updated: str
name: str
settings: dict
userid: int
trackhashes: list[str]
trackhashes: list[str] = dataclasses.field(default_factory=list)
extra: dict[str, Any] = dataclasses.field(default_factory=dict)
userid: int | None = None
thumb: str = ""
count: int = 0
duration: int = 0
@@ -28,11 +29,10 @@ class Playlist:
pinned: bool = False
def __post_init__(self):
# self.trackhashes = json.loads(str(self.trackhashes))
# self.count = len(self.trackhashes)
self.count = len(self.trackhashes)
# if isinstance(self.settings, str):
# self.settings = dict(json.loads(self.settings))
if self.userid is None:
self.userid = get_current_userid()
self.pinned = self.settings.get("pinned", False)
self.has_image = (
@@ -45,12 +45,6 @@ class Playlist:
self.image = "None"
self.thumb = "None"
# def set_duration(self, duration: int):
# self.duration = duration
# def set_count(self, count: int):
# self.count = count
def clear_lists(self):
"""
Removes data from lists to make it lighter for sending