Extract temporary tag management in own methods

Also added way to uniquely identifiying them
master
Felix Stupp 1 year ago
parent 059111068a
commit ed1e5b3f26
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -156,7 +156,25 @@ class CollectionStats:
## Tag & Selection Score's
TEMPORARY_TAGS_IDENTIFIER = (
"automatic_temporary_tag:82e4509f-e262-463f-8ee5-140ca400ea79"
)
"""random static UUID for identification
This string shall not be parsed and only used as a whole.
"""
class Tag(db.Entity, Tagable):
@classmethod
def gen_temporary_tag(cls, hint: str) -> Tag:
"""Generates a new, unique and temporary tag. Required for some algorithms."""
return Tag(
title=f"[A] {hint}",
notes=TEMPORARY_TAGS_IDENTIFIER,
use_for_preferences=True,
)
id: int = orm.PrimaryKey(int, auto=True)

@ -35,19 +35,16 @@ def generate_preference_list(
def add_tags_for_collections() -> None:
collections: Iterable[MediaCollection] = MediaCollection.select()
for coll in collections:
coll.tag_list.add(
Tag(
title="Automatic",
use_for_preferences=True,
)
tag = Tag.gen_temporary_tag(
hint=f"Collection: {coll.title}",
)
coll.tag_list.add(tag)
def add_tags_for_extractor_names() -> None:
@cache
def get_extractor_tag(extractor_name: str) -> Tag:
return Tag(
title=f"Automatic for extractor {extractor_name}",
use_for_preferences=True,
return Tag.gen_temporary_tag(
hint=f"Extractor: {extractor_name}",
)
for element in element_list:

Loading…
Cancel
Save