Merge branch 'sentriz:master' into ldap_auth
This commit is contained in:
No files matched your search
@@ -624,3 +624,25 @@ func TestAlbumAndArtistSameNameWeirdness(t *testing.T) {
|
||||
assert.NoError(m.DB().Find(&albums).Error)
|
||||
assert.Equal(len(albums), 5) // root, 2 artists, 2 albums
|
||||
}
|
||||
|
||||
func TestNoOrphanedGenres(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := assert.New(t)
|
||||
m := mockfs.New(t)
|
||||
|
||||
m.AddItems()
|
||||
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.Tags) error { tags.RawGenre = "genre-a;genre-b"; return nil })
|
||||
m.SetTags("artist-0/album-0/track-1.flac", func(tags *mockfs.Tags) error { tags.RawGenre = "genre-c;genre-d"; return nil })
|
||||
m.SetTags("artist-1/album-2/track-0.flac", func(tags *mockfs.Tags) error { tags.RawGenre = "genre-e;genre-f"; return nil })
|
||||
m.SetTags("artist-1/album-2/track-1.flac", func(tags *mockfs.Tags) error { tags.RawGenre = "genre-g;genre-h"; return nil })
|
||||
m.ScanAndClean()
|
||||
|
||||
m.RemoveAll("artist-0")
|
||||
m.RemoveAll("artist-1")
|
||||
m.RemoveAll("artist-2")
|
||||
m.ScanAndClean()
|
||||
|
||||
var genreCount int
|
||||
require.NoError(m.DB().Model(&db.Genre{}).Count(&genreCount).Error)
|
||||
require.Equal(0, genreCount)
|
||||
}
|
||||
@@ -246,8 +246,117 @@ func TestArtistGetTopTracks_clientRequestFails(t *testing.T) {
|
||||
require.Zero(actual)
|
||||
}
|
||||
|
||||
//go:embed testdata/artist_get_similar_response.xml
|
||||
var artistGetSimilarResponse string
|
||||
|
||||
func TestArtistGetSimilar(t *testing.T) {
|
||||
// arrange
|
||||
require := require.New(t)
|
||||
httpClient, shutdown := httpClientMock(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
require.Equal(http.MethodGet, r.Method)
|
||||
require.Equal(url.Values{
|
||||
"method": []string{"artist.getSimilar"},
|
||||
"api_key": []string{"apiKey1"},
|
||||
"artist": []string{"artist1"},
|
||||
}, r.URL.Query())
|
||||
require.Equal("/2.0/", r.URL.Path)
|
||||
require.Equal(baseURL, "https://"+r.Host+r.URL.Path)
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(artistGetSimilarResponse))
|
||||
}))
|
||||
defer shutdown()
|
||||
|
||||
client := Client{&httpClient}
|
||||
|
||||
// act
|
||||
actual, err := client.ArtistGetSimilar("apiKey1", "artist1")
|
||||
|
||||
// assert
|
||||
require.NoError(err)
|
||||
require.Equal(SimilarArtists{
|
||||
XMLName: xml.Name{
|
||||
Local: "similarartists",
|
||||
},
|
||||
Artist: "Artist 1",
|
||||
Artists: []Artist{
|
||||
{
|
||||
XMLName: xml.Name{
|
||||
Local: "artist",
|
||||
},
|
||||
Image: []Image{
|
||||
{
|
||||
Text: "https://last.fm/artist-2-small.png",
|
||||
Size: "small",
|
||||
},
|
||||
{
|
||||
Text: "https://last.fm/artist-2-large.png",
|
||||
Size: "large",
|
||||
},
|
||||
},
|
||||
MBID: "d2addad9-3fc4-4ce8-9cd4-63f2a19bb922",
|
||||
Name: "Artist 2",
|
||||
Similar: struct {
|
||||
Artists []Artist `xml:"artist"`
|
||||
}{},
|
||||
Streamable: "0",
|
||||
URL: "https://www.last.fm/music/Artist+2",
|
||||
},
|
||||
{
|
||||
XMLName: xml.Name{
|
||||
Local: "artist",
|
||||
},
|
||||
Image: []Image{
|
||||
{
|
||||
Text: "https://last.fm/artist-3-small.png",
|
||||
Size: "small",
|
||||
},
|
||||
{
|
||||
Text: "https://last.fm/artist-3-large.png",
|
||||
Size: "large",
|
||||
},
|
||||
},
|
||||
MBID: "dc95d067-df3e-4b83-a5fe-5ec773b1883f",
|
||||
Name: "Artist 3",
|
||||
Similar: struct {
|
||||
Artists []Artist `xml:"artist"`
|
||||
}{},
|
||||
Streamable: "0",
|
||||
URL: "https://www.last.fm/music/Artist+3",
|
||||
},
|
||||
},
|
||||
}, actual)
|
||||
}
|
||||
|
||||
func TestArtistGetSimilar_clientRequestFails(t *testing.T) {
|
||||
// arrange
|
||||
require := require.New(t)
|
||||
httpClient, shutdown := httpClientMock(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
require.Equal(http.MethodGet, r.Method)
|
||||
require.Equal(url.Values{
|
||||
"method": []string{"artist.getSimilar"},
|
||||
"api_key": []string{"apiKey1"},
|
||||
"artist": []string{"artist1"},
|
||||
}, r.URL.Query())
|
||||
require.Equal("/2.0/", r.URL.Path)
|
||||
require.Equal(baseURL, "https://"+r.Host+r.URL.Path)
|
||||
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}))
|
||||
defer shutdown()
|
||||
|
||||
client := Client{&httpClient}
|
||||
|
||||
// act
|
||||
actual, err := client.ArtistGetSimilar("apiKey1", "artist1")
|
||||
|
||||
// assert
|
||||
require.Error(err)
|
||||
require.Zero(actual)
|
||||
}
|
||||
|
||||
//go:embed testdata/track_get_similar_response.xml
|
||||
var trackGetSimilaResponse string
|
||||
var trackGetSimilarResponse string
|
||||
|
||||
func TestTrackGetSimilarTracks(t *testing.T) {
|
||||
// arrange
|
||||
@@ -264,7 +373,7 @@ func TestTrackGetSimilarTracks(t *testing.T) {
|
||||
require.Equal(baseURL, "https://"+r.Host+r.URL.Path)
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(trackGetSimilaResponse))
|
||||
w.Write([]byte(trackGetSimilarResponse))
|
||||
}))
|
||||
defer shutdown()
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lfm status="ok">
|
||||
<similarartists artist="Artist 1">
|
||||
<artist>
|
||||
<name>Artist 2</name>
|
||||
<mbid>d2addad9-3fc4-4ce8-9cd4-63f2a19bb922</mbid>
|
||||
<match>1</match>
|
||||
<url>https://www.last.fm/music/Artist+2</url>
|
||||
<image size="small">https://last.fm/artist-2-small.png</image>
|
||||
<image size="large">https://last.fm/artist-2-large.png</image>
|
||||
<streamable>0</streamable>
|
||||
</artist>
|
||||
<artist>
|
||||
<name>Artist 3</name>
|
||||
<mbid>dc95d067-df3e-4b83-a5fe-5ec773b1883f</mbid>
|
||||
<match>0.790991</match>
|
||||
<url>https://www.last.fm/music/Artist+3</url>
|
||||
<image size="small">https://last.fm/artist-3-small.png</image>
|
||||
<image size="large">https://last.fm/artist-3-large.png</image>
|
||||
<streamable>0</streamable>
|
||||
</artist>
|
||||
</similarartists>
|
||||
</lfm>
|
||||
@@ -6,11 +6,15 @@ import (
|
||||
)
|
||||
|
||||
func NewPodcastChannel(p *db.Podcast) *PodcastChannel {
|
||||
desc, err := html2text.FromString(p.Description, html2text.Options{TextOnly: true})
|
||||
if (err != nil) {
|
||||
desc = ""
|
||||
}
|
||||
ret := &PodcastChannel{
|
||||
ID: p.SID(),
|
||||
OriginalImageURL: p.ImageURL,
|
||||
Title: p.Title,
|
||||
Description: p.Description,
|
||||
Description: desc,
|
||||
URL: p.URL,
|
||||
CoverArt: p.SID(),
|
||||
Status: "skipped",
|
||||
|
||||
@@ -20,6 +20,7 @@ type Transcoder interface {
|
||||
|
||||
var UserProfiles = map[string]Profile{
|
||||
"mp3": MP3,
|
||||
"mp3_320": MP3320,
|
||||
"mp3_rg": MP3RG,
|
||||
"opus_car": OpusRGLoud,
|
||||
"opus": Opus,
|
||||
@@ -32,8 +33,9 @@ var UserProfiles = map[string]Profile{
|
||||
|
||||
// Store as simple strings, since we may let the user provide their own profiles soon
|
||||
var (
|
||||
MP3 = NewProfile("audio/mpeg", "mp3", 128, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libmp3lame -f mp3 -`)
|
||||
MP3RG = NewProfile("audio/mpeg", "mp3", 128, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libmp3lame -af "volume=replaygain=track:replaygain_preamp=6dB:replaygain_noclip=0, alimiter=level=disabled, asidedata=mode=delete:type=REPLAYGAIN" -metadata replaygain_album_gain= -metadata replaygain_album_peak= -metadata replaygain_track_gain= -metadata replaygain_track_peak= -metadata r128_album_gain= -metadata r128_track_gain= -f mp3 -`)
|
||||
MP3 = NewProfile("audio/mpeg", "mp3", 128, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libmp3lame -f mp3 -`)
|
||||
MP3320 = NewProfile("audio/mpeg", "mp3", 320, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libmp3lame -f mp3 -`)
|
||||
MP3RG = NewProfile("audio/mpeg", "mp3", 128, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libmp3lame -af "volume=replaygain=track:replaygain_preamp=6dB:replaygain_noclip=0, alimiter=level=disabled, asidedata=mode=delete:type=REPLAYGAIN" -metadata replaygain_album_gain= -metadata replaygain_album_peak= -metadata replaygain_track_gain= -metadata replaygain_track_peak= -metadata r128_album_gain= -metadata r128_track_gain= -f mp3 -`)
|
||||
|
||||
Opus = NewProfile("audio/ogg", "opus", 96, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libopus -vbr on -f opus -`)
|
||||
OpusRG = NewProfile("audio/ogg", "opus", 96, `ffmpeg -v 0 -i <file> -ss <seek> -map 0:a:0 -vn -b:a <bitrate> -c:a libopus -vbr on -af "volume=replaygain=track:replaygain_preamp=6dB:replaygain_noclip=0, alimiter=level=disabled, asidedata=mode=delete:type=REPLAYGAIN" -metadata replaygain_album_gain= -metadata replaygain_album_peak= -metadata replaygain_track_gain= -metadata replaygain_track_peak= -metadata r128_album_gain= -metadata r128_track_gain= -f opus -`)
|
||||
|
||||
Reference in New Issue
Block a user