diff --git a/api/funkwhale_api/radios/radios.py b/api/funkwhale_api/radios/radios.py
index 58ac8a2cc..3706cfc9f 100644
--- a/api/funkwhale_api/radios/radios.py
+++ b/api/funkwhale_api/radios/radios.py
@@ -119,6 +119,17 @@ class RandomRadio(SessionRadio):
return qs.filter(artist__content_category="music").order_by("?")
+@registry.register(name="random_library")
+class RandomLibraryRadio(SessionRadio):
+ def get_queryset(self, **kwargs):
+ qs = super().get_queryset(**kwargs)
+ tracks_ids = self.session.user.actor.attributed_tracks.all().values_list(
+ "id", flat=True
+ )
+ query = Q(artist__content_category="music") & Q(pk__in=tracks_ids)
+ return qs.filter(query).order_by("?")
+
+
@registry.register(name="favorites")
class FavoritesRadio(SessionRadio):
def get_queryset_kwargs(self):
@@ -323,6 +334,22 @@ class LessListenedRadio(SessionRadio):
)
+@registry.register(name="less-listened_library")
+class LessListenedLibraryRadio(SessionRadio):
+ def clean(self, instance):
+ instance.related_object = instance.user
+ super().clean(instance)
+
+ def get_queryset(self, **kwargs):
+ qs = super().get_queryset(**kwargs)
+ listened = self.session.user.listenings.all().values_list("track", flat=True)
+ tracks_ids = self.session.user.actor.attributed_tracks.all().values_list(
+ "id", flat=True
+ )
+ query = Q(artist__content_category="music") & Q(pk__in=tracks_ids)
+ return qs.filter(query).exclude(pk__in=listened).order_by("?")
+
+
@registry.register(name="actor-content")
class ActorContentRadio(RelatedObjectRadio):
"""
diff --git a/changes/changelog.d/2007.enhancement b/changes/changelog.d/2007.enhancement
new file mode 100644
index 000000000..f7cc6bf43
--- /dev/null
+++ b/changes/changelog.d/2007.enhancement
@@ -0,0 +1 @@
+Random and less listened radio filter out un-owned content on library section (#2007)
diff --git a/front/src/components/library/Radios.vue b/front/src/components/library/Radios.vue
index c8ad87839..9ebb1a02b 100644
--- a/front/src/components/library/Radios.vue
+++ b/front/src/components/library/Radios.vue
@@ -129,12 +129,23 @@ const paginateOptions = computed(() => sortedUniq([12, 25, 50, paginateBy.value]
v-if="isAuthenticated && hasFavorites"
:type="'favorites'"
/>
-
+
+
+
diff --git a/front/src/store/radios.ts b/front/src/store/radios.ts
index 85b79e5ee..3697a61c5 100644
--- a/front/src/store/radios.ts
+++ b/front/src/store/radios.ts
@@ -52,6 +52,10 @@ const store: Module = {
name: 'Random',
description: "Totally random picks, maybe you'll discover new things?"
},
+ random_library: {
+ name: 'Random',
+ description: 'Random picks from your library, be surprise by yourself ?'
+ },
favorites: {
name: 'Favorites',
description: 'Play your favorites tunes in a never-ending happiness loop.'
@@ -60,6 +64,10 @@ const store: Module = {
name: 'Less listened',
description: "Listen to tracks you usually don't. It's time to restore some balance."
},
+ 'less-listened_library': {
+ name: 'Less listened',
+ description: "Listen to tracks from your library you usually don't. It's time to restore some balance."
+ },
'recently-added': {
name: 'Recently Added',
description: 'Newest content on the network. Get some fresh air.'