Merge branch 'develop'

This commit is contained in:
Georg Krause 2021-03-10 10:26:46 +01:00
commit f63d0efb32
No known key found for this signature in database
GPG Key ID: FD479B9A4D48E632
97 changed files with 19311 additions and 15872 deletions

162
CHANGELOG
View File

@ -10,6 +10,168 @@ This changelog is viewable on the web at https://docs.funkwhale.audio/changelog.
.. towncrier
1.1 (unreleased)
----------------
Upgrade instructions are available at
https://docs.funkwhale.audio/admin/upgrading.html
Enhancements:
- Add number of tracks and discs of an album to API (#1238)
- Add spacing after "Play all" button in playlist view (!1271)
- Added a ListenBrainz plugin to submit listenings
- Added ability to choose fediverse addresses from channel subscription page/podcast screen (#1294)
- Added new search functions to allow users to more easily search for podcasts in the UI.
- Added padding to volume slider to ease mouse control (#1241)
- Logarithmic scale for volume slider (#1222)
- More user-friendly subsonic tokens (#1269)
- Remove manual entry of Import Reference on front-end import (#1284)
- Support AIFF file format (#1243)
Bugfixes:
- "Add check for empty/null covers (#1281)"
- Added an album filter to fix problem where channel entries would show up in the wrong series (#1282)
- Avoid broken Faker version (#1323)
- Changed audio format detection to happen via sniffing and not file extensions (#1274)
- Changed default behaviour of channel entries to use channel artwork if no entry artwork available (#1289)
- Fix delete library modal closing immediately (#1272)
- Fix public shared remote library radio button being disabled (#1292)
- Fixed an issue that prevented disabling plugins
- Fixed an issue where channel albums don't show up in the album search (#1300)
- Fixed an issue where modals would prevent users being able to interact with channels (#1295)
- Update MediaSession metadata for initially loaded track (#1252)
- Update playback position slider also when track is paused (#1266)
- Fixed follows from Pleroma with custom Emoji as Tag by ignoring not supported tag types #1342
- Update pleroma JSON-LD Schema (#1341)
- Pin twisted version to 20.3.0
Contributors to this release (development, documentation, reviews):
Adam Novak
Agate
alemairebe
Alicia Blasco Leon
anonymous
Amaranthe
appzer0
Arne
Asier Iturralde Sarasola
Christian Paul
Ciarán Ainsworth
Daniel
David
Dominik Danelski
Eorn le goéland
Eleos
Erik Duxstad
Esteban
Fred Uggla
Freyja Wildes
Georg Krause
ghose
hellekin
heyarne
interfect
Jess Jing
Johannes H.
jovuit
marzzzello
Meliurwen
Mehdi
Nitai Bezerra da Silva
Philipp Wolfer
Pierre Couy
Porrumentzio
Reg
Robert Kaye
Rubén Cabrera
Silver Fox
Snack Capt
SpcCw
Strom Lin
vicdorke
x
1.1-rc2 (2021-03-01)
--------------------
Upgrade instructions are available at
https://docs.funkwhale.audio/admin/upgrading.html
Bugfixes:
- Fixed follows from Pleroma with custom Emoji as Tag by ignoring not supported tag types #1342
- Update pleroma JSON-LD Schema (#1341)
- Revert fork replacement of http-signature since official package breaks federation
- Pin twisted version to 20.3.0
1.1-rc1 (2021-02-24)
--------------------
Upgrade instructions are available at
https://docs.funkwhale.audio/admin/upgrading.html
Enhancements:
- Add number of tracks and discs of an album to API (#1238)
- Add spacing after "Play all" button in playlist view (!1271)
- Added a ListenBrainz plugin to submit listenings
- Added ability to choose fediverse addresses from channel subscription page/podcast screen (#1294)
- Added new search functions to allow users to more easily search for podcasts in the UI.
- Added padding to volume slider to ease mouse control (#1241)
- Logarithmic scale for volume slider (#1222)
- More user-friendly subsonic tokens (#1269)
- Remove manual entry of Import Reference on front-end import (#1284)
- Replaced forked http-signature dependency with official package (#876)
- Support AIFF file format (#1243)
Bugfixes:
- "Add check for empty/null covers (#1281)"
- Added an album filter to fix problem where channel entries would show up in the wrong series (#1282)
- Avoid broken Faker version (#1323)
- Changed audio format detection to happen via sniffing and not file extensions (#1274)
- Changed default behaviour of channel entries to use channel artwork if no entry artwork available (#1289)
- Fix delete library modal closing immediately (#1272)
- Fix public shared remote library radio button being disabled (#1292)
- Fixed an issue that prevented disabling plugins
- Fixed an issue where channel albums don't show up in the album search (#1300)
- Fixed an issue where modals would prevent users being able to interact with channels (#1295)
- Update MediaSession metadata for initially loaded track (#1252)
- Update playback position slider also when track is paused (#1266)
Contributors to this release (development, documentation, reviews):
- Reg
- hellekin
- Esteban
- Freyja Wildes
- Amaranthe
- Eleos
- Johannes H.
- Mehdi
- Adam Novak
- Agate
- Christian Paul
- Ciarán Ainsworth
- Erik Duxstad
- Fred Uggla
- Georg Krause
- heyarne
- interfect
- jovuit
- Nitai Bezerra da Silva
- Philipp Wolfer
- Pierre Couy
- Robert Kaye
- Strom Lin
1.0.1 (2020-10-31)
------------------

View File

@ -199,7 +199,7 @@ Once everything is up, you can access the various funkwhale's components:
- The Vue webapp, on http://localhost:8000
- The API, on http://localhost:8000/api/v1/
- The django admin, on http://localhost:800/api/admin/
- The django admin, on http://localhost:8000/api/admin/
Stopping everything
^^^^^^^^^^^^^^^^^^^
@ -687,7 +687,7 @@ useful when testing components that depend on each other:
def test_downgrade_not_superuser_skips_email(factories, mocker):
mocked_notify = mocker.patch('funkwhale_api.myapp.notifications.notify')
user = factories['users.User'](is_superuser=True)
user = factories['users.User'](is_superuser=False)
users.downgrade_user(user)
# here, we ensure no email was sent

View File

@ -12,15 +12,7 @@ LICENSE: AGPL3
Getting help
------------
We offer various Matrix.org rooms to discuss about Funkwhale:
- `#funkwhale:matrix.org <https://matrix.to/#/#funkwhale:matrix.org>`_ for general questions about funkwhale
- `#funkwhale-dev:matrix.org <https://matrix.to/#/#funkwhale-dev:matrix.org>`_ for development-focused discussion
Please join those rooms if you have any questions!
You can also contact `@funkwhale@mastodon.eliotberriot.com <https://mastodon.eliotberriot.com/@funkwhale>`_ on the fediverse.
There are several places to get help or get in touch with other members of the community: https://funkwhale.audio/community/
Contribute
----------
@ -33,7 +25,7 @@ Security issues and vulnerabilities
If you found a vulnerability in Funkwhale, please report it on our Gitlab instance at `https://dev.funkwhale.audio/funkwhale/funkwhale/-/issues`_, ensuring
you have checked the ``This issue is confidential and should only be visible to team members with at least Reporter access.
`` box.
`` box.
This will ensure only maintainers and developpers have access to the vulnerability. Thank you for your help!

View File

@ -94,6 +94,7 @@ Path to a directory containing Funkwhale plugins. These will be imported at runt
sys.path.append(FUNKWHALE_PLUGINS_PATH)
CORE_PLUGINS = [
"funkwhale_api.contrib.scrobbler",
"funkwhale_api.contrib.listenbrainz",
]
LOAD_CORE_PLUGINS = env.bool("FUNKWHALE_LOAD_CORE_PLUGINS", default=True)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__version__ = "1.0.1"
__version__ = "1.1"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num

View File

@ -11,7 +11,7 @@ class APIAutenticationRequired(types.BooleanPreference):
verbose_name = "API Requires authentication"
default = True
help_text = (
"If disabled, anonymous users will be able to query the API"
"If disabled, anonymous users will be able to query the API "
"and access music data (as well as other data exposed in the API "
"without specific permissions)."
)

View File

@ -0,0 +1,168 @@
# Copyright (c) 2018 Philipp Wolfer <ph.wolfer@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import json
import logging
import ssl
import time
from http.client import HTTPSConnection
HOST_NAME = "api.listenbrainz.org"
PATH_SUBMIT = "/1/submit-listens"
SSL_CONTEXT = ssl.create_default_context()
class Track:
"""
Represents a single track to submit.
See https://listenbrainz.readthedocs.io/en/latest/dev/json.html
"""
def __init__(self, artist_name, track_name, release_name=None, additional_info={}):
"""
Create a new Track instance
@param artist_name as str
@param track_name as str
@param release_name as str
@param additional_info as dict
"""
self.artist_name = artist_name
self.track_name = track_name
self.release_name = release_name
self.additional_info = additional_info
@staticmethod
def from_dict(data):
return Track(
data["artist_name"],
data["track_name"],
data.get("release_name", None),
data.get("additional_info", {}),
)
def to_dict(self):
return {
"artist_name": self.artist_name,
"track_name": self.track_name,
"release_name": self.release_name,
"additional_info": self.additional_info,
}
def __repr__(self):
return "Track(%s, %s)" % (self.artist_name, self.track_name)
class ListenBrainzClient:
"""
Submit listens to ListenBrainz.org.
See https://listenbrainz.readthedocs.io/en/latest/dev/api.html
"""
def __init__(self, user_token, logger=logging.getLogger(__name__)):
self.__next_request_time = 0
self.user_token = user_token
self.logger = logger
def listen(self, listened_at, track):
"""
Submit a listen for a track
@param listened_at as int
@param entry as Track
"""
payload = _get_payload(track, listened_at)
return self._submit("single", [payload])
def playing_now(self, track):
"""
Submit a playing now notification for a track
@param track as Track
"""
payload = _get_payload(track)
return self._submit("playing_now", [payload])
def import_tracks(self, tracks):
"""
Import a list of tracks as (listened_at, Track) pairs
@param track as [(int, Track)]
"""
payload = _get_payload_many(tracks)
return self._submit("import", payload)
def _submit(self, listen_type, payload, retry=0):
self._wait_for_ratelimit()
self.logger.debug("ListenBrainz %s: %r", listen_type, payload)
data = {"listen_type": listen_type, "payload": payload}
headers = {
"Authorization": "Token %s" % self.user_token,
"Content-Type": "application/json",
}
body = json.dumps(data)
conn = HTTPSConnection(HOST_NAME, context=SSL_CONTEXT)
conn.request("POST", PATH_SUBMIT, body, headers)
response = conn.getresponse()
response_text = response.read()
try:
response_data = json.loads(response_text)
except json.decoder.JSONDecodeError:
response_data = response_text
self._handle_ratelimit(response)
log_msg = "Response %s: %r" % (response.status, response_data)
if response.status == 429 and retry < 5: # Too Many Requests
self.logger.warning(log_msg)
return self._submit(listen_type, payload, retry + 1)
elif response.status == 200:
self.logger.debug(log_msg)
else:
self.logger.error(log_msg)
return response
def _wait_for_ratelimit(self):
now = time.time()
if self.__next_request_time > now:
delay = self.__next_request_time - now
self.logger.debug("Rate limit applies, delay %d", delay)
time.sleep(delay)
def _handle_ratelimit(self, response):
remaining = int(response.getheader("X-RateLimit-Remaining", 0))
reset_in = int(response.getheader("X-RateLimit-Reset-In", 0))
self.logger.debug("X-RateLimit-Remaining: %i", remaining)
self.logger.debug("X-RateLimit-Reset-In: %i", reset_in)
if remaining == 0:
self.__next_request_time = time.time() + reset_in
def _get_payload_many(tracks):
payload = []
for (listened_at, track) in tracks:
data = _get_payload(track, listened_at)
payload.append(data)
return payload
def _get_payload(track, listened_at=None):
data = {"track_metadata": track.to_dict()}
if listened_at is not None:
data["listened_at"] = listened_at
return data

View File

@ -0,0 +1,41 @@
from config import plugins
from .funkwhale_startup import PLUGIN
from .client import ListenBrainzClient, Track
@plugins.register_hook(plugins.LISTENING_CREATED, PLUGIN)
def submit_listen(listening, conf, **kwargs):
user_token = conf["user_token"]
if not user_token:
return
logger = PLUGIN["logger"]
logger.info("Submitting listen to ListenBrainz")
client = ListenBrainzClient(user_token=user_token, logger=logger)
track = get_track(listening.track)
client.listen(int(listening.creation_date.timestamp()), track)
def get_track(track):
artist = track.artist.name
title = track.title
album = None
additional_info = {
"listening_from": "Funkwhale",
"tracknumber": track.position,
"discnumber": track.disc_number,
}
if track.mbid:
additional_info["recording_mbid"] = str(track.mbid)
if track.album:
if track.album.title:
album = track.album.title
if track.album.mbid:
additional_info["release_mbid"] = str(track.album.mbid)
if track.artist.mbid:
additional_info["artist_mbids"] = [str(track.artist.mbid)]
return Track(artist, title, album, additional_info)

View File

@ -0,0 +1,18 @@
from config import plugins
PLUGIN = plugins.get_plugin_config(
name="listenbrainz",
label="ListenBrainz",
description="A plugin that allows you to submit your listens to ListenBrainz.",
version="0.1",
user=True,
conf=[
{
"name": "user_token",
"type": "text",
"label": "Your ListenBrainz user token",
"help": "You can find your user token in your ListenBrainz profile at https://listenbrainz.org/profile/",
}
],
)

View File

@ -316,8 +316,8 @@ CONTEXTS = [
"shortId": "LITEPUB",
"contextUrl": None,
"documentUrl": "http://litepub.social/ns",
# from https://git.pleroma.social/pleroma/pleroma/-/blob/release/2.2.3/priv/static/schemas/litepub-0.1.jsonld
"document": {
# from https://ap.thequietplace.social/schemas/litepub-0.1.jsonld
"@context": {
"Emoji": "toot:Emoji",
"Hashtag": "as:Hashtag",
@ -326,6 +326,7 @@ CONTEXTS = [
"conversation": {"@id": "ostatus:conversation", "@type": "@id"},
"discoverable": "toot:discoverable",
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"capabilities": "litepub:capabilities",
"ostatus": "http://ostatus.org#",
"schema": "http://schema.org#",
"toot": "http://joinmastodon.org/ns#",
@ -340,6 +341,7 @@ CONTEXTS = [
"@type": "@id",
},
"EmojiReact": "litepub:EmojiReact",
"ChatMessage": "litepub:ChatMessage",
"alsoKnownAs": {"@id": "as:alsoKnownAs", "@type": "@id"},
}
},

View File

@ -258,9 +258,15 @@ class ActorSerializer(jsonld.JsonLdSerializer):
)
attributedTo = serializers.URLField(max_length=500, required=False)
tags = serializers.ListField(
child=TagSerializer(), min_length=0, required=False, allow_null=True
)
tags = serializers.ListField(min_length=0, required=False, allow_null=True)
def validate_tags(self, tags):
valid_tags = []
for tag in tags:
s = TagSerializer(data=tag)
if s.is_valid():
valid_tags.append(s.validated_data)
return valid_tags
category = serializers.CharField(required=False)
# languages = serializers.Char(

View File

@ -27,7 +27,7 @@ class MusicCacheDuration(types.IntPreference):
default = 60 * 24 * 7
verbose_name = "Transcoding cache duration"
help_text = (
"How much minutes do you want to keep a copy of transcoded tracks "
"How many minutes do you want to keep a copy of transcoded tracks "
"on the server? Transcoded files that were not listened in this interval "
"will be erased and retranscoded on the next listening."
)

View File

@ -103,6 +103,7 @@ class ArtistFilter(
playable = filters.BooleanFilter(field_name="_", method="filter_playable")
has_albums = filters.BooleanFilter(field_name="_", method="filter_has_albums")
tag = TAG_FILTER
content_category = filters.CharFilter("content_category")
scope = common_filters.ActorScopeFilter(
actor_field="tracks__uploads__library__actor",
distinct=True,
@ -257,6 +258,7 @@ class AlbumFilter(
search_fields=["title", "artist__name"],
fts_search_fields=["body_text", "artist__body_text"],
)
content_category = filters.CharFilter("artist__content_category")
tag = TAG_FILTER
scope = common_filters.ActorScopeFilter(
actor_field="tracks__uploads__library__actor",

View File

@ -17,6 +17,7 @@ from django.core.files import File
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q
from django.db.utils import IntegrityError
from django.utils import timezone
from rest_framework import serializers
@ -832,6 +833,13 @@ def check_upload(stdout, upload):
except serializers.ValidationError as e:
stdout.write(" Invalid metadata: {}".format(e))
return
except IntegrityError:
stdout.write(
" Duplicate key violation for metadata. Skipping...\n{}".format(
upload.source
)
)
return
else:
upload.checksum = checksum
upload.save(update_fields=["checksum"])

View File

@ -253,7 +253,7 @@ CONF = {
"comment": {"field": "comment"},
},
},
"MP3": {
"ID3": {
"getter": get_id3_tag,
"clean_pictures": clean_id3_pictures,
"fields": {
@ -331,6 +331,9 @@ CONF = {
},
}
CONF["MP3"] = CONF["ID3"]
CONF["AIFF"] = CONF["ID3"]
ALL_FIELDS = [
"position",
"disc_number",

View File

@ -20,6 +20,7 @@ from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from django.urls import reverse
from django.utils import timezone
from django.db.models import Prefetch, Count
from funkwhale_api import musicbrainz
from funkwhale_api.common import fields
@ -420,7 +421,13 @@ def import_album(v):
class TrackQuerySet(common_models.LocalFromFidQuerySet, models.QuerySet):
def for_nested_serialization(self):
return self.prefetch_related(
"artist", "album__artist", "album__attachment_cover"
"artist",
Prefetch(
"album",
queryset=Album.objects.select_related(
"artist", "attachment_cover"
).annotate(_prefetched_tracks_count=Count("tracks")),
),
)
def annotate_playable_by_actor(self, actor):
@ -855,8 +862,7 @@ class Upload(models.Model):
if not input:
return
input_format = utils.MIMETYPE_TO_EXTENSION[self.mimetype]
audio = pydub.AudioSegment.from_file(input, format=input_format)
audio = pydub.AudioSegment.from_file(input)
return audio
def save(self, **kwargs):

View File

@ -227,6 +227,10 @@ class AlbumSerializer(OptionalDescriptionMixin, serializers.Serializer):
class TrackAlbumSerializer(serializers.ModelSerializer):
artist = serializers.SerializerMethodField()
cover = cover_field
tracks_count = serializers.SerializerMethodField()
def get_tracks_count(self, o):
return getattr(o, "_prefetched_tracks_count", len(o.tracks.all()))
class Meta:
model = models.Album
@ -240,6 +244,7 @@ class TrackAlbumSerializer(serializers.ModelSerializer):
"cover",
"creation_date",
"is_local",
"tracks_count",
)
def get_artist(self, o):

View File

@ -59,6 +59,10 @@ AUDIO_EXTENSIONS_AND_MIMETYPE = [
("m4a", "audio/x-m4a"),
("flac", "audio/x-flac"),
("flac", "audio/flac"),
("aif", "audio/aiff"),
("aif", "audio/x-aiff"),
("aiff", "audio/aiff"),
("aiff", "audio/x-aiff"),
]
EXTENSION_TO_MIMETYPE = {ext: mt for ext, mt in AUDIO_EXTENSIONS_AND_MIMETYPE}
@ -101,7 +105,7 @@ def get_actor_from_request(request):
return actor
def transcode_file(input, output, input_format, output_format, **kwargs):
def transcode_file(input, output, input_format=None, output_format="mp3", **kwargs):
with input.open("rb"):
audio = pydub.AudioSegment.from_file(input, format=input_format)
return transcode_audio(audio, output, output_format, **kwargs)

View File

@ -2,6 +2,7 @@
from __future__ import absolute_import, unicode_literals
import datetime
import os
import random
import string
import uuid
@ -29,9 +30,14 @@ from funkwhale_api.federation import models as federation_models
from funkwhale_api.federation import utils as federation_utils
def get_token(length=30):
choices = string.ascii_lowercase + string.ascii_uppercase + "0123456789"
return "".join(random.choice(choices) for i in range(length))
def get_token(length=5):
wordlist_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "wordlist.txt"
)
with open(wordlist_path, "r") as f:
words = f.readlines()
phrase = "".join(random.choice(words) for i in range(length))
return phrase.replace("\n", "-").rstrip("-")
PERMISSIONS_CONFIGURATION = {

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ gunicorn~=20.0.0
cryptography~=2.9.0
# requests-http-signature==0.0.3
# clone until the branch is merged and released upstream
git+https://github.com/EliotBerriot/requests-http-signature.git@signature-header-support
git+https://github.com/agateblue/requests-http-signature.git@signature-header-support
django-cleanup~=5.0.0
requests~=2.24.0
pyOpenSSL~=19.1.0
@ -70,5 +70,8 @@ click~=7.1.0
service_identity~=18.1.0
markdown~=3.2.0
bleach~=3.1.0
feedparser==6.0.0b3
watchdog~=0.10.0
feedparser~=6.0.0
watchdog~=1.0.2
## Pin third party dependency to avoid issue with latest version
twisted==20.3.0

View File

@ -10,3 +10,4 @@ pytest-randomly~=3.4.0
pytest-sugar~=0.9.0
requests-mock~=1.8.0
#pytest-profiling<1.4
faker!=5.5.0

View File

@ -4,6 +4,75 @@ from funkwhale_api.federation import routes
from funkwhale_api.federation import serializers
def test_pleroma_actor_from_ap_with_tags(factories):
payload = {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://test.federation/schemas/litepub-0.1.jsonld",
{"@language": "und"},
],
"endpoints": {
"oauthAuthorizationEndpoint": "https://test.federation/oauth/authorize",
"oauthRegistrationEndpoint": "https://test.federation/api/v1/apps",
"oauthTokenEndpoint": "https://test.federation/oauth/token",
"sharedInbox": "https://test.federation/inbox",
"uploadMedia": "https://test.federation/api/ap/upload_media",
},
"followers": "https://test.federation/internal/fetch/followers",
"following": "https://test.federation/internal/fetch/following",
"id": "https://test.federation/internal/fetch",
"inbox": "https://test.federation/internal/fetch/inbox",
"invisible": True,
"manuallyApprovesFollowers": False,
"name": "Pleroma",
"preferredUsername": "internal.fetch",
"publicKey": {
"id": "https://test.federation/internal/fetch#main-key",
"owner": "https://test.federation/internal/fetch",
"publicKeyPem": "PEM",
},
"summary": "An internal service actor for this Pleroma instance. No user-serviceable parts inside.",
"type": "Application",
"url": "https://test.federation/internal/fetch",
"tag": [
{
"type": "Hashtag",
"href": "https://test.federation/explore/funkwhale",
"name": "#funkwhale",
},
{
"type": "Emoji",
"id": "https://test.federation/emoji/test/custom.png",
"name": ":custom:",
},
],
}
serializer = serializers.ActorSerializer(data=payload)
assert serializer.is_valid(raise_exception=True)
actor = serializer.save()
assert actor.fid == payload["id"]
assert actor.url == payload["url"]
assert actor.inbox_url == payload["inbox"]
assert actor.shared_inbox_url == payload["endpoints"]["sharedInbox"]
assert actor.outbox_url is None
assert actor.following_url == payload["following"]
assert actor.followers_url == payload["followers"]
assert actor.followers_url == payload["followers"]
assert actor.type == payload["type"]
assert actor.preferred_username == payload["preferredUsername"]
assert actor.name == payload["name"]
assert actor.summary_obj.text == payload["summary"]
assert actor.summary_obj.content_type == "text/html"
assert actor.fid == payload["url"]
assert actor.manually_approves_followers is payload["manuallyApprovesFollowers"]
assert actor.private_key is None
assert actor.public_key == payload["publicKey"]["publicKeyPem"]
assert actor.domain_id == "test.federation"
def test_pleroma_actor_from_ap(factories):
payload = {

BIN
api/tests/music/test.aiff Normal file

Binary file not shown.

View File

@ -150,10 +150,38 @@ def test_can_get_metadata_from_id3_mp3_file(field, value):
assert str(data.get(field)) == value
@pytest.mark.parametrize(
"field,value",
[
("title", "Bend"),
("artist", "Binärpilot"),
("album_artist", "Binärpilot"),
# ("artists", "Binärpilot; Another artist"), # FW does not properly extract multi-value artists from ID3
("album", "You Can't Stop Da Funk"),
("date", "2006-02-07"),
("position", "2/4"),
("disc_number", "1/1"),
("musicbrainz_albumid", "ce40cdb1-a562-4fd8-a269-9269f98d4124"),
("mbid", "f269d497-1cc0-4ae4-a0c4-157ec7d73fcb"),
("musicbrainz_artistid", "9c6bddde-6228-4d9f-ad0d-03f6fcb19e13"),
("musicbrainz_albumartistid", "9c6bddde-6228-4d9f-ad0d-03f6fcb19e13"),
("license", "https://creativecommons.org/licenses/by-nc-nd/2.5/"),
("copyright", "Someone"),
("comment", "Hello there"),
],
)
def test_can_get_metadata_from_id3_aiff_file(field, value):
path = os.path.join(DATA_DIR, "test.aiff")
data = metadata.Metadata(path)
assert str(data.get(field)) == value
@pytest.mark.parametrize(
"name",
[
"test.mp3",
"test.aiff",
"with_other_picture.mp3",
"sample.flac",
"with_cover.ogg",

View File

@ -196,6 +196,35 @@ def test_album_serializer(factories, to_api_date):
assert serializer.data == expected
def test_track_album_serializer(factories, to_api_date):
actor = factories["federation.Actor"]()
track1 = factories["music.Track"](
position=2, album__attributed_to=actor, album__with_cover=True
)
factories["music.Track"](position=1, album=track1.album)
album = track1.album
expected = {
"id": album.id,
"fid": album.fid,
"mbid": str(album.mbid),
"title": album.title,
"artist": serializers.serialize_artist_simple(album.artist),
"creation_date": to_api_date(album.creation_date),
"is_playable": False,
"cover": common_serializers.AttachmentSerializer(album.attachment_cover).data,
"release_date": to_api_date(album.release_date),
"tracks_count": 2,
"is_local": album.is_local,
"tags": [],
"attributed_to": federation_serializers.APIActorSerializer(actor).data,
}
serializer = serializers.AlbumSerializer(
album.__class__.objects.with_tracks_count().get(pk=album.pk)
)
assert serializer.data == expected
def test_track_serializer(factories, to_api_date):
actor = factories["federation.Actor"]()
upload = factories["music.Upload"](

View File

@ -1,6 +1,7 @@
import os
import pathlib
import pytest
import tempfile
from funkwhale_api.music import utils
@ -28,6 +29,7 @@ def test_guess_mimetype_try_using_extension_if_fail(wrong, factories, mocker):
("sample.flac", {"bitrate": 1608000, "length": 0.001}),
("test.mp3", {"bitrate": 8000, "length": 267.70285714285717}),
("test.ogg", {"bitrate": 112000, "length": 1}),
("test.opus", {"bitrate": 0, "length": 1}), # This Opus file lacks a bitrate
],
)
def test_get_audio_file_data(name, expected):
@ -109,3 +111,22 @@ def test_get_dirs_and_files(path, expected, tmpdir):
(root_path / "System" / "file.ogg").touch()
assert utils.browse_dir(root_path, path) == expected
@pytest.mark.parametrize(
"name, expected",
[
("sample.flac", {"bitrate": 128000, "length": 0}),
("test.mp3", {"bitrate": 16000, "length": 268}),
("test.ogg", {"bitrate": 128000, "length": 1}),
("test.opus", {"bitrate": 128000, "length": 1}),
],
)
def test_transcode_file(name, expected):
path = pathlib.Path(os.path.join(DATA_DIR, name))
with tempfile.NamedTemporaryFile() as dest:
utils.transcode_file(path, pathlib.Path(dest.name))
with open(dest.name, "rb") as f:
result = {k: round(v) for k, v in utils.get_audio_file_data(f).items()}
assert result == expected

View File

@ -88,7 +88,7 @@ services:
volumes:
- "./nginx/funkwhale.template:/etc/nginx/conf.d/funkwhale.template:ro"
- "./nginx/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf:ro"
- "${MUSIC_DIRECTORY_SERVE_PATH-/srv/funkwhale/data/music}:${MUSIC_DIRECTORY_SERVE_PATH-/srv/funkwhale/data/music}:ro"
- "${MUSIC_DIRECTORY_SERVE_PATH-/srv/funkwhale/data/music}:${MUSIC_DIRECTORY_PATH-/music}:ro"
- "${MEDIA_ROOT}:${MEDIA_ROOT}:ro"
- "${STATIC_ROOT}:${STATIC_ROOT}:ro"
- "${FUNKWHALE_FRONTEND_PATH}:/frontend:ro"

View File

@ -154,7 +154,7 @@ services:
- "8001:8001"
api-docs:
image: swaggerapi/swagger-ui:v3.26.0
image: swaggerapi/swagger-ui:v3.37.2
environment:
- "API_URL=/swagger.yml"
ports:

View File

@ -67,7 +67,7 @@ get details::
.. note::
At the moment, only Flac, OGG/Vorbis and MP3 files with ID3 tags are supported
At the moment, only Flac, OGG/Vorbis and MP3 or AIFF files with ID3 tags are supported

View File

@ -164,6 +164,7 @@ match what is described in :doc:`/installation/debian`:
sudo -u funkwhale unzip "api-$FUNKWHALE_VERSION.zip" -d extracted
sudo -u funkwhale rm -rf api/ && sudo -u funkwhale mv extracted/api .
sudo -u funkwhale rm -rf extracted
sudo -u funkwhale rm api-$FUNKWHALE_VERSION.zip
# update os dependencies
sudo api/install_os_dependencies.sh install

View File

@ -57,7 +57,7 @@ Attachment:
example: 2787000
description: "Size of the file, in bytes"
mimetype:
$ref: "./properties.yml#image_mimetype"
$ref: "./properties.yml#/image_mimetype"
creation_date:
type: "string"
format: "date-time"
@ -121,7 +121,7 @@ BaseArtist:
properties:
mbid:
required: false
$ref: "./properties.yml#mbid"
$ref: "./properties.yml#/mbid"
id:
type: "integer"
format: "int64"
@ -160,7 +160,7 @@ BaseAlbum:
properties:
mbid:
required: false
$ref: "./properties.yml#mbid"
$ref: "./properties.yml#/mbid"
id:
type: "integer"
format: "int64"
@ -249,11 +249,11 @@ ChannelCreate:
example: "aliceandbob"
description: "The username to associate with the channel, for use over federation. This cannot be changed afterwards."
description:
$ref: "./properties.yml#description"
$ref: "./properties.yml#/description"
tags:
$ref: "./properties.yml#tags"
$ref: "./properties.yml#/tags"
content_category:
$ref: "./properties.yml#content_category"
$ref: "./properties.yml#/content_category"
cover:
type: string
format: uuid
@ -267,9 +267,9 @@ ChannelUpdate:
example: "A short, public name for the channel"
maxLength: 255
description:
$ref: "./properties.yml#description"
$ref: "./properties.yml#/description"
tags:
$ref: "./properties.yml#tags"
$ref: "./properties.yml#/tags"
cover:
type: string
format: uuid
@ -283,7 +283,7 @@ Channel:
type: "string"
format: "uuid"
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
artist:
$ref: "#/BaseArtist"
attributed_to:
@ -299,12 +299,12 @@ Subscription:
approved:
type: "string"
fid:
$ref: "./properties.yml#fid"
$ref: "./properties.yml#/fid"
uuid:
type: "string"
format: "uuid"
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
channel:
$ref: "#/Channel"
@ -402,7 +402,7 @@ BaseTrack:
properties:
mbid:
required: false
$ref: "./properties.yml#mbid"
$ref: "./properties.yml#/mbid"
id:
type: "integer"
format: "int64"
@ -472,7 +472,7 @@ ListeningCreate:
format: "int64"
example: 66
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
track:
type: "integer"
format: "int64"
@ -486,7 +486,7 @@ Listening:
format: "int64"
example: 66
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
track:
$ref: "#/Track"
actor:
@ -529,7 +529,7 @@ Upload:
example: 128000
description: "Bitrate of the file, in bytes/s"
mimetype:
$ref: "./properties.yml#audio_mimetype"
$ref: "./properties.yml#/audio_mimetype"
extension:
type: string
example: "ogg"
@ -556,7 +556,7 @@ OwnedLibraryCreate:
type: "string"
example: "Lots of interesting content"
privacy_level:
$ref: "./properties.yml#privacy_level"
$ref: "./properties.yml#/privacy_level"
OwnedLibrary:
type: "object"
@ -565,7 +565,7 @@ OwnedLibrary:
type: string
format: uuid
fid:
$ref: "./properties.yml#fid"
$ref: "./properties.yml#/fid"
name:
type: "string"
example: "My Creative Commons library"
@ -573,9 +573,9 @@ OwnedLibrary:
type: "string"
example: "All content is under CC-BY"
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
privacy_level:
$ref: "./properties.yml#privacy_level"
$ref: "./properties.yml#/privacy_level"
uploads_count:
type: "integer"
format: "int64"
@ -593,7 +593,7 @@ OwnedUpload:
- type: "object"
properties:
import_status:
$ref: "./properties.yml#import_status"
$ref: "./properties.yml#/import_status"
track:
$ref: "#/Track"
library:
@ -629,14 +629,14 @@ Playlist:
description: Number of tracks in the playlist
example: 76
privacy_level:
$ref: "./properties.yml#privacy_level"
$ref: "./properties.yml#/privacy_level"
actor:
$ref: "#/Actor"
description: Actor owning the playlist
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
modification_date:
$ref: "./properties.yml#modification_date"
$ref: "./properties.yml#/modification_date"
PlaylistCreate:
@ -647,7 +647,7 @@ PlaylistCreate:
description: Name of the playlist
example: "Move your body"
privacy_level:
$ref: "./properties.yml#privacy_level"
$ref: "./properties.yml#/privacy_level"
PlaylistTrack:
type: "object"
@ -662,7 +662,7 @@ PlaylistTrack:
example: 16
description: Position of the track in the playlist
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
track:
$ref: "#/Track"
@ -675,7 +675,7 @@ ImportMetadata:
example: "My Track"
required: true
mbid:
$ref: "./properties.yml#mbid"
$ref: "./properties.yml#/mbid"
required: false
copyright:
type: "string"
@ -688,7 +688,7 @@ ImportMetadata:
required: false
description: A license code, as returned by /api/v1/licenses
tags:
$ref: "./properties.yml#tags"
$ref: "./properties.yml#/tags"
required: false
position:
description: "Position of the track in the album or channel"
@ -708,7 +708,7 @@ TrackFavorite:
user:
$ref: "#/User"
creation_date:
$ref: "./properties.yml#creation_date"
$ref: "./properties.yml#/creation_date"
User:
type: "object"
properties:
@ -750,7 +750,7 @@ Me:
type: "string"
format: "date-time"
privacy_level:
$ref: "./properties.yml#privacy_level"
$ref: "./properties.yml#/privacy_level"
description: Default privacy-level associated with the user account
quota_status:
$ref: "#/QuotaStatus"
@ -771,7 +771,7 @@ Me:
The token expires after 3 days by default.
QuotaStatus:
QuotaStatus:
type: "object"
properties:
max:

View File

@ -1,5 +1,5 @@
ChannelOrdering:
- $ref: "#/parameters/Ordering"
- $ref: "#/Ordering"
- default: "-creation_date"
schema:
required: false
@ -118,6 +118,19 @@ Scope:
- "actor:alice@example.com"
- "domain:example.com"
ContentCategory:
name: "content_category"
in: "query"
description: |
Limits the results to those whose artist content type matches the query.
schema:
required: false
type: "string"
enum:
- "podcast"
- "music"
Search:
name: "q"
in: "query"

View File

@ -1,6 +1,6 @@
#!/bin/bash -eux
SWAGGER_VERSION="3.13.6"
SWAGGER_VERSION="3.37.2"
TARGET_PATH=${TARGET_PATH-"swagger"}
rm -rf $TARGET_PATH /tmp/swagger-ui
git clone --branch="v$SWAGGER_VERSION" --depth=1 "https://github.com/swagger-api/swagger-ui.git" /tmp/swagger-ui

View File

@ -1,4 +1,4 @@
openapi: "3.0.2"
openapi: "3.0.3"
info:
description: |
Interactive documentation for [Funkwhale](https://funkwhale.audio) API.
@ -140,7 +140,6 @@ components:
description: This API uses OAuth 2 with the Authorization Code flow. You can register an app using the /oauth/apps/ endpoint.
flows:
authorizationCode:
# Swagger doesn't support relative URLs yet (cf https://github.com/swagger-api/swagger-ui/pull/5244)
authorizationUrl: /authorize
tokenUrl: /api/v1/oauth/token/
refreshUrl: /api/v1/oauth/token/
@ -408,6 +407,7 @@ paths:
- $ref: "./api/parameters.yml#/PageSize"
- $ref: "./api/parameters.yml#/Related"
- $ref: "./api/parameters.yml#/Scope"
- $ref: "./api/parameters.yml#/ContentCategory"
responses:
200:
content:
@ -506,6 +506,7 @@ paths:
- $ref: "./api/parameters.yml#/PageSize"
- $ref: "./api/parameters.yml#/Related"
- $ref: "./api/parameters.yml#/Scope"
- $ref: "./api/parameters.yml#/ContentCategory"
responses:
200:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"description": "Funkwhale front-end",
"author": "Eliot Berriot <contact@eliotberriot.com>",
"scripts": {
"serve": "vue-cli-service serve --port ${VUE_PORT:-8000} --host ${VUE_HOST:-0.0.0.0}",
"serve": "[ ! -d src/translations ] && npm run i18n-compile; vue-cli-service serve --port ${VUE_PORT:-8080} --host ${VUE_HOST:-0.0.0.0}",
"build": "scripts/i18n-compile.sh && vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",

32
front/src/audio/volume.js Normal file
View File

@ -0,0 +1,32 @@
// Provides functions to convert between linear and logarithmic volume scales.
// The logarithmic volume from the UI is converted to a linear volume with a
// logarithmic function like exp(b*x)/a.
// Compare https://www.dr-lex.be/info-stuff/volumecontrols.html for how the
// values for a and b got derived.
const PARAM_A = 1000
const PARAM_B = Math.log(1000) // ~ 6.908
function toLinearVolumeScale(v) {
// Or as approximation:
// return Math.pow(v, 4)
if (v == 0.0) {
return 0.0
}
return Math.min(Math.exp(PARAM_B * v) / PARAM_A, 1.0)
}
function toLogarithmicVolumeScale(v) {
// Or as approximation:
// return Math.exp(Math.log(v) / 4)
if (v == 0.0) {
return 0.0
}
return Math.log(v * PARAM_A) / PARAM_B
}
exports.toLinearVolumeScale = toLinearVolumeScale
exports.toLogarithmicVolumeScale = toLogarithmicVolumeScale

View File

@ -88,7 +88,7 @@
<translate translate-context="Footer/*/Title/Short">About Funkwhale</translate>
</h3>
<p v-translate translate-context="Content/Home/Paragraph">This pod runs Funkwhale, a community-driven project that lets you listen and share music and audio within a decentralized, open network.</p>
<p v-translate translate-context="Content/Home/Paragraph">Funkwhale is free and developped by a friendly community of volunteers.</p>
<p v-translate translate-context="Content/Home/Paragraph">Funkwhale is free and developed by a friendly community of volunteers.</p>
<a target="_blank" rel="noopener" href="https://funkwhale.audio">
<i class="external alternate icon"></i>
<translate translate-context="Content/Home/Link">Visit funkwhale.audio</translate>

View File

@ -15,10 +15,10 @@
{{ currentTrack.title }}
</router-link>
<div class="sub header ellipsis">
<router-link class="discrete link artist" :to="{name: 'library.artists.detail', params: {id: currentTrack.artist.id }}">
{{ currentTrack.artist.name }}</router-link> <template v-if="currentTrack.album">/<router-link class="discrete link album" :to="{name: 'library.albums.detail', params: {id: currentTrack.album.id }}">
{{ currentTrack.album.title }}
</router-link></template>
<router-link class="discrete link artist" :to="{name: 'library.artists.detail', params: {id: currentTrack.artist.id }}">{{ currentTrack.artist.name }}</router-link>
<template v-if="currentTrack.album"> /
<router-link class="discrete link album" :to="{name: 'library.albums.detail', params: {id: currentTrack.album.id }}">{{ currentTrack.album.title }}</router-link>
</template>
</div>
</div>
</h1>
@ -128,7 +128,12 @@
<h2 class="ui header">
<div class="content">
<button
class="ui right floated basic icon button"
class="ui right floated basic button"
@click="$store.commit('ui/queueFocused', null)">
<translate translate-context="*/Queue/*/Verb">Close</translate>
</button>
<button
class="ui right floated basic button danger"
@click="$store.dispatch('queue/clean')">
<translate translate-context="*/Queue/*/Verb">Clear</translate>
</button>

View File

@ -1,5 +1,14 @@
<template>
<div>
<div v-if="type === 'both' || type === undefined" class="two ui buttons">
<button class="ui left floated labeled icon button" @click.prevent="changeType('rss')"><i class="feed icon"></i>
<translate translate-context="Content/Search/Input.Label/Noun">RSS</translate>
</button>
<div class="or"></div>
<button class="ui right floated right labeled icon button" @click.prevent="changeType('artists')"><i class="globe icon"></i>
<translate translate-context="Content/Search/Input.Label/Noun">Fediverse</translate>
</button>
</div>
<div v-else>
<form id="remote-search" :class="['ui', {loading: isLoading}, 'form']" @submit.stop.prevent="submit">
<div v-if="errors.length > 0" role="alert" class="ui negative message">
<h3 class="header"><translate translate-context="Content/*/Error message.Title">Error while fetching object</translate></h3>
@ -14,7 +23,7 @@
<p v-if="type === 'rss'">
<translate translate-context="Content/Fetch/Paragraph">Paste here the RSS url or the fediverse address to subscribe to its feed.</translate>
</p>
<p v-else>
<p v-else-if="type === 'artists'">
<translate translate-context="Content/Fetch/Paragraph">Use this form to retrieve an object hosted somewhere else in the fediverse.</translate>
</p>
<input type="text" name="object-id" id="object-id" :placeholder="labels.fieldPlaceholder" v-model="id" required>
@ -54,7 +63,7 @@ export default {
if (this.type === 'rss') {
this.rssSubscribe()
} else {
} else if (this.type === 'artists') {
this.createFetch()
}
}
@ -109,6 +118,9 @@ export default {
},
methods: {
changeType(newType) {
this.type = newType
},
submit () {
if (this.type === 'rss') {
return this.rssSubscribe()

View File

@ -114,20 +114,22 @@
<div class="ui small hidden divider"></div>
<section :class="['ui', 'bottom', 'attached', {active: selectedTab === 'library'}, 'tab']" :aria-label="labels.mainMenu">
<nav class="ui vertical large fluid inverted menu" role="navigation" :aria-label="labels.mainMenu">
<div :class="[{collapsed: !exploreExpanded}, 'collaspable item']">
<div :class="[{collapsed: !exploreExpanded}, 'collapsible item']">
<h2 class="header" role="button" @click="exploreExpanded = true" tabindex="0" @focus="exploreExpanded = true">
<translate translate-context="*/*/*/Verb">Explore</translate>
<i class="angle right icon" v-if="!exploreExpanded"></i>
</h2>
<div class="menu">
<router-link class="item" :to="{name: 'search'}"><i class="search icon"></i><translate translate-context="Sidebar/Navigation/List item.Link/Verb">Search</translate></router-link>
<router-link class="item" :exact="true" :to="{name: 'library.index'}"><i class="music icon"></i><translate translate-context="Sidebar/Navigation/List item.Link/Verb">Browse</translate></router-link>
<router-link class="item" :to="{name: 'library.podcasts.browse'}"><i class="podcast icon"></i><translate translate-context="*/*/*">Podcasts</translate></router-link>
<router-link class="item" :to="{name: 'library.albums.browse'}"><i class="compact disc icon"></i><translate translate-context="*/*/*">Albums</translate></router-link>
<router-link class="item" :to="{name: 'library.artists.browse'}"><i class="user icon"></i><translate translate-context="*/*/*">Artists</translate></router-link>
<router-link class="item" :to="{name: 'library.playlists.browse'}"><i class="list icon"></i><translate translate-context="*/*/*">Playlists</translate></router-link>
<router-link class="item" :to="{name: 'library.radios.browse'}"><i class="feed icon"></i><translate translate-context="*/*/*">Radios</translate></router-link>
</div>
</div>
<div :class="[{collapsed: !myLibraryExpanded}, 'collaspable item']" v-if="$store.state.auth.authenticated">
<div :class="[{collapsed: !myLibraryExpanded}, 'collapsible item']" v-if="$store.state.auth.authenticated">
<h3 class="header" role="button" @click="myLibraryExpanded = true" tabindex="0" @focus="myLibraryExpanded = true">
<translate translate-context="*/*/*/Noun">My Library</translate>
<i class="angle right icon" v-if="!myLibraryExpanded"></i>
@ -225,7 +227,9 @@ export default {
},
focusedMenu () {
let mapping = {
"search": 'exploreExpanded',
"library.index": 'exploreExpanded',
"library.podcasts.browse": 'exploreExpanded',
"library.albums.browse": 'exploreExpanded',
"library.albums.detail": 'exploreExpanded',
"library.artists.browse": 'exploreExpanded',

View File

@ -5,7 +5,7 @@
<div v-if="isLoading" class="ui inverted active dimmer">
<div class="ui loader"></div>
</div>
<channel-entry-card v-for="entry in objects" :entry="entry" :key="entry.id" />
<channel-entry-card v-for="entry in objects" :default-cover="defaultCover" :entry="entry" :key="entry.id" />
<template v-if="count > limit">
<div class="ui hidden divider"></div>
<div class = "ui center aligned basic segment">
@ -38,6 +38,7 @@ export default {
props: {
filters: {type: Object, required: true},
limit: {type: Number, default: 10},
defaultCover: {type: Object},
},
components: {
ChannelEntryCard,

View File

@ -9,10 +9,11 @@
class="channel-image image"
v-if="cover && cover.urls.original"
v-lazy="$store.getters['instance/absoluteUrl'](cover.urls.medium_square_crop)">
<span
<img
@click="$router.push({name: 'library.tracks.detail', params: {id: entry.id}})"
class="channel-image image"
v-else-if="entry.artist.content_category === 'podcast'">#{{ entry.position }}</span>
v-else-if="entry.artist.content_category === 'podcast' && defaultCover != undefined"
v-lazy="$store.getters['instance/absoluteUrl'](defaultCover.urls.medium_square_crop)">
<img
@click="$router.push({name: 'library.tracks.detail', params: {id: entry.id}})"
alt=""
@ -53,7 +54,7 @@ import { mapGetters } from "vuex"
export default {
props: ['entry'],
props: ['entry', 'defaultCover'],
components: {
PlayButton,
TrackFavoriteIcon,

View File

@ -1,9 +1,9 @@
<template>
<div class="channel-serie-card">
<div class="two-images">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-if="cover.urls.original" v-lazy="$store.getters['instance/absoluteUrl'](cover.urls.medium_square_crop)">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-if="cover && cover.urls.original" v-lazy="$store.getters['instance/absoluteUrl'](cover.urls.medium_square_crop)">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-else src="../../assets/audio/default-cover.png">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-if="cover.urls.original" v-lazy="$store.getters['instance/absoluteUrl'](cover.urls.medium_square_crop)">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-if="cover && cover.urls.original" v-lazy="$store.getters['instance/absoluteUrl'](cover.urls.medium_square_crop)">
<img alt="" @click="$router.push({name: 'library.albums.detail', params: {id: serie.id}})" class="channel-image" v-else src="../../assets/audio/default-cover.png">
</div>
<div class="content ellipsis">

View File

@ -24,10 +24,10 @@
</router-link>
</strong>
<div class="meta">
<router-link @click.stop.prevent="" class="discrete link" :to="{name: 'library.artists.detail', params: {id: currentTrack.artist.id }}">
{{ currentTrack.artist.name }}</router-link><template v-if="currentTrack.album"> /<router-link @click.stop.prevent="" class="discrete link" :to="{name: 'library.albums.detail', params: {id: currentTrack.album.id }}">
{{ currentTrack.album.title }}
</router-link></template>
<router-link @click.stop.prevent="" class="discrete link" :to="{name: 'library.artists.detail', params: {id: currentTrack.artist.id }}">{{ currentTrack.artist.name }}</router-link>
<template v-if="currentTrack.album"> /
<router-link @click.stop.prevent="" class="discrete link" :to="{name: 'library.albums.detail', params: {id: currentTrack.album.id }}">{{ currentTrack.album.title }}</router-link>
</template>
</div>
</div>
</div>
@ -277,6 +277,7 @@ export default {
})
if (this.currentTrack) {
this.getSound(this.currentTrack)
this.updateMetadata()
}
// Add controls for notification drawer
if ('mediaSession' in navigator) {
@ -550,6 +551,10 @@ export default {
this.updateProgressThrottled.cancel()
}
this.currentSound.seek(t)
// If player is paused update progress immediately to ensure updated UI
if (!this.$store.state.player.playing) {
this.updateProgress()
}
},
ended: function () {
let onlyTrack = this.$store.state.queue.tracks.length === 1
@ -642,6 +647,28 @@ export default {
}
},
updateMetadata () {
// If the session is playing as a PWA, populate the notification
// with details from the track
if (this.currentTrack && 'mediaSession' in navigator) {
let metadata = {
title: this.currentTrack.title,
artist: this.currentTrack.artist.name,
}
if (this.currentTrack.album && this.currentTrack.album.cover) {
metadata.album = this.currentTrack.album.title
metadata.artwork = [
{ src: this.currentTrack.album.cover.urls.original, sizes: '96x96', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '128x128', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '192x192', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '256x256', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '384x384', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '512x512', type: 'image/png' },
]
}
navigator.mediaSession.metadata = new MediaMetadata(metadata)
}
}
},
computed: {
...mapState({
@ -723,26 +750,7 @@ export default {
this.playTimeout = setTimeout(async () => {
await self.loadSound(newValue, oldValue)
}, 500);
// If the session is playing as a PWA, populate the notification
// with details from the track
if (this.currentTrack && 'mediaSession' in navigator) {
let metadata = {
title: this.currentTrack.title,
artist: this.currentTrack.artist.name,
}
if (this.currentTrack.album && this.currentTrack.album.cover) {
metadata.album = this.currentTrack.album.title
metadata.artwork = [
{ src: this.currentTrack.album.cover.urls.original, sizes: '96x96', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '128x128', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '192x192', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '256x256', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '384x384', type: 'image/png' },
{ src: this.currentTrack.album.cover.urls.original, sizes: '512x512', type: 'image/png' },
]
}
navigator.mediaSession.metadata = new MediaMetadata(metadata);
}
this.updateMetadata()
},
immediate: false
},

View File

@ -29,15 +29,16 @@
<input
id="volume-slider"
type="range"
step="0.05"
step="0.02"
min="0"
max="1"
v-model="sliderVolume" />
</div>
</button class="circular control">
</button>
</template>
<script>
import { mapState, mapGetters, mapActions } from "vuex"
import { toLinearVolumeScale, toLogarithmicVolumeScale } from '@/audio/volume'
export default {
data () {
@ -49,10 +50,10 @@ export default {
computed: {
sliderVolume: {
get () {
return this.$store.state.player.volume
return toLogarithmicVolumeScale(this.$store.state.player.volume)
},
set (v) {
this.$store.commit("player/volume", v)
this.$store.commit("player/volume", toLinearVolumeScale(v))
}
},
labels () {

View File

@ -15,7 +15,8 @@
<tags-list label-classes="tiny" :truncate-size="20" :limit="2" :show-more="false" :tags="artist.tags"></tags-list>
</div>
<div class="extra content">
<translate translate-context="*/*/*" :translate-params="{count: artist.tracks_count}" :translate-n="artist.tracks_count" translate-plural="%{ count } tracks">%{ count } track</translate>
<translate v-if="artist.content_category === 'music'" translate-context="*/*/*" :translate-params="{count: artist.tracks_count}" :translate-n="artist.tracks_count" translate-plural="%{ count } tracks">%{ count } track</translate>
<translate v-else translate-context="*/*/*" :translate-params="{count: artist.tracks_count}" :translate-n="artist.tracks_count" translate-plural="%{ count } episodes">%{ count } episode</translate>
<play-button class="right floated basic icon" :dropdown-only="true" :is-playable="artist.is_playable" :dropdown-icon-classes="['ellipsis', 'horizontal', 'large really discrete']" :artist="artist"></play-button>
</div>
</div>

View File

@ -91,7 +91,7 @@ export default {
this.isLoading = true
this.errors = []
let url = `plugins/${this.plugin.name}`
let enableUrl = this.enabled ? `${url}/enable` : `${url}/enable`
let enableUrl = this.enabled ? `${url}/enable` : `${url}/disable`
await axios.post(enableUrl)
try {
await axios.post(url, this.values)

View File

@ -4,7 +4,7 @@
<translate key="1" v-if="isSerie" translate-context="Content/Channels/*">Episodes</translate>
<translate key="2" v-else translate-context="*/*/*">Tracks</translate>
</h2>
<channel-entries v-if="artist.channel && isSerie" :limit="50" :filters="{channel: artist.channel.uuid, ordering: '-creation_date'}">
<channel-entries v-if="artist.channel && isSerie" :limit="50" :filters="{channel: artist.channel.uuid, album: object.id, ordering: '-creation_date'}">
</channel-entries>
<template v-else-if="discs && discs.length > 1">
<div v-for="tracks in discs" :key="tracks.disc_number">

View File

@ -175,6 +175,8 @@ export default {
ordering: this.getOrderingAsString(),
playable: "true",
tag: this.tags,
include_channels: "true",
content_category: "music"
}
logger.default.debug("Fetching albums")
axios.get(

View File

@ -8,7 +8,7 @@
<div class="fields">
<div class="field">
<label for="artist-search">
<translate translate-context="Content/Search/Input.Label/Noun">Search</translate>
<translate translate-context="Content/Search/Input.Label/Noun">Artist name</translate>
</label>
<div class="ui action input">
<input id="artist-search" type="text" name="search" v-model="query" :placeholder="labels.searchPlaceholder"/>
@ -138,7 +138,7 @@ export default {
},
computed: {
labels() {
let searchPlaceholder = this.$pgettext('Content/Search/Input.Placeholder', "Enter artist name…")
let searchPlaceholder = this.$pgettext('Content/Search/Input.Placeholder', "Search…")
let title = this.$pgettext('*/*/*/Noun', "Artists")
return {
searchPlaceholder,
@ -157,7 +157,9 @@ export default {
page: this.page,
tag: this.tags,
paginateBy: this.paginateBy,
ordering: this.getOrderingAsString()
ordering: this.getOrderingAsString(),
content_category: 'music',
include_channels: true,
}).toString()
)
},
@ -175,6 +177,7 @@ export default {
playable: "true",
tag: this.tags,
include_channels: "true",
content_category: 'music',
}
logger.default.debug("Fetching artists")
axios.get(

View File

@ -1,7 +1,6 @@
<template>
<div class="component-file-upload">
<div class="ui top attached tabular menu">
<a href="" :class="['item', {active: currentTab === 'summary'}]" @click.prevent="currentTab = 'summary'"><translate translate-context="Content/Library/Tab.Title/Short">Summary</translate></a>
<a href="" :class="['item', {active: currentTab === 'uploads'}]" @click.prevent="currentTab = 'uploads'">
<translate translate-context="Content/Library/Tab.Title/Short">Uploading</translate>
<div v-if="files.length === 0" class="ui label">
@ -27,70 +26,6 @@
</div>
</a>
</div>
<div :class="['ui', 'bottom', 'attached', 'segment', {hidden: currentTab != 'summary'}]">
<h2 class="ui header"><translate translate-context="Content/Library/Title/Verb">Upload new tracks</translate></h2>
<div class="ui message">
<p><translate translate-context="Content/Library/Paragraph">You are about to upload music to your library. Before proceeding, please ensure that:</translate></p>
<ul>
<li v-if="library.privacy_level != 'me'">
<translate translate-context="Content/Library/List item">You are not uploading copyrighted content in a public library, otherwise you may be infringing the law</translate>
</li>
<li>
<translate translate-context="Content/Library/List item">The music files you are uploading are tagged properly.</translate>&nbsp;
<a href="http://picard.musicbrainz.org/" target='_blank'><translate translate-context="Content/Library/Link">We recommend using Picard for that purpose.</translate></a>
</li>
<li>
<translate translate-context="Content/Library/List item">The uploaded music files are in OGG, Flac or MP3 format</translate>
</li>
</ul>
</div>
<form class="ui form" @submit.prevent="currentTab = 'uploads'">
<div class="fields">
<div class="ui field">
<label for="import-reference"><translate translate-context="Content/Library/Input.Label/Noun">Import reference</translate></label>
<p><translate translate-context="Content/Library/Paragraph">This reference will be used to group imported files together.</translate></p>
<input id="import-reference" name="import-ref" type="text" v-model="importReference" />
</div>
</div>
<button type="submit" class="ui success button"><translate translate-context="Content/Library/Button.Label">Proceed</translate></button>
</form>
<template v-if="$store.state.auth.availablePermissions['library']">
<div class="ui divider"></div>
<h2 class="ui header"><translate translate-context="Content/Library/Title/Verb">Import music from your server</translate></h2>
<div v-if="fsErrors.length > 0" role="alert" class="ui negative message">
<h3 class="header"><translate translate-context="Content/*/Error message.Title">Error while launching import</translate></h3>
<ul class="list">
<li v-for="error in fsErrors">{{ error }}</li>
</ul>
</div>
<fs-browser
v-if="fsStatus"
v-model="fsPath"
@import="importFs"
:loading="isLoadingFs"
:data="fsStatus"></fs-browser>
<template v-if="fsStatus && fsStatus.import">
<h3 class="ui header"><translate translate-context="Content/Library/Title/Verb">Import status</translate></h3>
<p v-if="fsStatus.import.reference != importReference">
<translate translate-context="Content/Library/Paragraph">Results of your previous import:</translate>
</p>
<p v-else>
<translate translate-context="Content/Library/Paragraph">Results of your import:</translate>
</p>
<button
class="ui button"
@click="cancelFsScan"
v-if="fsStatus.import.status === 'started' || fsStatus.import.status === 'pending'">
<translate translate-context="*/*/Button.Label/Verb">Cancel</translate>
</button>
<fs-logs :data="fsStatus.import"></fs-logs>
</template>
</template>
</div>
<div :class="['ui', 'bottom', 'attached', 'segment', {hidden: currentTab != 'uploads'}]">
<div :class="['ui', {loading: isLoadingQuota}, 'container']">
<div :class="['ui', {red: remainingSpace === 0}, {warning: remainingSpace > 0 && remainingSpace <= 50}, 'small', 'statistic']">
@ -101,6 +36,23 @@
{{ remainingSpace * 1000 * 1000 | humanSize}}
</div>
</div>
<div class="ui divider"></div>
<h2 class="ui header"><translate translate-context="Content/Library/Title/Verb">Upload music from your local storage</translate></h2>
<div class="ui message">
<p><translate translate-context="Content/Library/Paragraph">You are about to upload music to your library. Before proceeding, please ensure that:</translate></p>
<ul>
<li v-if="library.privacy_level != 'me'">
<translate translate-context="Content/Library/List item">You are not uploading copyrighted content in a public library, otherwise you may be infringing the law</translate>
</li>
<li>
<translate translate-context="Content/Library/List item">The music files you are uploading are tagged properly.</translate>&nbsp;
<a href="http://picard.musicbrainz.org/" target='_blank'><translate translate-context="Content/Library/Link">We recommend using Picard for that purpose.</translate></a>
</li>
<li>
<translate translate-context="Content/Library/List item">The music files you are uploading are in OGG, Flac, MP3 or AIFF format</translate>
</li>
</ul>
</div>
<file-upload-widget
:class="['ui', 'icon', 'basic', 'button']"
:post-action="uploadUrl"
@ -178,6 +130,37 @@
</tbody>
</table>
</div>
<div class="ui divider"></div>
<h2 class="ui header"><translate translate-context="Content/Library/Title/Verb">Import music from your server</translate></h2>
<div v-if="fsErrors.length > 0" role="alert" class="ui negative message">
<h3 class="header"><translate translate-context="Content/*/Error message.Title">Error while launching import</translate></h3>
<ul class="list">
<li v-for="error in fsErrors">{{ error }}</li>
</ul>
</div>
<fs-browser
v-model="fsPath"
@import="importFs"
:loading="isLoadingFs"
:data="fsStatus"></fs-browser>
<template v-if="fsStatus && fsStatus.import">
<h3 class="ui header"><translate translate-context="Content/Library/Title/Verb">Import status</translate></h3>
<p v-if="fsStatus.import.reference != importReference">
<translate translate-context="Content/Library/Paragraph">Results of your previous import:</translate>
</p>
<p v-else>
<translate translate-context="Content/Library/Paragraph">Results of your import:</translate>
</p>
<button
class="ui button"
@click="cancelFsScan"
v-if="fsStatus.import.status === 'started' || fsStatus.import.status === 'pending'">
<translate translate-context="*/*/Button.Label/Verb">Cancel</translate>
</button>
<fs-logs :data="fsStatus.import"></fs-logs>
</template>
</div>
<div :class="['ui', 'bottom', 'attached', 'segment', {hidden: currentTab != 'processing'}]">
@ -216,7 +199,7 @@ export default {
return {
files: [],
needsRefresh: false,
currentTab: "summary",
currentTab: "uploads",
uploadUrl: this.$store.getters['instance/absoluteUrl']("/api/v1/uploads/"),
importReference,
isLoadingQuota: false,

View File

@ -0,0 +1,247 @@
<template>
<main v-title="labels.title">
<section class="ui vertical stripe segment">
<h2 class="ui header">
<translate translate-context="Content/Podcasts/Title">Browsing Podcasts</translate>
</h2>
<form :class="['ui', {'loading': isLoading}, 'form']" @submit.prevent="updatePage();updateQueryString();fetchData()">
<div class="fields">
<div class="field">
<label for="artist-search">
<translate translate-context="Content/Search/Input.Label/Noun">Podcast Title</translate>
</label>
<div class="ui action input">
<input id="artist-search" type="text" name="search" v-model="query" :placeholder="labels.searchPlaceholder"/>
<button class="ui icon button" type="submit" :aria-label="$pgettext('Content/Search/Input.Label/Noun', 'Search')">
<i class="search icon"></i>
</button>
</div>
</div>
<div class="field">
<label for="tags-search"><translate translate-context="*/*/*/Noun">Tags</translate></label>
<tags-selector v-model="tags"></tags-selector>
</div>
<div class="field">
<label for="artist-ordering"><translate translate-context="Content/Search/Dropdown.Label/Noun">Ordering</translate></label>
<select id="artist-ordering" class="ui dropdown" v-model="ordering">
<option v-for="option in orderingOptions" :value="option[0]">
{{ sharedLabels.filters[option[1]] }}
</option>
</select>
</div>
<div class="field">
<label for="artist-ordering-direction"><translate translate-context="Content/Search/Dropdown.Label/Noun">Ordering direction</translate></label>
<select id="artist-ordering-direction" class="ui dropdown" v-model="orderingDirection">
<option value="+"><translate translate-context="Content/Search/Dropdown">Ascending</translate></option>
<option value="-"><translate translate-context="Content/Search/Dropdown">Descending</translate></option>
</select>
</div>
<div class="field">
<label for="artist-results"><translate translate-context="Content/Search/Dropdown.Label/Noun">Results per page</translate></label>
<select id="artist-results" class="ui dropdown" v-model="paginateBy">
<option :value="parseInt(12)">12</option>
<option :value="parseInt(30)">30</option>
<option :value="parseInt(50)">50</option>
</select>
</div>
</div>
</form>
<div class="ui hidden divider"></div>
<div v-if="result && result.results.length > 0" class="ui five app-cards cards">
<div v-if="isLoading" class="ui inverted active dimmer">
<div class="ui loader"></div>
</div>
<artist-card :artist="artist" v-for="artist in result.results" :key="artist.id"></artist-card>
</div>
<div v-else-if="!isLoading" class="ui placeholder segment sixteen wide column" style="text-align: center; display: flex; align-items: center">
<div class="ui icon header">
<i class="podcast icon"></i>
<translate translate-context="Content/Artists/Placeholder">
No results matching your query
</translate>
</div>
<router-link
v-if="$store.state.auth.authenticated"
:to="{name: 'content.index'}"
class="ui success button labeled icon">
<i class="upload icon"></i>
<translate translate-context="Content/*/Verb">
Create a Channel
</translate>
</router-link>
<h1 v-if ="$store.state.auth.authenticated" class="ui with-actions header">
<div class="actions">
<a @click.stop.prevent="showSubscribeModal = true">
<i class="plus icon"></i>
<translate translate-context="Content/Profile/Button">Subscribe to feed</translate>
</a>
</div>
</h1>
</div>
<div class="ui center aligned basic segment">
<pagination
v-if="result && result.count > paginateBy"
@page-changed="selectPage"
:current="page"
:paginate-by="paginateBy"
:total="result.count"
></pagination>
</div>
</section>
<modal class="tiny" :show.sync="showSubscribeModal" :fullscreen="false">
<h2 class="header">
<translate translate-context="*/*/*/Noun">Subscription</translate>
</h2>
<div class="scrolling content" ref="modalContent">
<remote-search-form
type="both"
:show-submit="false"
:standalone="false"
@subscribed="showSubscribeModal = false; fetchData()"
:redirect="true"></remote-search-form>
</div>
<div class="actions">
<button class="ui basic deny button">
<translate translate-context="*/*/Button.Label/Verb">Cancel</translate>
</button>
<button form="remote-search" type="submit" class="ui primary button">
<i class="bookmark icon"></i>
<translate translate-context="*/*/*/Verb">Subscribe</translate>
</button>
</div>
</modal>
</main>
</template>
<script>
import qs from 'qs'
import axios from "axios"
import _ from "@/lodash"
import $ from "jquery"
import logger from "@/logging"
import OrderingMixin from "@/components/mixins/Ordering"
import PaginationMixin from "@/components/mixins/Pagination"
import TranslationsMixin from "@/components/mixins/Translations"
import ArtistCard from "@/components/audio/artist/Card"
import Pagination from "@/components/Pagination"
import TagsSelector from '@/components/library/TagsSelector'
import Modal from '@/components/semantic/Modal'
import RemoteSearchForm from "@/components/RemoteSearchForm"
const FETCH_URL = "artists/"
export default {
mixins: [OrderingMixin, PaginationMixin, TranslationsMixin],
props: {
defaultQuery: { type: String, required: false, default: "" },
defaultTags: { type: Array, required: false, default: () => { return [] } },
scope: { type: String, required: false, default: "all" },
},
components: {
ArtistCard,
Pagination,
TagsSelector,
RemoteSearchForm,
Modal,
},
data() {
return {
isLoading: true,
result: null,
page: parseInt(this.defaultPage),
query: this.defaultQuery,
tags: (this.defaultTags || []).filter((t) => { return t.length > 0 }),
orderingOptions: [["creation_date", "creation_date"], ["name", "name"]],
showSubscribeModal: false,
}
},
created() {
this.fetchData()
},
mounted() {
$(".ui.dropdown").dropdown()
},
computed: {
labels() {
let searchPlaceholder = this.$pgettext('Content/Search/Input.Placeholder', "Search…")
let title = this.$pgettext('*/*/*/Noun', "Podcasts")
return {
searchPlaceholder,
title
}
}
},
methods: {
updateQueryString: function() {
history.pushState(
{},
null,
this.$route.path + '?' + new URLSearchParams(
{
query: this.query,
page: this.page,
tag: this.tags,
paginateBy: this.paginateBy,
ordering: this.getOrderingAsString(),
include_channels: true,
content_category: 'podcast',
}).toString()
)
},
fetchData: function() {
var self = this
this.isLoading = true
let url = FETCH_URL
let params = {
scope: this.scope,
page: this.page,
page_size: this.paginateBy,
has_albums: this.excludeCompilation,
q: this.query,
ordering: this.getOrderingAsString(),
playable: "true",
tag: this.tags,
include_channels: "true",
content_category: 'podcast',
}
logger.default.debug("Fetching artists")
axios.get(
url,
{
params: params,
paramsSerializer: function(params) {
return qs.stringify(params, { indices: false })
}
}
).then(response => {
self.result = response.data
self.isLoading = false
}, error => {
self.result = null
self.isLoading = false
})
},
selectPage: function(page) {
this.page = page
},
updatePage() {
this.page = this.defaultPage
},
},
watch: {
page() {
this.updateQueryString()
this.fetchData()
},
"$store.state.moderation.lastUpdate": function () {
this.fetchData()
},
excludeCompilation() {
this.fetchData()
}
}
}
</script>

View File

@ -4,7 +4,7 @@
<i class="dropdown icon"></i>
<input id="tags-search" type="text" class="search">
<div class="default text">
<translate translate-context="*/Dropdown/Placeholder/Verb">Search for tags</translate>
<translate translate-context="*/Dropdown/Placeholder/Verb">Search</translate>
</div>
</div>
</template>

View File

@ -29,6 +29,7 @@ export default {
if (this.control) {
$(this.$el).modal('hide')
}
this.focusTrap.deactivate()
$(this.$el).remove()
},
methods: {

View File

@ -637,6 +637,23 @@ export default new Router({
defaultPage: route.query.page
})
},
{
path: "podcasts/",
name: "library.podcasts.browse",
component: () =>
import(
/* webpackChunkName: "podcasts" */ "@/components/library/Podcasts"
),
props: route => ({
defaultOrdering: route.query.ordering,
defaultQuery: route.query.query,
defaultTags: Array.isArray(route.query.tag || [])
? route.query.tag
: [route.query.tag],
defaultPaginateBy: route.query.paginateBy,
defaultPage: route.query.page
})
},
{
path: "me/albums",
name: "library.albums.me",

View File

@ -11,7 +11,7 @@ export default {
lastDate: new Date(),
maxMessages: 100,
messageDisplayDuration: 5 * 1000,
supportedExtensions: ["flac", "ogg", "mp3", "opus", "aac", "m4a"],
supportedExtensions: ["flac", "ogg", "mp3", "opus", "aac", "m4a", "aiff", "aif"],
messages: [],
theme: 'light',
window: {
@ -45,6 +45,11 @@ export default {
orderingDirection: "-",
ordering: "creation_date",
},
"library.podcasts.browse": {
paginateBy: 30,
orderingDirection: "-",
ordering: "creation_date",
},
"library.radios.browse": {
paginateBy: 12,
orderingDirection: "-",

View File

@ -1,244 +1,237 @@
.ui.wide.left.sidebar {
@include media(">desktop") {
width: $desktop-sidebar-width;
}
@include media(">widedesktop") {
width: $widedesktop-sidebar-width;
}
@include media(">desktop") {
width: $desktop-sidebar-width;
}
@include media(">widedesktop") {
width: $widedesktop-sidebar-width;
}
}
.sidebar {
.logo {
&.bordered.icon {
padding: .5em .41em !important;
.logo {
&.bordered.icon {
padding: .5em .41em !important;
}
path {
fill: white;
}
}
path {
fill: white;
.tab {
flex-direction: column;
}
}
.tab {
flex-direction: column;
}
}
.component-sidebar {
.ui.search .input {
flex: 1;
.prompt {
border-radius: 0;
.ui.search .input {
flex: 1;
.prompt {
border-radius: 0;
}
}
}
.ui.search .results {
vertical-align: middle;
}
.ui.search .name {
vertical-align: middle;
}
&.sidebar {
overflow-y: visible !important;
background: var(--sidebar-background);
z-index: 1;
@include media(">desktop") {
display: flex;
flex-direction: column;
justify-content: space-between;
padding-bottom: 4em;
.ui.search .results {
vertical-align: middle;
}
> nav {
flex-grow: 1;
overflow-y: auto;
.ui.search .name {
vertical-align: middle;
}
@include media(">desktop") {
.menu .item.collapse-button-wrapper {
&.sidebar {
overflow-y: visible !important;
background: var(--sidebar-background);
z-index: 1;
@include media(">desktop") {
display: flex;
flex-direction: column;
justify-content: space-between;
padding-bottom: 4em;
}
>nav {
flex-grow: 1;
overflow-y: auto;
}
@include media(">desktop") {
.menu .item.collapse-button-wrapper {
padding: 0;
}
.collapse.button {
display: none !important;
}
}
@include media("<=desktop") {
position: static !important;
width: 100% !important;
&.collapsed {
.player-wrapper,
.search,
.signup.segment,
nav.secondary {
display: none;
}
}
}
>div {
margin: 0;
background-color: var(--sidebar-background);
}
.menu.vertical {
background: transparent;
}
}
.ui.vertical.menu {
.item .item {
font-size: 1em;
>i.icon {
float: none;
margin: 0 0.5em 0 0;
}
}
.item.active {
border-right: 5px solid var(--vibrant-color);
border-radius: 0 !important;
background: var(--sidebar-active-item-background) !important;
}
.item.collapsed {
&:not(:focus)>.menu {
display: none;
}
.header {
margin-bottom: 0;
}
}
.collapsible.item .header {
cursor: pointer;
}
}
.ui.secondary.menu {
margin-left: 0;
margin-right: 0;
}
.tabs {
flex: 1;
display: flex;
flex-direction: column;
overflow-y: auto;
justify-content: space-between;
@include media("<=desktop") {
max-height: 500px;
}
}
.ui.tab.active {
display: flex;
}
.tab[data-tab="queue"] {
flex-direction: column;
tr {
cursor: pointer;
}
td:nth-child(2) {
width: 55px;
}
}
.item .header .angle.icon {
float: right;
margin: 0;
}
.tab[data-tab="library"] {
flex-direction: column;
flex: 1 1 auto;
>.menu {
flex: 1;
flex-grow: 1;
}
>.player-wrapper {
width: 100%;
}
}
.sidebar .segment {
margin: 0;
border-radius: 0;
}
.ui.menu .item.inline.admin-dropdown.dropdown>.menu {
left: 0;
right: auto;
}
.ui.segment.header-wrapper {
background: var(--sidebar-header-background);
color: var(--sidebar-header-color);
box-shadow: var(--sidebar-header-box-shadow);
padding: 0;
}
.collapse.button {
display: none !important;
}
}
@include media("<=desktop") {
position: static !important;
width: 100% !important;
&.collapsed {
.player-wrapper,
.search,
.signup.segment,
nav.secondary {
display: none;
}
}
}
> div {
margin: 0;
background-color: var(--sidebar-background);
}
.menu.vertical {
background: transparent;
}
}
.ui.vertical.menu {
.item .item {
font-size: 1em;
> i.icon {
float: none;
margin: 0 0.5em 0 0;
}
}
.item.active {
border-right: 5px solid var(--vibrant-color);
border-radius: 0 !important;
background: var(--sidebar-active-item-background) !important;
}
.item.collapsed {
&:not(:focus) > .menu {
display: none;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
height: 4em;
margin-bottom: 0;
}
}
.collaspable.item .header {
cursor: pointer;
}
}
.ui.secondary.menu {
margin-left: 0;
margin-right: 0;
}
.tabs {
flex: 1;
display: flex;
flex-direction: column;
overflow-y: auto;
justify-content: space-between;
@include media("<=desktop") {
max-height: 500px;
}
}
.ui.tab.active {
display: flex;
}
.tab[data-tab="queue"] {
flex-direction: column;
tr {
cursor: pointer;
}
td:nth-child(2) {
width: 55px;
}
}
.item .header .angle.icon {
float: right;
margin: 0;
}
.tab[data-tab="library"] {
flex-direction: column;
flex: 1 1 auto;
> .menu {
flex: 1;
flex-grow: 1;
}
> .player-wrapper {
width: 100%;
}
}
.sidebar .segment {
margin: 0;
border-radius: 0;
}
.ui.menu .item.inline.admin-dropdown.dropdown > .menu {
left: 0;
right: auto;
}
.ui.segment.header-wrapper {
background: var(--sidebar-header-background);
color: var(--sidebar-header-color);
box-shadow: var(--sidebar-header-box-shadow);
padding: 0;
display: flex;
justify-content: space-between;
align-items: center;
height: 4em;
margin-bottom: 0;
nav {
> .item, > .menu > .item > .item {
&:hover {
background-color: transparent;
nav {
>.item,
>.menu>.item>.item {
&:hover {
background-color: transparent;
}
}
}
}
}
}
nav.top.title-menu {
flex-grow: 1;
.item {
font-size: 1.5em;
nav.top.title-menu {
flex-grow: 1;
.item {
font-size: 1.5em;
}
}
}
.logo {
cursor: pointer;
display: inline-block;
margin: 0px;
}
&.collapsed .search-wrapper {
@include media("<desktop") {
padding: 0;
.logo {
cursor: pointer;
display: inline-block;
margin: 0px;
}
}
.ui.search {
display: flex;
}
.ui.message.black {
background: var(--sidebar-background);
}
.ui.mini.image {
width: 100%;
}
nav.top {
align-items: self-end;
padding: 0.5em 0;
> .item, > .right.menu > .item {
// color: rgba(255, 255, 255, 0.9) !important;
font-size: 1.2em;
&:hover, > .dropdown > .icon {
// color: rgba(255, 255, 255, 0.9) !important;
}
> .label, > .dropdown > .label {
font-size: 0.5em;
right: 1.7em;
bottom: -0.5em;
z-index: 0 !important;
}
&.collapsed .search-wrapper {
@include media("<desktop") {
padding: 0;
}
}
}
.ui.user-dropdown > .text > .label {
margin-right: 0;
}
.logo-wrapper {
display: inline-block;
margin: 0 auto;
@include media("<desktop") {
margin: 0;
.ui.search {
display: flex;
}
img {
height: 1em;
display: inline-block;
margin: 0 auto;
.ui.message.black {
background: var(--sidebar-background);
}
@include media(">tablet") {
img {
height: 1.5em;
}
.ui.mini.image {
width: 100%;
}
}
}
nav.top {
align-items: self-end;
padding: 0.5em 0;
>.item,
>.right.menu>.item {
// color: rgba(255, 255, 255, 0.9) !important;
font-size: 1.2em;
&:hover,
>.dropdown>.icon {
// color: rgba(255, 255, 255, 0.9) !important;
}
>.label,
>.dropdown>.label {
font-size: 0.5em;
right: 1.7em;
bottom: -0.5em;
z-index: 0 !important;
}
}
}
.ui.user-dropdown>.text>.label {
margin-right: 0;
}
.logo-wrapper {
display: inline-block;
margin: 0 auto;
@include media("<desktop") {
margin: 0;
}
img {
height: 1em;
display: inline-block;
margin: 0 auto;
}
@include media(">tablet") {
img {
height: 1.5em;
}
}
}
}

View File

@ -24,6 +24,7 @@
}
input {
max-width: 8.5em;
padding: 1em 0em;
}
&:not(:hover):not(.expanded) .popup {
display: none;

View File

@ -39,10 +39,10 @@
<p>
<translate translate-context="Content/Notifications/Paragraph">We noticed you've been here for a while. If Funkwhale is useful to you, we could use your help to make it even better!</translate>
</p>
<a href="https://funkwhale.audio/support-us" _target="blank" rel="noopener" class="ui primary inverted button">
<a href="https://funkwhale.audio/support-us" target="_blank" rel="noopener" class="ui primary inverted button">
<translate translate-context="Content/Notifications/Button.Label/Verb">Donate</translate>
</a>
<a href="https://contribute.funkwhale.audio" _target="blank" rel="noopener" class="ui secondary inverted button">
<a href="https://contribute.funkwhale.audio" target="_blank" rel="noopener" class="ui secondary inverted button">
<translate translate-context="Content/Notifications/Button.Label/Verb">Discover other ways to help</translate>
</a>
</div>

View File

@ -43,11 +43,11 @@
<empty-state v-else-if="!currentResults || currentResults.count === 0" @refresh="search" :refresh="true"></empty-state>
<div v-else-if="type === 'artists'" class="ui five app-cards cards">
<div v-else-if="type === 'artists' || type === 'podcasts'" class="ui five app-cards cards">
<artist-card :artist="artist" v-for="artist in currentResults.results" :key="artist.id"></artist-card>
</div>
<div v-else-if="type === 'albums'" class="ui five app-cards cards">
<div v-else-if="type === 'albums' || type === 'series'" class="ui five app-cards cards">
<album-card
v-for="album in currentResults.results"
:key="album.id"
@ -124,6 +124,8 @@ export default {
playlists: null,
radios: null,
tags: null,
podcasts: null,
series: null,
},
isLoading: false,
paginateBy: 25,
@ -147,15 +149,28 @@ export default {
submitSearch
}
},
axiosParams() {
const params = new URLSearchParams();
params.append('q', this.query);
params.append('page', this.page);
params.append('page_size', this.paginateBy);
if(this.currentType.contentCategory != undefined) {params.append('content_category', this.currentType.contentCategory)};
if(this.currentType.includeChannels != undefined) {params.append('include_channels', this.currentType.includeChannels)};
return params;
},
types () {
return [
{
id: 'artists',
label: this.$pgettext("*/*/*/Noun", "Artists"),
includeChannels: true,
contentCategory: 'music',
},
{
id: 'albums',
label: this.$pgettext("*/*/*", "Albums"),
includeChannels: true,
contentCategory: 'music',
},
{
id: 'tracks',
@ -174,6 +189,20 @@ export default {
id: 'tags',
label: this.$pgettext("*/*/*", "Tags"),
},
{
id: 'podcasts',
label: this.$pgettext("*/*/*", "Podcasts"),
endpoint: '/artists',
contentCategory: 'podcast',
includeChannels: true,
},
{
id: 'series',
label: this.$pgettext("*/*/*", "Series"),
endpoint: '/albums',
includeChannels: true,
contentCategory: 'podcast',
},
]
},
currentType () {
@ -197,13 +226,18 @@ export default {
this.isLoading = true
let response = await axios.get(
this.currentType.endpoint || this.currentType.id,
{params: {q: this.query, page: this.page, page_size: this.paginateBy}}
{params: this.axiosParams}
)
this.results[this.currentType.id] = response.data
this.isLoading = false
this.types.forEach(t => {
if (t.id != this.currentType.id) {
axios.get(t.endpoint || t.id, {params: {q: this.query, page_size: 1}}).then(response => {
axios.get(t.endpoint || t.id, {params: {
q: this.query,
page_size: 1,
content_category: t.contentCategory,
include_channels: t.includeChannels,
}}).then(response => {
this.results[t.id] = response.data
})
}

View File

@ -49,7 +49,7 @@
:can-update="false"></rendered-description>
<div class="ui hidden divider"></div>
</div>
<channel-entries :key="String(episodesKey) + 'entries'" :limit='25' :filters="{channel: object.uuid, ordering: '-creation_date', page_size: '25'}">
<channel-entries :key="String(episodesKey) + 'entries'" :default-cover='object.artist.cover' :limit='25' :filters="{channel: object.uuid, ordering: '-creation_date', page_size: '25'}">
<h2 class="ui header">
<translate key="1" v-if="isPodcast" translate-context="Content/Channel/Paragraph">Latest episodes</translate>
<translate key="2" v-else translate-context="Content/Channel/Paragraph">Latest tracks</translate>

View File

@ -16,11 +16,11 @@
</h2>
<div class="scrolling content" ref="modalContent">
<remote-search-form
type="rss"
type="both"
:show-submit="false"
:standalone="false"
@subscribed="showSubscribeModal = false; reloadWidget()"
:redirect="false"></remote-search-form>
:redirect="true"></remote-search-form>
</div>
<div class="actions">
<button class="ui basic deny button">

View File

@ -11,7 +11,7 @@
<translate translate-context="Content/Library/Title/Verb">Publish your work in a channel</translate>
</h2>
<p>
<translate translate-context="Content/Library/Paragraph">If you are a musician or a podcaster, channels are designed for you!</translate>
<translate translate-context="Content/Library/Paragraph">If you are a musician or a podcaster, channels are designed for you!</translate>&#32;
<translate translate-context="Content/Library/Paragraph">Share your work publicly and get subscribers on Funkwhale, the Fediverse or any podcasting application.</translate>
</p>
<router-link :to="{name: 'profile.overview', params: {username: $store.state.auth.username}, hash: '#channels'}" class="ui primary button">

View File

@ -26,7 +26,7 @@
<translate translate-context="Content/Library/Button.Label/Verb" v-if="library">Update library</translate>
<translate translate-context="Content/Library/Button.Label/Verb" v-else>Create library</translate>
</button>
<dangerous-button v-if="library" class="ui right floated basic danger button" @confirm="remove()">
<dangerous-button v-if="library" type="button" class="ui right floated basic danger button" @confirm="remove()">
<translate translate-context="*/*/*/Verb">Delete</translate>
<p slot="modal-header">
<translate translate-context="Popup/Library/Title">Delete this library?</translate>

View File

@ -194,7 +194,7 @@ export default {
isPlayable () {
return this.object.uploads_count > 0 && (
this.isOwner ||
this.object.privacy_level === 'public' ||
this.object.privacy_level === 'everyone' ||
(this.object.privacy_level === 'instance' && this.$store.state.auth.authenticated && this.object.actor.domain === this.$store.getters['instance/domain']) ||
(this.$store.getters['libraries/follow'](this.object.uuid) || {}).approved === true
)

View File

@ -15,40 +15,46 @@
:translate-n="playlist.tracks_count"
:translate-params="{count: playlist.tracks_count, username: playlist.user.username}"
translate-context="Content/Playlist/Header.Subtitle">
Playlist containing %{ count } track, by %{ username }
Playlist containing %{ count } track, by %{ username }
</translate><br>
<duration :seconds="playlist.duration" />
</div>
</div>
</h2>
<div class="ui hidden divider"></div>
<play-button class="vibrant" :is-playable="playlist.is_playable" :tracks="tracks"><translate translate-context="Content/Queue/Button.Label/Short, Verb">Play all</translate></play-button>
<button
class="ui icon labeled button"
v-if="$store.state.auth.profile && playlist.user.id === $store.state.auth.profile.id"
@click="edit = !edit">
<i class="pencil icon"></i>
<template v-if="edit"><translate translate-context="Content/Playlist/Button.Label/Verb">Stop Editing</translate></template>
<template v-else><translate translate-context="Content/*/Button.Label/Verb">Edit</translate></template>
</button>
<button
class="ui icon labeled button"
v-if="playlist.privacy_level === 'everyone' && playlist.is_playable"
@click="showEmbedModal = !showEmbedModal">
<i class="code icon"></i>
<translate translate-context="Content/*/Button.Label/Verb">Embed</translate>
</button>
<dangerous-button v-if="$store.state.auth.profile && playlist.user.id === $store.state.auth.profile.id" class="ui labeled danger icon button" :action="deletePlaylist">
<i class="trash icon"></i> <translate translate-context="*/*/*/Verb">Delete</translate>
<p slot="modal-header" v-translate="{playlist: playlist.name}" translate-context="Popup/Playlist/Title/Call to action" :translate-params="{playlist: playlist.name}">
Do you want to delete the playlist "%{ playlist }"?
</p>
<p slot="modal-content"><translate translate-context="Popup/Playlist/Paragraph">This will completely delete this playlist and cannot be undone.</translate></p>
<div slot="modal-confirm"><translate translate-context="Popup/Playlist/Button.Label/Verb">Delete playlist</translate></div>
</dangerous-button>
</div>
<modal v-if="playlist.privacy_level === 'everyone' && playlist.is_playable" :show.sync="showEmbedModal">
<div class="header-buttons">
<div class="ui buttons">
<play-button class="vibrant" :is-playable="playlist.is_playable" :tracks="tracks"><translate translate-context="Content/Queue/Button.Label/Short, Verb">Play all</translate></play-button>
</div>
<div class="ui buttons">
<button
class="ui icon labeled button"
v-if="$store.state.auth.profile && playlist.user.id === $store.state.auth.profile.id"
@click="edit = !edit">
<i class="pencil icon"></i>
<template v-if="edit"><translate translate-context="Content/Playlist/Button.Label/Verb">Stop Editing</translate></template>
<template v-else><translate translate-context="Content/*/Button.Label/Verb">Edit</translate></template>
</button>
</div>
<div class="ui buttons">
<button
class="ui icon labeled button"
v-if="playlist.privacy_level === 'everyone' && playlist.is_playable"
@click="showEmbedModal = !showEmbedModal">
<i class="code icon"></i>
<translate translate-context="Content/*/Button.Label/Verb">Embed</translate>
</button>
<dangerous-button v-if="$store.state.auth.profile && playlist.user.id === $store.state.auth.profile.id" class="ui labeled danger icon button" :action="deletePlaylist">
<i class="trash icon"></i> <translate translate-context="*/*/*/Verb">Delete</translate>
<p slot="modal-header" v-translate="{playlist: playlist.name}" translate-context="Popup/Playlist/Title/Call to action" :translate-params="{playlist: playlist.name}">
Do you want to delete the playlist "%{ playlist }"?
</p>
<p slot="modal-content"><translate translate-context="Popup/Playlist/Paragraph">This will completely delete this playlist and cannot be undone.</translate></p>
<div slot="modal-confirm"><translate translate-context="Popup/Playlist/Button.Label/Verb">Delete playlist</translate></div>
</dangerous-button>
</div>
</div>
<modal v-if="playlist.privacy_level === 'everyone' && playlist.is_playable" :show.sync="showEmbedModal">
<h4 class="header">
<translate translate-context="Popup/Album/Title/Verb">Embed this playlist on your website</translate>
</h4>
@ -62,7 +68,8 @@
<translate translate-context="*/*/Button.Label/Verb">Cancel</translate>
</button>
</div>
</modal>
</modal>
</div>
</section>
<section class="ui vertical stripe segment">
<template v-if="edit">

View File

@ -0,0 +1,34 @@
import { expect } from 'chai'
import { toLinearVolumeScale, toLogarithmicVolumeScale } from '@/audio/volume'
describe('store/auth', () => {
describe('toLinearVolumeScale', () => {
describe('it should return real 0', () => {
expect(toLinearVolumeScale(0.0)).to.equal(0.0)
})
describe('it should have logarithmic scale', () => {
expect(2 * toLinearVolumeScale(0.5)).to.be.closeTo(toLinearVolumeScale(0.6), 0.001)
})
describe('it should return full volume', () => {
expect(toLogarithmicVolumeScale(1.0)).to.be.closeTo(1.0, 0.001)
})
})
describe('toLogarithmicVolumeScale', () => {
describe('it should return real 0', () => {
expect(toLogarithmicVolumeScale(0.0)).to.equal(0.0)
})
describe('it should have logarithmic scale', () => {
expect(toLogarithmicVolumeScale(0.6)).to.be.closeTo(0.9261, 0.001)
expect(toLogarithmicVolumeScale(0.7)).to.be.closeTo(0.9483, 0.001)
})
describe('it should return full volume', () => {
expect(toLogarithmicVolumeScale(1.0)).to.be.closeTo(1.0, 0.001)
})
})
})