Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy Craze
funkwhale
Commits
81a6a197
Unverified
Commit
81a6a197
authored
5 years ago
by
Agate
💬
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#1082
: subsonic crash on stared track with no album
parent
20f5416b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/subsonic/serializers.py
+6
-39
6 additions, 39 deletions
api/funkwhale_api/subsonic/serializers.py
api/tests/subsonic/test_serializers.py
+0
-37
0 additions, 37 deletions
api/tests/subsonic/test_serializers.py
with
6 additions
and
76 deletions
api/funkwhale_api/subsonic/serializers.py
+
6
−
39
View file @
81a6a197
...
...
@@ -33,13 +33,15 @@ def get_valid_filepart(s):
def
get_track_path
(
track
,
suffix
):
artist_part
=
get_valid_filepart
(
track
.
artist
.
name
)
album_part
=
get_valid_filepart
(
track
.
album
.
title
)
parts
=
[]
parts
.
append
(
get_valid_filepart
(
track
.
artist
.
name
))
if
track
.
album
:
parts
.
append
(
get_valid_filepart
(
track
.
album
.
title
))
track_part
=
get_valid_filepart
(
track
.
title
)
+
"
.
"
+
suffix
if
track
.
position
:
track_part
=
"
{} - {}
"
.
format
(
track
.
position
,
track_part
)
return
"
/
"
.
join
(
[
artist_part
,
album_part
,
track_part
]
)
parts
.
append
(
track_part
)
return
"
/
"
.
join
(
parts
)
def
get_artist_data
(
artist_values
):
...
...
@@ -238,41 +240,6 @@ def get_playlist_detail_data(playlist):
return
data
def
get_music_directory_data
(
artist
):
tracks
=
artist
.
tracks
.
select_related
(
"
album
"
).
prefetch_related
(
"
uploads
"
)
data
=
{
"
id
"
:
artist
.
pk
,
"
parent
"
:
1
,
"
name
"
:
artist
.
name
,
"
child
"
:
[]}
for
track
in
tracks
:
try
:
upload
=
[
upload
for
upload
in
track
.
uploads
.
all
()][
0
]
except
IndexError
:
continue
album
=
track
.
album
td
=
{
"
id
"
:
track
.
pk
,
"
isDir
"
:
"
false
"
,
"
title
"
:
track
.
title
,
"
album
"
:
album
.
title
,
"
artist
"
:
artist
.
name
,
"
track
"
:
track
.
position
or
1
,
"
year
"
:
track
.
album
.
release_date
.
year
if
track
.
album
.
release_date
else
0
,
"
contentType
"
:
upload
.
mimetype
,
"
suffix
"
:
upload
.
extension
or
""
,
"
path
"
:
get_track_path
(
track
,
upload
.
extension
or
"
mp3
"
),
"
duration
"
:
upload
.
duration
or
0
,
"
created
"
:
to_subsonic_date
(
track
.
creation_date
),
"
albumId
"
:
album
.
pk
,
"
artistId
"
:
artist
.
pk
,
"
parent
"
:
artist
.
id
,
"
type
"
:
"
music
"
,
}
if
upload
.
bitrate
:
td
[
"
bitrate
"
]
=
int
(
upload
.
bitrate
/
1000
)
if
upload
.
size
:
td
[
"
size
"
]
=
upload
.
size
data
[
"
child
"
].
append
(
td
)
return
data
def
get_folders
(
user
):
return
[
# Dummy folder ID to match what is returned in the getMusicFolders endpoint
...
...
This diff is collapsed.
Click to expand it.
api/tests/subsonic/test_serializers.py
+
0
−
37
View file @
81a6a197
...
...
@@ -252,43 +252,6 @@ def test_playlist_detail_serializer(factories):
assert
data
==
expected
def
test_directory_serializer_artist
(
factories
):
track
=
factories
[
"
music.Track
"
]()
upload
=
factories
[
"
music.Upload
"
](
track
=
track
,
bitrate
=
42000
,
duration
=
43
,
size
=
44
)
album
=
track
.
album
artist
=
track
.
artist
expected
=
{
"
id
"
:
artist
.
pk
,
"
parent
"
:
1
,
"
name
"
:
artist
.
name
,
"
child
"
:
[
{
"
id
"
:
track
.
pk
,
"
isDir
"
:
"
false
"
,
"
title
"
:
track
.
title
,
"
album
"
:
album
.
title
,
"
artist
"
:
artist
.
name
,
"
track
"
:
track
.
position
,
"
year
"
:
track
.
album
.
release_date
.
year
,
"
contentType
"
:
upload
.
mimetype
,
"
suffix
"
:
upload
.
extension
or
""
,
"
path
"
:
serializers
.
get_track_path
(
track
,
upload
.
extension
),
"
bitrate
"
:
42
,
"
duration
"
:
43
,
"
size
"
:
44
,
"
created
"
:
serializers
.
to_subsonic_date
(
track
.
creation_date
),
"
albumId
"
:
album
.
pk
,
"
artistId
"
:
artist
.
pk
,
"
parent
"
:
artist
.
pk
,
"
type
"
:
"
music
"
,
}
],
}
data
=
serializers
.
get_music_directory_data
(
artist
)
assert
data
==
expected
def
test_scrobble_serializer
(
factories
):
upload
=
factories
[
"
music.Upload
"
]()
track
=
upload
.
track
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment