diff --git a/Web/ClientApp/src/components/DownloadButton.jsx b/Web/ClientApp/src/components/DownloadButton.jsx
index 69dc913..10e4f01 100644
--- a/Web/ClientApp/src/components/DownloadButton.jsx
+++ b/Web/ClientApp/src/components/DownloadButton.jsx
@@ -7,7 +7,8 @@ export default class DownloadButton extends React.Component {
this.state = {
mediaKey: this.props.mediaKey,
isLoading: false,
- mediatype: this.props.mediaType
+ mediatype: this.props.mediaType,
+ mediaFileKey: this.props.mediaFileKey
};
}
@@ -39,6 +40,11 @@ export default class DownloadButton extends React.Component {
season: this.props.season
})
}
+ if (typeof this.props.mediaFileKey !== 'undefined') {
+ input = input + '?' + new URLSearchParams({
+ mediaFileKey: this.props.mediaFileKey
+ })
+ }
return fetch(input, settings)
.then(response => {
if (response.status >= 200 && response.status < 300) {
diff --git a/Web/ClientApp/src/components/Movies.js b/Web/ClientApp/src/components/Movies.js
index 97ca0c6..65608a5 100644
--- a/Web/ClientApp/src/components/Movies.js
+++ b/Web/ClientApp/src/components/Movies.js
@@ -127,7 +127,7 @@ export class Movies extends Component {
{mediaFile.videoCodec} |
{mediaFile.videoResolution} |
{this.humanizeByteSize(mediaFile.totalBytes)} |
- Download |
+ Download |
)
)}
diff --git a/Web/Controllers/DownloadController.cs b/Web/Controllers/DownloadController.cs
index 77756c7..3f78572 100644
--- a/Web/Controllers/DownloadController.cs
+++ b/Web/Controllers/DownloadController.cs
@@ -31,13 +31,13 @@ public async Task> GetPendingDownloads()
}
[HttpPost("movie/{key}")]
- public async Task DownloadMovie( string key, [FromQuery] string mediaFileKey)
+ public async Task DownloadMovie( string key, [FromQuery] string? mediaFileKey)
{
await _downloadService.DownloadMovie(key, mediaFileKey);
}
[HttpPost("episode/{key}")]
- public async Task DownloadEpisode( string key, [FromQuery] string mediaFileKey)
+ public async Task DownloadEpisode( string key, [FromQuery] string? mediaFileKey)
{
await _downloadService.DownloadEpisode(key, mediaFileKey);
}
diff --git a/Web/Services/DownloadService.cs b/Web/Services/DownloadService.cs
index 992e834..1b7a673 100644
--- a/Web/Services/DownloadService.cs
+++ b/Web/Services/DownloadService.cs
@@ -51,7 +51,7 @@ public IReadOnlyCollection GetAll()
return returnList;
}
- private async Task CreateDownloadElement(string key, string mediaFileKey, ElementType elementType)
+ private async Task CreateDownloadElement(string key, string? mediaFileKey, ElementType elementType)
{
using (var scope = _scopeFactory.CreateScope())
{
@@ -60,7 +60,11 @@ private async Task CreateDownloadElement(string key, string med
IMediaElement? mediaElement = await GetMediaElement(unitOfWork, elementType, key);
if (mediaElement == null)
throw new ArgumentException();
- MediaFile? mediaFile = mediaElement.MediaFiles.FirstOrDefault(x => x.DownloadUri == mediaFileKey);
+ MediaFile? mediaFile;
+ if (mediaFileKey == null)
+ mediaFile = await SelectMediaFile(mediaElement.MediaFiles, settingsService);
+ else
+ mediaFile = mediaElement.MediaFiles.FirstOrDefault(x => x.DownloadUri == mediaFileKey);
if (mediaElement == null)
{
_logger.LogError("Could not prepare download of {0} due to missing media file.", mediaElement!.Title);
@@ -265,7 +269,7 @@ private void StartDownloaderIfNotActive()
}
}
- private async Task SelectMediaFile(IEnumerable mediaFiles, SettingsService settingsService)
+ private async Task SelectMediaFile(IEnumerable mediaFiles, ISettingsService settingsService)
{
var preferredResolution = await settingsService.GetPreferredResolution();
var preferredVideoCodec = await settingsService.GetPreferredVideoCodec();