Skip to content

Commit

Permalink
Switch to new node Deemix app
Browse files Browse the repository at this point in the history
  • Loading branch information
ta264 committed Mar 23, 2022
1 parent 43ed5f3 commit 501433b
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 663 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
PLUGIN_NAME: Lidarr.Plugin.Deemix
PLUGIN_VERSION: 1.0.0.${{ github.run_number }}
MINIMUM_LIDARR_VERSION: 1.0.0.2344
MINIMUM_LIDARR_VERSION: 1.0.0.2498
jobs:
build:
strategy:
matrix:
framework: [ net5.0 ]
framework: [ net6.0 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.402
dotnet-version: 6.0.101
- name: Update Version Info
run: |
echo $PLUGIN_VERSION
Expand All @@ -43,10 +43,10 @@ jobs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Download Artifact (net5.0)
- name: Download Artifact (net6.0)
uses: actions/download-artifact@v2
with:
name: net5.0
name: net6.0
- uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -60,5 +60,5 @@ jobs:
draft: true
prerelease: true
files: >
${{ env.PLUGIN_NAME }}.net5.0.zip
${{ env.PLUGIN_NAME }}.net6.0.zip
gzip: false
2 changes: 1 addition & 1 deletion src/Lidarr
Submodule Lidarr updated 598 files
40 changes: 18 additions & 22 deletions src/Lidarr.Plugin.Deemix/Download/Clients/Deemix/Deemix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ namespace NzbDrone.Core.Download.Clients.Deemix
{
public class Deemix : DownloadClientBase<DeemixSettings>
{
private readonly IDeemixProxyManager _proxyManager;
private readonly IDeemixProxy _proxy;

public Deemix(IConfigService configService,
public Deemix(IDeemixProxy proxy,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IDeemixProxyManager proxyManager,
Logger logger)
: base(configService, diskProvider, remotePathMappingService, logger)
{
_proxyManager = proxyManager;
_proxy = proxy;
}

public override string Protocol => nameof(DeemixDownloadProtocol);
Expand All @@ -33,9 +33,7 @@ public Deemix(IConfigService configService,

public override IEnumerable<DownloadClientItem> GetItems()
{
var proxy = _proxyManager.GetProxy(Settings);

var queue = proxy.GetQueue();
var queue = _proxy.GetQueue(Settings);

foreach (var item in queue)
{
Expand All @@ -46,22 +44,18 @@ public override IEnumerable<DownloadClientItem> GetItems()
return queue;
}

public override void RemoveItem(string downloadId, bool deleteData)
public override void RemoveItem(DownloadClientItem item, bool deleteData)
{
var proxy = _proxyManager.GetProxy(Settings);

if (deleteData)
{
DeleteItemData(downloadId);
DeleteItemData(item);
}

proxy.RemoveFromQueue(downloadId);
_proxy.RemoveFromQueue(item.DownloadId, Settings);
}

public override string Download(RemoteAlbum remoteAlbum)
{
var proxy = _proxyManager.GetProxy(Settings);

var release = remoteAlbum.Release;

int bitrate;
Expand All @@ -79,13 +73,12 @@ public override string Download(RemoteAlbum remoteAlbum)
bitrate = 1;
}

return proxy.Download(release.DownloadUrl, bitrate);
return _proxy.Download(release.DownloadUrl, bitrate, Settings);
}

public override DownloadClientInfo GetStatus()
{
var proxy = _proxyManager.GetProxy(Settings);
var config = proxy.GetSettings();
var config = _proxy.GetSettings(Settings);

return new DownloadClientInfo
{
Expand All @@ -101,8 +94,7 @@ protected override void Test(List<ValidationFailure> failures)

private ValidationFailure TestSettings()
{
var proxy = _proxyManager.GetProxy(Settings);
var config = proxy.GetSettings();
var config = _proxy.GetSettings(Settings);

if (!config.CreateAlbumFolder)
{
Expand All @@ -122,12 +114,16 @@ private ValidationFailure TestSettings()
};
}

if (!config.SaveDownloadQueue)
try
{
_proxy.Authenticate(Settings);
}
catch (DownloadClientException)
{
return new NzbDroneValidationFailure(string.Empty, "Deemix must have 'Save Download Queue' enabled")
return new NzbDroneValidationFailure(string.Empty, "Could not login to Deemix. Invalid ARL?")
{
InfoLink = HttpRequestBuilder.BuildBaseUrl(Settings.UseSsl, Settings.Host, Settings.Port, Settings.UrlBase),
DetailedDescription = "Deemix must have 'Save Download Queue' enabled, otherwise Lidarr won't be able to import if deemix restarts",
DetailedDescription = "Deemix requires a valid ARL to initiate downloads",
};
}

Expand Down
113 changes: 93 additions & 20 deletions src/Lidarr.Plugin.Deemix/Download/Clients/Deemix/DeemixApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,56 @@

namespace NzbDrone.Core.Download.Clients.Deemix
{
public class DeemixResult<T>
where T : new()
{
public bool Result { get; set; }

public string Errid { get; set; }

public T Data { get; set; }
}

public class DeemixConfigResult
{
public DeemixConfig Settings { get; set; }
}

public class DeemixConfig
{
public string DownloadLocation { get; set; }
public bool CreateAlbumFolder { get; set; }
public bool CreateSingleFolder { get; set; }
}

public class DeemixConnect
{
public DeemixUser CurrentUser { get; set; }
}

public class DeemixUser
{
public long Id { get; set; }
public string Name { get; set; }
[JsonProperty("can_stream_hq")]
public bool CanStreamHq { get; set; }
[JsonProperty("can_stream_lossless")]
public bool CanStreamLossless { get; set; }
}

public class DeemixAddResult
{
public List<string> Url { get; set; }
public string Bitrate { get; set; }
public List<DeemixQueueItem> Obj { get; set; }
}

public class DeemixQueue
{
public Dictionary<string, DeemixQueueItem> Queue { get; set; }
public List<int> QueueOrder { get; set; }
}

public class DeemixQueueItem
{
public string Title { get; set; }
Expand All @@ -16,36 +66,17 @@ public class DeemixQueueItem
public bool Failed { get; set; }
public List<object> Errors { get; set; }
public int Progress { get; set; }
public List<string> Files { get; set; }
public List<DeemixFile> Files { get; set; }
public string Type { get; set; }
public string Id { get; set; }
public string Bitrate { get; set; }
public string Uuid { get; set; }
public int? Ack { get; set; }
}

public class DeemixQueueUpdate
{
public string Uuid { get; set; }
public string DownloadPath { get; set; }
public string ExtrasPath { get; set; }
public int? Progress { get; set; }
}

public class DeemixQueue
{
public List<string> Queue { get; set; }
public List<string> QueueComplete { get; set; }
public Dictionary<string, DeemixQueueItem> QueueList { get; set; }
public string CurrentItem { get; set; }
}

public class DeemixSearchResponse
{
public IList<DeemixGwAlbum> Data { get; set; }
public int Total { get; set; }
public string Next { get; set; }
public int? Ack { get; set; }
}

public class ExplicitAlbumContent
Expand Down Expand Up @@ -92,4 +123,46 @@ public class DeemixGwAlbum

public bool Explicit => ExplicitAlbumContent?.ExplicitLyrics == 1 || ExplicitAlbumContent.ExplicitCover == 1;
}

public class DeemixAlbumUrl
{
[JsonProperty("url")]
public string Url { get; set; }

[JsonProperty("ext")]
public string Ext { get; set; }
}

public class DeemixFileData
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("artist")]
public string Artist { get; set; }
}

public class DeemixFile
{
[JsonProperty("albumURLs")]
public List<DeemixAlbumUrl> AlbumUrls { get; set; }

[JsonProperty("albumPath")]
public string AlbumPath { get; set; }

[JsonProperty("albumFilename")]
public string AlbumFilename { get; set; }

[JsonProperty("filename")]
public string Filename { get; set; }

[JsonProperty("data")]
public DeemixFileData Data { get; set; }

[JsonProperty("path")]
public string Path { get; set; }
}
}
83 changes: 0 additions & 83 deletions src/Lidarr.Plugin.Deemix/Download/Clients/Deemix/DeemixConfig.cs

This file was deleted.

Loading

0 comments on commit 501433b

Please sign in to comment.