[podcasts] Fix name for Episode model to PodcastEpisode
This commit is contained in:
@ -16,7 +16,8 @@ from scrobbles.models import Scrobble
|
|||||||
def build_scrobbles(client, request_data, num=7, spacing=2):
|
def build_scrobbles(client, request_data, num=7, spacing=2):
|
||||||
url = reverse("scrobbles:mopidy-webhook")
|
url = reverse("scrobbles:mopidy-webhook")
|
||||||
user = get_user_model().objects.create(username="Test User")
|
user = get_user_model().objects.create(username="Test User")
|
||||||
UserProfile.objects.create(user=user, timezone="US/Eastern")
|
user.profile.timezone = "US/Eastern"
|
||||||
|
user.profile.save()
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
client.post(url, request_data, content_type="application/json")
|
client.post(url, request_data, content_type="application/json")
|
||||||
s = Scrobble.objects.last()
|
s = Scrobble.objects.last()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from music.models import Track
|
from music.models import Track
|
||||||
from podcasts.models import Episode
|
from podcasts.models import PodcastEpisode
|
||||||
from scrobbles.models import Scrobble
|
from scrobbles.models import Scrobble
|
||||||
|
|
||||||
|
|
||||||
@ -96,5 +96,5 @@ def test_scrobble_mopidy_podcast(
|
|||||||
assert response.data == {"scrobble_id": 1}
|
assert response.data == {"scrobble_id": 1}
|
||||||
|
|
||||||
scrobble = Scrobble.objects.get(id=1)
|
scrobble = Scrobble.objects.get(id=1)
|
||||||
assert scrobble.media_obj.__class__ == Episode
|
assert scrobble.media_obj.__class__ == PodcastEpisode
|
||||||
assert scrobble.media_obj.title == "Up First"
|
assert scrobble.media_obj.title == "Up First"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from podcasts.models import Episode, Podcast, Producer
|
from podcasts.models import PodcastEpisode, Podcast, Producer
|
||||||
from scrobbles.admin import ScrobbleInline
|
from scrobbles.admin import ScrobbleInline
|
||||||
|
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ class PodcastAdmin(admin.ModelAdmin):
|
|||||||
ordering = ("name",)
|
ordering = ("name",)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Episode)
|
@admin.register(PodcastEpisode)
|
||||||
class EpisodeAdmin(admin.ModelAdmin):
|
class PodcastEpisodeAdmin(admin.ModelAdmin):
|
||||||
date_hierarchy = "created"
|
date_hierarchy = "created"
|
||||||
list_display = (
|
list_display = (
|
||||||
"title",
|
"title",
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-02-10 18:54
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("scrobbles", "0048_alter_scrobble_media_type"),
|
||||||
|
("podcasts", "0012_alter_episode_genre"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name="Episode",
|
||||||
|
new_name="PodcastEpisode",
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -76,7 +76,7 @@ class Podcast(TimeStampedModel):
|
|||||||
self.cover_image.save(fname, ContentFile(r.content), save=True)
|
self.cover_image.save(fname, ContentFile(r.content), save=True)
|
||||||
|
|
||||||
|
|
||||||
class Episode(ScrobblableMixin):
|
class PodcastEpisode(ScrobblableMixin):
|
||||||
COMPLETION_PERCENT = getattr(settings, "PODCAST_COMPLETION_PERCENT", 90)
|
COMPLETION_PERCENT = getattr(settings, "PODCAST_COMPLETION_PERCENT", 90)
|
||||||
|
|
||||||
podcast = models.ForeignKey(Podcast, on_delete=models.DO_NOTHING)
|
podcast = models.ForeignKey(Podcast, on_delete=models.DO_NOTHING)
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-02-10 18:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("scrobbles", "0047_scrobble_book_koreader_hash"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="scrobble",
|
||||||
|
name="media_type",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("Video", "Video"),
|
||||||
|
("Track", "Track"),
|
||||||
|
("PodcastEpisode", "Podcast episode"),
|
||||||
|
("SportEvent", "Sport event"),
|
||||||
|
("Book", "Book"),
|
||||||
|
("VideoGame", "Video game"),
|
||||||
|
("BoardGame", "Board game"),
|
||||||
|
("GeoLocation", "GeoLocation"),
|
||||||
|
("WebPage", "Web Page"),
|
||||||
|
],
|
||||||
|
default="Video",
|
||||||
|
max_length=14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -19,7 +19,7 @@ from imagekit.processors import ResizeToFit
|
|||||||
from locations.models import GeoLocation
|
from locations.models import GeoLocation
|
||||||
from music.lastfm import LastFM
|
from music.lastfm import LastFM
|
||||||
from music.models import Artist, Track
|
from music.models import Artist, Track
|
||||||
from podcasts.models import Episode
|
from podcasts.models import PodcastEpisode
|
||||||
from profiles.utils import (
|
from profiles.utils import (
|
||||||
end_of_day,
|
end_of_day,
|
||||||
end_of_month,
|
end_of_month,
|
||||||
@ -469,7 +469,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
|
|
||||||
VIDEO = "Video", "Video"
|
VIDEO = "Video", "Video"
|
||||||
TRACK = "Track", "Track"
|
TRACK = "Track", "Track"
|
||||||
PODCAST_EPISODE = "Episode", "Podcast episode"
|
PODCAST_EPISODE = "PodcastEpisode", "Podcast episode"
|
||||||
SPORT_EVENT = "SportEvent", "Sport event"
|
SPORT_EVENT = "SportEvent", "Sport event"
|
||||||
BOOK = "Book", "Book"
|
BOOK = "Book", "Book"
|
||||||
VIDEO_GAME = "VideoGame", "Video game"
|
VIDEO_GAME = "VideoGame", "Video game"
|
||||||
@ -477,20 +477,11 @@ class Scrobble(TimeStampedModel):
|
|||||||
GEO_LOCATION = "GeoLocation", "GeoLocation"
|
GEO_LOCATION = "GeoLocation", "GeoLocation"
|
||||||
WEBPAGE = "WebPage", "Web Page"
|
WEBPAGE = "WebPage", "Web Page"
|
||||||
|
|
||||||
media_ids = {
|
|
||||||
"Track": "track_id",
|
|
||||||
"Video": "video_id",
|
|
||||||
"Episode": "episode_id",
|
|
||||||
"SportEvent": "spoort_event_id",
|
|
||||||
"Track": "track_id",
|
|
||||||
"Track": "track_id",
|
|
||||||
}
|
|
||||||
|
|
||||||
uuid = models.UUIDField(editable=False, **BNULL)
|
uuid = models.UUIDField(editable=False, **BNULL)
|
||||||
video = models.ForeignKey(Video, on_delete=models.DO_NOTHING, **BNULL)
|
video = models.ForeignKey(Video, on_delete=models.DO_NOTHING, **BNULL)
|
||||||
track = models.ForeignKey(Track, on_delete=models.DO_NOTHING, **BNULL)
|
track = models.ForeignKey(Track, on_delete=models.DO_NOTHING, **BNULL)
|
||||||
podcast_episode = models.ForeignKey(
|
podcast_episode = models.ForeignKey(
|
||||||
Episode, on_delete=models.DO_NOTHING, **BNULL
|
PodcastEpisode, on_delete=models.DO_NOTHING, **BNULL
|
||||||
)
|
)
|
||||||
sport_event = models.ForeignKey(
|
sport_event = models.ForeignKey(
|
||||||
SportEvent, on_delete=models.DO_NOTHING, **BNULL
|
SportEvent, on_delete=models.DO_NOTHING, **BNULL
|
||||||
|
|||||||
@ -17,7 +17,7 @@ from music.utils import (
|
|||||||
get_or_create_artist,
|
get_or_create_artist,
|
||||||
get_or_create_track,
|
get_or_create_track,
|
||||||
)
|
)
|
||||||
from podcasts.models import Episode
|
from podcasts.models import PodcastEpisode
|
||||||
from scrobbles.models import Scrobble
|
from scrobbles.models import Scrobble
|
||||||
from scrobbles.utils import convert_to_seconds, parse_mopidy_uri
|
from scrobbles.utils import convert_to_seconds, parse_mopidy_uri
|
||||||
from sports.models import SportEvent
|
from sports.models import SportEvent
|
||||||
@ -52,7 +52,9 @@ def mopidy_scrobble_podcast(
|
|||||||
"mopidy_uri": mopidy_uri,
|
"mopidy_uri": mopidy_uri,
|
||||||
}
|
}
|
||||||
|
|
||||||
episode = Episode.find_or_create(podcast_dict, producer_dict, episode_dict)
|
episode = PodcastEpisode.find_or_create(
|
||||||
|
podcast_dict, producer_dict, episode_dict
|
||||||
|
)
|
||||||
|
|
||||||
# Now we run off a scrobble
|
# Now we run off a scrobble
|
||||||
mopidy_data = {
|
mopidy_data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user