Skip to content

Commit

Permalink
refactor: remove jingles & short tracks from search results
Browse files Browse the repository at this point in the history
  • Loading branch information
ohrstrom committed Jun 26, 2024
1 parent 90a9838 commit 08143fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
7 changes: 2 additions & 5 deletions obr_core/account/apple_id_login/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
APP_TEAM_ID = "236JDQVAKF"

APP_KEY_ID = "DX7Z5X95D3"
APP_KEY_CONTENT = """-----BEGIN PRIVATE KEY-----
(( THIS IS NOT THE KEY ;) ))
-----END PRIVATE KEY-----"""
APP_KEY_CONTENT = ""


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -57,6 +55,7 @@ def generate_client_secret():


def verify_authorization_code(authorization_code):
# NOTE: this is not working. is it even needed??
print("ac", authorization_code)

client_secret = generate_client_secret()
Expand Down Expand Up @@ -132,8 +131,6 @@ def get_or_create_user( # noqa C901
):
raise AppleIdLoginError("token has expired")

# NOTE: this does not work at the moment:

social_auth_uid = apple_id
user_created = False

Expand Down
29 changes: 14 additions & 15 deletions obr_core/catalog/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@
from tagging.models import TaggedItem


class Kind(models.TextChoices):
UNDEFINED = "", "Not specified"
SONG = "song", "Song"
ACAPPELLA = "acappella", "A cappella"
SOUNDEFFECTS = "soundeffects", "Sound effects"
SOUNDTRACK = "soundtrack", "Soundtrack"
SPOKENWORD = "spokenword", "Spokenword"
INTERVIEW = "interview", "Interview"
JINGLE = "jingle", "Jingle"
DJMIX = "djmix", "DJ-Mix"
CONCERT = "concert", "Concert"
LIVEACT = "liveact", "Live Act PA)"
RADIOSHOW = "radioshow", "Radio show"


class Media(
TimestampedModelMixin,
CTUIDModelMixin,
SyncModelMixin,
models.Model,
):
class Kind(models.TextChoices):
UNDEFINED = "", "Not specified"
SONG = "song", "Song"
ACAPPELLA = "acappella", "A cappella"
SOUNDEFFECTS = "soundeffects", "Sound effects"
SOUNDTRACK = "soundtrack", "Soundtrack"
SPOKENWORD = "spokenword", "Spokenword"
INTERVIEW = "interview", "Interview"
JINGLE = "jingle", "Jingle"
DJMIX = "djmix", "DJ-Mix"
CONCERT = "concert", "Concert"
LIVEACT = "liveact", "Live Act PA)"
RADIOSHOW = "radioshow", "Radio show"

name = models.CharField(max_length=256)

duration = models.DurationField(
Expand Down
8 changes: 8 additions & 0 deletions obr_core/search/api/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from datetime import timedelta

from django.db.models import Q

from catalog.models import Media
from rest_framework import mixins, viewsets

from .serializers import SearchMediaResultSerializer

MEDIA_MIN_DURATION = 12


class GlobalMediaSearchView(
mixins.ListModelMixin,
Expand All @@ -20,6 +24,10 @@ def get_queryset(self, **kwargs):
"releases__images",
)

qs = qs.exclude(kind=Media.Kind.JINGLE)

qs = qs.filter(duration__gt=timedelta(seconds=MEDIA_MIN_DURATION))

qs = qs.filter(
Q(name__unaccent__icontains=q)
| Q(artists__name__unaccent__icontains=q)
Expand Down

0 comments on commit 08143fc

Please sign in to comment.