mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2025-02-22 06:00:33 +03:00
fixed song process
This commit is contained in:
parent
85e8e3fe8b
commit
b72ebe6e8c
|
@ -22,13 +22,30 @@
|
||||||
|
|
||||||
|
|
||||||
def get_or_create_author(author_name):
|
def get_or_create_author(author_name):
|
||||||
|
"""Get or create author with unique slug."""
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
author = Author.objects.filter(name__iexact=author_name).order_by("id").first()
|
author = Author.objects.filter(name__iexact=author_name).order_by("id").first()
|
||||||
if author is None:
|
if author is None:
|
||||||
author = Author.objects.create(name=author_name)
|
author = Author.objects.create(
|
||||||
|
name=author_name, slug=generate_readable_slug(author_name, Author)
|
||||||
|
)
|
||||||
return author
|
return author
|
||||||
|
|
||||||
|
|
||||||
|
def get_or_create_album(album_name):
|
||||||
|
"""Get or create album with unique slug."""
|
||||||
|
if not album_name:
|
||||||
|
return None
|
||||||
|
|
||||||
|
with transaction.atomic():
|
||||||
|
album = Album.objects.filter(name__iexact=album_name).order_by("id").first()
|
||||||
|
if album is None:
|
||||||
|
album = Album.objects.create(
|
||||||
|
name=album_name, slug=generate_readable_slug(album_name, Album)
|
||||||
|
)
|
||||||
|
return album
|
||||||
|
|
||||||
|
|
||||||
def process_track_name(track_name: str) -> str:
|
def process_track_name(track_name: str) -> str:
|
||||||
# Split the track name by dash and parentheses
|
# Split the track name by dash and parentheses
|
||||||
parts = track_name.split(" - ")
|
parts = track_name.split(" - ")
|
||||||
|
@ -109,9 +126,7 @@ def load_track(
|
||||||
else:
|
else:
|
||||||
album_name = None
|
album_name = None
|
||||||
if album_name:
|
if album_name:
|
||||||
album, created = Album.objects.get_or_create(
|
album = get_or_create_album(album_name)
|
||||||
name__iexact=album_name, defaults={"name": album_name}
|
|
||||||
)
|
|
||||||
|
|
||||||
processed_authors = []
|
processed_authors = []
|
||||||
if authors:
|
if authors:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user