mirror of https://github.com/lidarr/Lidarr
Merge 961484412a
into 416d505316
This commit is contained in:
commit
464e236ee0
|
@ -5,6 +5,7 @@ using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Localization;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
@ -22,13 +23,18 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
IConfigService configService,
|
IConfigService configService,
|
||||||
IParsingService parsingService,
|
IParsingService parsingService,
|
||||||
IHttpClient httpClient,
|
IHttpClient httpClient,
|
||||||
|
ILocalizationService localizationService,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
: base(spotifyProxy, requestBuilder, importListStatusService, importListRepository, configService, parsingService, httpClient, logger)
|
: base(spotifyProxy, requestBuilder, importListStatusService, importListRepository, configService, parsingService, httpClient, logger)
|
||||||
{
|
{
|
||||||
|
_localizationService = localizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const string LIKED_SONGS_ID = "LikedSongs";
|
||||||
public override string Name => "Spotify Playlists";
|
public override string Name => "Spotify Playlists";
|
||||||
|
|
||||||
|
private readonly ILocalizationService _localizationService;
|
||||||
|
|
||||||
public override IList<SpotifyImportListItemInfo> Fetch(SpotifyWebAPI api)
|
public override IList<SpotifyImportListItemInfo> Fetch(SpotifyWebAPI api)
|
||||||
{
|
{
|
||||||
return Settings.PlaylistIds.SelectMany(x => Fetch(api, x)).ToList();
|
return Settings.PlaylistIds.SelectMany(x => Fetch(api, x)).ToList();
|
||||||
|
@ -40,7 +46,27 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
|
|
||||||
_logger.Trace($"Processing playlist {playlistId}");
|
_logger.Trace($"Processing playlist {playlistId}");
|
||||||
|
|
||||||
var playlistTracks = _spotifyProxy.GetPlaylistTracks(this, api, playlistId, "next, items(track(name, artists(id, name), album(id, name, release_date, release_date_precision, artists(id, name))))");
|
Paging<PlaylistTrack> playlistTracks;
|
||||||
|
|
||||||
|
if (playlistId.Equals(LIKED_SONGS_ID))
|
||||||
|
{
|
||||||
|
var savedTracks = _spotifyProxy.GetSavedTracks(this, api);
|
||||||
|
playlistTracks = new Paging<PlaylistTrack>
|
||||||
|
{
|
||||||
|
Href = savedTracks.Href,
|
||||||
|
Limit = savedTracks.Limit,
|
||||||
|
Offset = savedTracks.Offset,
|
||||||
|
Next = savedTracks.Next,
|
||||||
|
Previous = savedTracks.Previous,
|
||||||
|
Total = savedTracks.Total,
|
||||||
|
Error = savedTracks.Error,
|
||||||
|
Items = savedTracks.Items.Select(t => new PlaylistTrack { AddedAt = t.AddedAt, Track = t.Track }).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playlistTracks = _spotifyProxy.GetPlaylistTracks(this, api, playlistId, "next, items(track(name, artists(id, name), album(id, name, release_date, release_date_precision, artists(id, name))))");
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +166,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
{
|
{
|
||||||
id = p.Id,
|
id = p.Id,
|
||||||
name = p.Name
|
name = p.Name
|
||||||
})
|
}).Prepend(new { id = LIKED_SONGS_ID, name = _localizationService.GetLocalizedString("LikedSongs") })
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
PlaylistIds = System.Array.Empty<string>();
|
PlaylistIds = System.Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Scope => "playlist-read-private";
|
public override string Scope => "playlist-read-private user-library-read";
|
||||||
|
|
||||||
[FieldDefinition(1, Label = "Playlists", Type = FieldType.Playlist)]
|
[FieldDefinition(1, Label = "Playlists", Type = FieldType.Playlist)]
|
||||||
public IEnumerable<string> PlaylistIds { get; set; }
|
public IEnumerable<string> PlaylistIds { get; set; }
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
where TSettings : SpotifySettingsBase<TSettings>, new();
|
where TSettings : SpotifySettingsBase<TSettings>, new();
|
||||||
Paging<PlaylistTrack> GetPlaylistTracks<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, string id, string fields)
|
Paging<PlaylistTrack> GetPlaylistTracks<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, string id, string fields)
|
||||||
where TSettings : SpotifySettingsBase<TSettings>, new();
|
where TSettings : SpotifySettingsBase<TSettings>, new();
|
||||||
|
Paging<SavedTrack> GetSavedTracks<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api)
|
||||||
|
where TSettings : SpotifySettingsBase<TSettings>, new();
|
||||||
Paging<T> GetNextPage<T, TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, Paging<T> item)
|
Paging<T> GetNextPage<T, TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, Paging<T> item)
|
||||||
where TSettings : SpotifySettingsBase<TSettings>, new();
|
where TSettings : SpotifySettingsBase<TSettings>, new();
|
||||||
FollowedArtists GetNextPage<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, FollowedArtists item)
|
FollowedArtists GetNextPage<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, FollowedArtists item)
|
||||||
|
@ -63,6 +65,12 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
return Execute(list, api, x => x.GetPlaylistTracks(id, fields: fields));
|
return Execute(list, api, x => x.GetPlaylistTracks(id, fields: fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Paging<SavedTrack> GetSavedTracks<TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api)
|
||||||
|
where TSettings : SpotifySettingsBase<TSettings>, new()
|
||||||
|
{
|
||||||
|
return Execute(list, api, x => x.GetSavedTracks(50));
|
||||||
|
}
|
||||||
|
|
||||||
public Paging<T> GetNextPage<T, TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, Paging<T> item)
|
public Paging<T> GetNextPage<T, TSettings>(SpotifyImportListBase<TSettings> list, SpotifyWebAPI api, Paging<T> item)
|
||||||
where TSettings : SpotifySettingsBase<TSettings>, new()
|
where TSettings : SpotifySettingsBase<TSettings>, new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -640,6 +640,7 @@
|
||||||
"LidarrSupportsAnyIndexerThatUsesTheNewznabStandardAsWellAsOtherIndexersListedBelow": "{appName} supports any indexer that uses the Newznab standard, as well as other indexers listed below.",
|
"LidarrSupportsAnyIndexerThatUsesTheNewznabStandardAsWellAsOtherIndexersListedBelow": "{appName} supports any indexer that uses the Newznab standard, as well as other indexers listed below.",
|
||||||
"LidarrSupportsMultipleListsForImportingAlbumsAndArtistsIntoTheDatabase": "{appName} supports multiple lists for importing Albums and Artists into the database.",
|
"LidarrSupportsMultipleListsForImportingAlbumsAndArtistsIntoTheDatabase": "{appName} supports multiple lists for importing Albums and Artists into the database.",
|
||||||
"LidarrTags": "{appName} Tags",
|
"LidarrTags": "{appName} Tags",
|
||||||
|
"LikedSongs": "Liked Songs",
|
||||||
"Links": "Links",
|
"Links": "Links",
|
||||||
"ListRefreshInterval": "List Refresh Interval",
|
"ListRefreshInterval": "List Refresh Interval",
|
||||||
"ListWillRefreshEveryInterp": "List will refresh every {0}",
|
"ListWillRefreshEveryInterp": "List will refresh every {0}",
|
||||||
|
|
Loading…
Reference in New Issue