Skip to content

Commit

Permalink
Rename TrackRequest and TrackRequestOptions to DownloadRequest
Browse files Browse the repository at this point in the history
…and `DownloadRequestOptions`
  • Loading branch information
formeo14 committed Oct 21, 2024
1 parent 566529e commit 68e12a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using QobuzApiSharp.Exceptions;
using QobuzApiSharp.Models.Content;
using QobuzApiSharp.Service;
using QobuzDownloaderX.Models;
using QobuzDownloaderX.Models.Content;
using QobuzDownloaderX.Properties;
using QobuzDownloaderX.Shared;
using Requests;
using Requests.Options;
using System;
Expand All @@ -18,9 +18,9 @@
using System.Linq;
using System.Threading.Tasks;

namespace QobuzDownloaderX.Models.Download
namespace QobuzDownloaderX.Shared
{
internal class TrackRequest : Request<TrackRequestOptions, DownloadItem, DownloadItem>, ISpeedReportable
internal class DownloadRequest : Request<DownloadRequestOptions, DownloadItem, DownloadItem>, ISpeedReportable
{
private readonly DownloadLogger _logger;
private readonly DownloadItem _downloadItem;
Expand All @@ -35,7 +35,7 @@ internal class TrackRequest : Request<TrackRequestOptions, DownloadItem, Downloa

public SpeedReporter<long> SpeedReporter => _requestContainer.SpeedReporter;

public TrackRequest(TrackRequestOptions options)
public DownloadRequest(DownloadRequestOptions options)
: base(options)
{
_logger = options.Logger;
Expand Down Expand Up @@ -188,7 +188,7 @@ private bool DownloadTrack(Track qobuzTrack, string basePath, bool isPartOfTrack
if (removeTagArtFileAfterDownload)
{
Notify<IRequest, DownloadItem> x = (_, _) => RemoveTempTaggingArtFile(key);
Options.RequestCompleated = (Notify<IRequest, DownloadItem>)(Delegate.Combine(Options.RequestCompleated, x));
Options.RequestCompleated = (Notify<IRequest, DownloadItem>)Delegate.Combine(Options.RequestCompleated, x);
}
return true;
}
Expand Down Expand Up @@ -304,15 +304,15 @@ private bool DownloadAlbum(Album qobuzAlbum, string basePath, string albumPathSu
{
if (State != RequestState.Running && State != RequestState.Idle)
return false;
bool isLastTrackOfAlbum = (i + tracksPageOffset) == (tracksTotal - 1);
bool isLastTrackOfAlbum = i + tracksPageOffset == tracksTotal - 1;
Track qobuzTrack = qobuzAlbum.Tracks.Items[i];
qobuzTrack.Album = qobuzAlbum;

if (!DownloadTrack(qobuzTrack, basePath, false, isLastTrackOfAlbum, albumPathSuffix))
noErrorsOccured = false;

i++;
if (i == tracksLoaded && tracksTotal > (i + tracksPageOffset))
if (i == tracksLoaded && tracksTotal > i + tracksPageOffset)
{
tracksPageOffset += tracksLimit;
qobuzAlbum = ExecuteApiCall(apiService => apiService.GetAlbum(qobuzAlbum.Id, true, null, tracksLimit, tracksPageOffset));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using QobuzDownloaderX.Shared;
using QobuzDownloaderX.Models;
using Requests.Options;

namespace QobuzDownloaderX.Models.Download
namespace QobuzDownloaderX.Shared
{
public record TrackRequestOptions : RequestOptions<DownloadItem, DownloadItem>
public record DownloadRequestOptions : RequestOptions<DownloadItem, DownloadItem>
{
public DownloadLogger Logger { get; init; }
public DownloadItem DownloadItem { get; init; }
Expand All @@ -14,14 +14,14 @@ public record TrackRequestOptions : RequestOptions<DownloadItem, DownloadItem>
/// <summary>
/// Main Constructor
/// </summary>
public TrackRequestOptions()
public DownloadRequestOptions()
{ }

/// <summary>
/// Copy Constructor
/// </summary>
/// <param name="options">Copied object</param>
protected TrackRequestOptions(TrackRequestOptions options) : base(options)
protected DownloadRequestOptions(DownloadRequestOptions options) : base(options)
{
Logger = options.Logger;
DownloadItem = options.DownloadItem;
Expand Down
5 changes: 2 additions & 3 deletions QobuzDownloaderX/View/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using DownloadAssistant.Requests;
using Newtonsoft.Json.Linq;
using QobuzDownloaderX.Models;
using QobuzDownloaderX.Models.Download;
using QobuzDownloaderX.Properties;
using QobuzDownloaderX.Shared;
using QobuzDownloaderX.View;
Expand Down Expand Up @@ -39,7 +38,7 @@ public QobuzDownloaderX()
};
}

private readonly ExtendedContainer<TrackRequest> _requests = [];
private readonly ExtendedContainer<DownloadRequest> _requests = [];
public string DownloadLogPath { get; set; }

public int DevClickEggThingValue { get; set; }
Expand Down Expand Up @@ -299,7 +298,7 @@ public void StartLinkItemDownload(params string[] downloadLinks)
output.Invoke(new Action(() => output.AppendText($"URL >{downloadItem.Url}< not understood. Is there a typo?\r\n")));

else
_requests.Add(new TrackRequest(new()
_requests.Add(new DownloadRequest(new()
{
DownloadItem = downloadItem,
UpdateAlbumTagsUi = UpdateAlbumTagsUI,
Expand Down

0 comments on commit 68e12a8

Please sign in to comment.