added dropdown menu for importing anime based on the list status for MAL import
This commit is contained in:
parent
bdb9124e14
commit
6d6c88a283
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NzbDrone.Core.ImportLists.MyAnimeList
|
namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||||
|
@ -26,6 +27,20 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||||
|
|
||||||
public class MalAnimeListStatus
|
public class MalAnimeListStatus
|
||||||
{
|
{
|
||||||
public string Status { get; set; }
|
public MalAnimeStatus Status { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MalAnimeStatus
|
||||||
|
{
|
||||||
|
[EnumMember(Value = "watching")]
|
||||||
|
Watching,
|
||||||
|
[EnumMember(Value = "completed")]
|
||||||
|
Completed,
|
||||||
|
[EnumMember(Value = "on_hold")]
|
||||||
|
OnHold,
|
||||||
|
[EnumMember(Value = "dropped")]
|
||||||
|
Dropped,
|
||||||
|
[EnumMember(Value = "plan_to_watch")]
|
||||||
|
PlanToWatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,12 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||||
public MalListSettings()
|
public MalListSettings()
|
||||||
{
|
{
|
||||||
BaseUrl = "https://api.myanimelist.net/v2";
|
BaseUrl = "https://api.myanimelist.net/v2";
|
||||||
|
ListStatus = MalAnimeStatus.Watching;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[FieldDefinition(0, Label = "List Status", Type = FieldType.Select, SelectOptions = typeof(MalAnimeStatus), HelpText = "Type of list status you're seeking to import from")]
|
||||||
|
public MalAnimeStatus ListStatus { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Client ID", Type = FieldType.Textbox)]
|
[FieldDefinition(0, Label = "Client ID", Type = FieldType.Textbox)]
|
||||||
public string ClientId { get; set; }
|
public string ClientId { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
|
|
||||||
namespace NzbDrone.Core.ImportLists.MyAnimeList
|
namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||||
{
|
{
|
||||||
public enum MalUserListType
|
|
||||||
{
|
|
||||||
Watching,
|
|
||||||
Completed,
|
|
||||||
OnHold,
|
|
||||||
Dropped,
|
|
||||||
PlanToWatch
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MalRequestGenerator : IImportListRequestGenerator
|
public class MalRequestGenerator : IImportListRequestGenerator
|
||||||
{
|
{
|
||||||
public MalListSettings Settings { get; set; }
|
public MalListSettings Settings { get; set; }
|
||||||
|
@ -27,7 +20,8 @@ namespace NzbDrone.Core.ImportLists.MyAnimeList
|
||||||
|
|
||||||
private IEnumerable<ImportListRequest> GetSeriesRequest()
|
private IEnumerable<ImportListRequest> GetSeriesRequest()
|
||||||
{
|
{
|
||||||
var url = $"{Settings.BaseUrl.Trim()}/users/@me/animelist?fields=list_status";
|
var selectedListStatus = JsonConvert.SerializeObject(Settings.ListStatus, new StringEnumConverter()).Replace("\"", "");
|
||||||
|
var url = $"{Settings.BaseUrl.Trim()}/users/@me/animelist?fields=list_status&limit=1000&status={selectedListStatus}";
|
||||||
|
|
||||||
var httpReq = new ImportListRequest(url, HttpAccept.Json);
|
var httpReq = new ImportListRequest(url, HttpAccept.Json);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue