From 755588b399813e8624e59ffbc439ff2849c3f66e Mon Sep 17 00:00:00 2001 From: zexuz Date: Mon, 22 Apr 2019 01:17:18 +0200 Subject: [PATCH] You can now download files from the media server for offline watching --- .../csharp/FileDownload.cs | 48 +++++++++++++++---- SnackTime.MediaServer.Proto/csharp/Storage.cs | 43 ++++++++++++++--- .../proto/file-service/file-download.proto | 2 +- .../proto/storage.proto | 1 + SnackTime.MediaServer/FileController.cs | 27 +++++++++-- .../Controllers/FileController.cs | 9 ++-- .../Services/FileDownloadService.cs | 25 ++++++---- app/src/logic/api/protogen/types.d.ts | 12 +++++ app/src/logic/api/protogen/types.js | 18 +++++++ app/src/views/Series.vue | 15 +++++- 10 files changed, 166 insertions(+), 34 deletions(-) diff --git a/SnackTime.MediaServer.Proto/csharp/FileDownload.cs b/SnackTime.MediaServer.Proto/csharp/FileDownload.cs index 252eb4f..f8383ac 100644 --- a/SnackTime.MediaServer.Proto/csharp/FileDownload.cs +++ b/SnackTime.MediaServer.Proto/csharp/FileDownload.cs @@ -25,19 +25,19 @@ static FileDownloadReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiZwcm90by9maWxlLXNlcnZpY2UvZmlsZS1kb3dubG9hZC5wcm90bxIVc25h", - "Y2t0aW1lLnNlcmllcy5maWxlIhUKE0Rvd25sb2FkRmlsZVJlcXVlc3QisAEK", - "FFJlc3BvbnNlRG93bmxvYWRGaWxlEjEKB3N0YXJ0ZWQYASABKAsyHi5zbmFj", - "a3RpbWUuc2VyaWVzLmZpbGUuU3RhcnRlZEgAEjAKCHByb2dyZXNzGAIgASgL", - "Mhwuc25hY2t0aW1lLnNlcmllcy5maWxlLkNodW5rSAASKwoEZG9uZRgDIAEo", - "CzIbLnNuYWNrdGltZS5zZXJpZXMuZmlsZS5Eb25lSABCBgoEdHlwZSJBCgdT", - "dGFydGVkEg4KBmxlbmdodBgBIAEoARIUCgxzaXplUGVyQ2h1bmsYAiABKAUS", - "EAoIRmlsZU5hbWUYAyABKAkiGAoFQ2h1bmsSDwoHQ29udGVudBgBIAEoDCIU", - "CgREb25lEgwKBEhhc2gYASABKAlCJaoCIlNuYWNrVGltZS5NZWRpYVNlcnZl", - "ci5TZXJ2aWNlLkZpbGViBnByb3RvMw==")); + "Y2t0aW1lLnNlcmllcy5maWxlIioKE0Rvd25sb2FkRmlsZVJlcXVlc3QSEwoL", + "bWVkaWFGaWxlSWQYASABKAkisAEKFFJlc3BvbnNlRG93bmxvYWRGaWxlEjEK", + "B3N0YXJ0ZWQYASABKAsyHi5zbmFja3RpbWUuc2VyaWVzLmZpbGUuU3RhcnRl", + "ZEgAEjAKCHByb2dyZXNzGAIgASgLMhwuc25hY2t0aW1lLnNlcmllcy5maWxl", + "LkNodW5rSAASKwoEZG9uZRgDIAEoCzIbLnNuYWNrdGltZS5zZXJpZXMuZmls", + "ZS5Eb25lSABCBgoEdHlwZSJBCgdTdGFydGVkEg4KBmxlbmdodBgBIAEoARIU", + "CgxzaXplUGVyQ2h1bmsYAiABKAUSEAoIRmlsZU5hbWUYAyABKAkiGAoFQ2h1", + "bmsSDwoHQ29udGVudBgBIAEoDCIUCgREb25lEgwKBEhhc2gYASABKAlCJaoC", + "IlNuYWNrVGltZS5NZWRpYVNlcnZlci5TZXJ2aWNlLkZpbGViBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Service.File.DownloadFileRequest), global::SnackTime.MediaServer.Service.File.DownloadFileRequest.Parser, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Service.File.DownloadFileRequest), global::SnackTime.MediaServer.Service.File.DownloadFileRequest.Parser, new[]{ "MediaFileId" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Service.File.ResponseDownloadFile), global::SnackTime.MediaServer.Service.File.ResponseDownloadFile.Parser, new[]{ "Started", "Progress", "Done" }, new[]{ "Type" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Service.File.Started), global::SnackTime.MediaServer.Service.File.Started.Parser, new[]{ "Lenght", "SizePerChunk", "FileName" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Service.File.Chunk), global::SnackTime.MediaServer.Service.File.Chunk.Parser, new[]{ "Content" }, null, null, null), @@ -73,6 +73,7 @@ public DownloadFileRequest() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DownloadFileRequest(DownloadFileRequest other) : this() { + mediaFileId_ = other.mediaFileId_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -81,6 +82,17 @@ public DownloadFileRequest Clone() { return new DownloadFileRequest(this); } + /// Field number for the "mediaFileId" field. + public const int MediaFileIdFieldNumber = 1; + private string mediaFileId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string MediaFileId { + get { return mediaFileId_; } + set { + mediaFileId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as DownloadFileRequest); @@ -94,12 +106,14 @@ public bool Equals(DownloadFileRequest other) { if (ReferenceEquals(other, this)) { return true; } + if (MediaFileId != other.MediaFileId) return false; return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (MediaFileId.Length != 0) hash ^= MediaFileId.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -113,6 +127,10 @@ public override string ToString() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (MediaFileId.Length != 0) { + output.WriteRawTag(10); + output.WriteString(MediaFileId); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -121,6 +139,9 @@ public void WriteTo(pb::CodedOutputStream output) { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (MediaFileId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(MediaFileId); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -132,6 +153,9 @@ public void MergeFrom(DownloadFileRequest other) { if (other == null) { return; } + if (other.MediaFileId.Length != 0) { + MediaFileId = other.MediaFileId; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -143,6 +167,10 @@ public void MergeFrom(pb::CodedInputStream input) { default: _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; + case 10: { + MediaFileId = input.ReadString(); + break; + } } } } diff --git a/SnackTime.MediaServer.Proto/csharp/Storage.cs b/SnackTime.MediaServer.Proto/csharp/Storage.cs index 0e9f7b2..00f5313 100644 --- a/SnackTime.MediaServer.Proto/csharp/Storage.cs +++ b/SnackTime.MediaServer.Proto/csharp/Storage.cs @@ -27,19 +27,20 @@ static StorageReflection() { "ChNwcm90by9zdG9yYWdlLnByb3RvEhFzbmFja3RpbWUuc3RvcmFnZSJfCglN", "ZWRpYUZpbGUSEAoIZmlsZU5hbWUYASABKAkSEQoJbWVkaWFOYW1lGAIgASgJ", "EhUKDWRvd25sb2FkZWRVVEMYAyABKAkSFgoObGFzdFdhdGNoZWRVVEMYBCAB", - "KAkikQEKB1Nlc3Npb24SCgoCaWQYASABKAkSEAoIc3RhcnRVVEMYAiABKAMS", + "KAkipQEKB1Nlc3Npb24SCgoCaWQYASABKAkSEAoIc3RhcnRVVEMYAiABKAMS", "DgoGZW5kVVRDGAMgASgDEg8KB21lZGlhSWQYBCABKAkSLQoIZHVyYXRpb24Y", "BSABKAsyGy5zbmFja3RpbWUuc3RvcmFnZS5EdXJhdGlvbhIYChBtZWRpYUxl", - "bmdodEluU2VjGAYgASgBIj4KCER1cmF0aW9uEhkKEXN0YXJ0UG9zdGlvbklu", - "U2VjGAEgASgBEhcKD2VuZFBvc3Rpb25JblNlYxgCIAEoASJICghQcm9ncmVz", - "cxIUCgx3YXRjaGVkSW5TZWMYASABKAESDgoGbGVuZ2h0GAIgASgBEhYKDmxh", - "c3RXYXRjaGVkVXRjGAMgASgBQi+qAixTbmFja1RpbWUuTWVkaWFTZXJ2ZXIu", - "U3RvcmFnZS5Qcm90b0dlbmVyYXRlZGIGcHJvdG8z")); + "bmdodEluU2VjGAYgASgBEhIKCmZyb21EZXZpY2UYByABKAkiPgoIRHVyYXRp", + "b24SGQoRc3RhcnRQb3N0aW9uSW5TZWMYASABKAESFwoPZW5kUG9zdGlvbklu", + "U2VjGAIgASgBIkgKCFByb2dyZXNzEhQKDHdhdGNoZWRJblNlYxgBIAEoARIO", + "CgZsZW5naHQYAiABKAESFgoObGFzdFdhdGNoZWRVdGMYAyABKAFCL6oCLFNu", + "YWNrVGltZS5NZWRpYVNlcnZlci5TdG9yYWdlLlByb3RvR2VuZXJhdGVkYgZw", + "cm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Storage.ProtoGenerated.MediaFile), global::SnackTime.MediaServer.Storage.ProtoGenerated.MediaFile.Parser, new[]{ "FileName", "MediaName", "DownloadedUTC", "LastWatchedUTC" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Storage.ProtoGenerated.Session), global::SnackTime.MediaServer.Storage.ProtoGenerated.Session.Parser, new[]{ "Id", "StartUTC", "EndUTC", "MediaId", "Duration", "MediaLenghtInSec" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Storage.ProtoGenerated.Session), global::SnackTime.MediaServer.Storage.ProtoGenerated.Session.Parser, new[]{ "Id", "StartUTC", "EndUTC", "MediaId", "Duration", "MediaLenghtInSec", "FromDevice" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Storage.ProtoGenerated.Duration), global::SnackTime.MediaServer.Storage.ProtoGenerated.Duration.Parser, new[]{ "StartPostionInSec", "EndPostionInSec" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SnackTime.MediaServer.Storage.ProtoGenerated.Progress), global::SnackTime.MediaServer.Storage.ProtoGenerated.Progress.Parser, new[]{ "WatchedInSec", "Lenght", "LastWatchedUtc" }, null, null, null) })); @@ -292,6 +293,7 @@ public Session(Session other) : this() { mediaId_ = other.mediaId_; duration_ = other.duration_ != null ? other.duration_.Clone() : null; mediaLenghtInSec_ = other.mediaLenghtInSec_; + fromDevice_ = other.fromDevice_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -366,6 +368,17 @@ public double MediaLenghtInSec { } } + /// Field number for the "fromDevice" field. + public const int FromDeviceFieldNumber = 7; + private string fromDevice_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string FromDevice { + get { return fromDevice_; } + set { + fromDevice_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Session); @@ -385,6 +398,7 @@ public bool Equals(Session other) { if (MediaId != other.MediaId) return false; if (!object.Equals(Duration, other.Duration)) return false; if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(MediaLenghtInSec, other.MediaLenghtInSec)) return false; + if (FromDevice != other.FromDevice) return false; return Equals(_unknownFields, other._unknownFields); } @@ -397,6 +411,7 @@ public override int GetHashCode() { if (MediaId.Length != 0) hash ^= MediaId.GetHashCode(); if (duration_ != null) hash ^= Duration.GetHashCode(); if (MediaLenghtInSec != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(MediaLenghtInSec); + if (FromDevice.Length != 0) hash ^= FromDevice.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -434,6 +449,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(49); output.WriteDouble(MediaLenghtInSec); } + if (FromDevice.Length != 0) { + output.WriteRawTag(58); + output.WriteString(FromDevice); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -460,6 +479,9 @@ public int CalculateSize() { if (MediaLenghtInSec != 0D) { size += 1 + 8; } + if (FromDevice.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FromDevice); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -492,6 +514,9 @@ public void MergeFrom(Session other) { if (other.MediaLenghtInSec != 0D) { MediaLenghtInSec = other.MediaLenghtInSec; } + if (other.FromDevice.Length != 0) { + FromDevice = other.FromDevice; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -530,6 +555,10 @@ public void MergeFrom(pb::CodedInputStream input) { MediaLenghtInSec = input.ReadDouble(); break; } + case 58: { + FromDevice = input.ReadString(); + break; + } } } } diff --git a/SnackTime.MediaServer.Proto/proto/file-service/file-download.proto b/SnackTime.MediaServer.Proto/proto/file-service/file-download.proto index b4c2523..7dc4458 100644 --- a/SnackTime.MediaServer.Proto/proto/file-service/file-download.proto +++ b/SnackTime.MediaServer.Proto/proto/file-service/file-download.proto @@ -6,7 +6,7 @@ package snacktime.series.file; message DownloadFileRequest { - + string mediaFileId = 1; } message ResponseDownloadFile { diff --git a/SnackTime.MediaServer.Proto/proto/storage.proto b/SnackTime.MediaServer.Proto/proto/storage.proto index 5f9db8e..2021404 100644 --- a/SnackTime.MediaServer.Proto/proto/storage.proto +++ b/SnackTime.MediaServer.Proto/proto/storage.proto @@ -19,6 +19,7 @@ message Session { string mediaId = 4; Duration duration = 5; double mediaLenghtInSec = 6; + string fromDevice = 7; } message Duration { diff --git a/SnackTime.MediaServer/FileController.cs b/SnackTime.MediaServer/FileController.cs index c28755c..5eda3db 100644 --- a/SnackTime.MediaServer/FileController.cs +++ b/SnackTime.MediaServer/FileController.cs @@ -1,9 +1,12 @@ using System; using System.IO; using System.Security.Cryptography; +using System.Threading; using System.Threading.Tasks; using Google.Protobuf; using Grpc.Core; +using SnackTime.Core; +using SnackTime.Core.Media.Episodes; using SnackTime.MediaServer.Service.File; using File = System.IO.File; @@ -11,6 +14,13 @@ namespace SnackTime.MediaServer { class FileController : SnackTime.MediaServer.Service.File.File.FileBase { + private readonly EpisodeFileLookupProvider _episodeFileLookupProvider; + + public FileController(EpisodeFileLookupProvider episodeFileLookupProvider) + { + _episodeFileLookupProvider = episodeFileLookupProvider; + } + public override async Task Download ( DownloadFileRequest request, @@ -18,10 +28,21 @@ public override async Task Download ServerCallContext context ) { - var fileName = "Superstore.S04E15.1080p.WEB.H264-METCON.mkv"; - var path = @"D:\Downloads\Torrents\Superstore.S04E15.1080p.WEB.H264-METCON\"; + if (!MediaFileId.TryParse(request.MediaFileId, out var mediaFileId)) + { + throw new Exception("Invalid mediaFileId"); + } + + var info = await _episodeFileLookupProvider.GetFileInfoForId(mediaFileId.FileId); + + + var backSlashIndex = info.Path.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase); + var index = backSlashIndex > -1 ? backSlashIndex : info.Path.LastIndexOf("/", StringComparison.CurrentCultureIgnoreCase); + + var fileName = info.Path.Substring(index + 1); + var chunkSize = 2048; - using (Stream source = File.OpenRead(path + fileName)) + using (Stream source = File.OpenRead(info.Path)) { byte[] buffer = new byte[chunkSize]; int bytesRead; diff --git a/SnackTime.WebApi/Controllers/FileController.cs b/SnackTime.WebApi/Controllers/FileController.cs index 51c806b..b62c6cb 100644 --- a/SnackTime.WebApi/Controllers/FileController.cs +++ b/SnackTime.WebApi/Controllers/FileController.cs @@ -20,10 +20,13 @@ public FileController(FileDownloadService fileDownloadService) _fileDownloadService = fileDownloadService; } - [HttpGet("download")] - public async Task DownloadFile() + [HttpGet("download/{mediaFileIdStr}")] + public async Task DownloadFile(string mediaFileIdStr) { - await _fileDownloadService.DownloadFile(); + if (!MediaFileId.TryParse(mediaFileIdStr, out var mediaFileId)) + return BadRequest($"{nameof(mediaFileIdStr)} is invalid"); + + await _fileDownloadService.DownloadFile(mediaFileId); return StatusCode(202); } } diff --git a/SnackTime.WebApi/Services/FileDownloadService.cs b/SnackTime.WebApi/Services/FileDownloadService.cs index ebe1da8..c3fd2ca 100644 --- a/SnackTime.WebApi/Services/FileDownloadService.cs +++ b/SnackTime.WebApi/Services/FileDownloadService.cs @@ -5,6 +5,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using SnackTime.Core; +using SnackTime.Core.Settings; using SnackTime.MediaServer.Service.File; using File = System.IO.File; @@ -15,22 +17,31 @@ public class FileDownloadService private readonly ILogger _logger; private readonly MediaServer.Service.File.File.FileClient _client; private readonly FileService _fileService; + private readonly SettingsService _settingsService; public FileDownloadService ( ILogger logger, MediaServer.Service.File.File.FileClient client, - FileService fileService + FileService fileService, + SettingsService settingsService ) { _logger = logger; _client = client; _fileService = fileService; + _settingsService = settingsService; } - public async Task DownloadFile() + public async Task DownloadFile(MediaFileId id) { - var streamingCall = _client.Download(new DownloadFileRequest()); + var streamingCall = _client.Download(new DownloadFileRequest + { + MediaFileId = id.ToString(), + }); + + var settings = _settingsService.Get(); + double nrOfChunks = 0; @@ -39,11 +50,9 @@ public async Task DownloadFile() FileStream fileStream = null; - const string tempPath = "D:\\SnackTime\\Temp\\"; const int tempFileSize = 1024 * 10 * 10; var fileName = ""; - var fileOutputPath = "D:\\SnackTime\\"; _logger.LogInformation($"Starting to download file"); @@ -70,7 +79,7 @@ public async Task DownloadFile() fileStream.Dispose(); } - fileStream = File.Create(tempPath + $"{fileName}.{currentTempFileIndex}.temp"); + fileStream = File.Create(settings.TempFileDir + $"{fileName}.{currentTempFileIndex}.temp"); currentTempFileIndex++; } @@ -93,10 +102,10 @@ public async Task DownloadFile() var sw = Stopwatch.StartNew(); var filePattern = $"{fileName}.*.temp"; - await _fileService.CombineMultipleFilesIntoSingleFile(tempPath, filePattern, fileOutputPath + fileName); + await _fileService.CombineMultipleFilesIntoSingleFile(settings.TempFileDir, filePattern, settings.FileDir + fileName); string hash; - using (Stream source = File.OpenRead(fileOutputPath + fileName)) + using (Stream source = File.OpenRead(settings.FileDir + fileName)) using (var md5 = MD5.Create()) { var byteHash = md5.ComputeHash(source); diff --git a/app/src/logic/api/protogen/types.d.ts b/app/src/logic/api/protogen/types.d.ts index 83413a2..cae2570 100644 --- a/app/src/logic/api/protogen/types.d.ts +++ b/app/src/logic/api/protogen/types.d.ts @@ -155,6 +155,9 @@ export namespace snacktime { /** Properties of a DownloadFileRequest. */ interface IDownloadFileRequest { + + /** DownloadFileRequest mediaFileId */ + mediaFileId?: (string|null); } /** Represents a DownloadFileRequest. */ @@ -165,6 +168,9 @@ export namespace snacktime { * @param [properties] Properties to set */ constructor(properties?: snacktime.series.file.IDownloadFileRequest); + + /** DownloadFileRequest mediaFileId. */ + public mediaFileId: string; } /** Properties of a ResponseDownloadFile. */ @@ -763,6 +769,9 @@ export namespace snacktime { /** Session mediaLenghtInSec */ mediaLenghtInSec?: (number|null); + + /** Session fromDevice */ + fromDevice?: (string|null); } /** Represents a Session. */ @@ -791,6 +800,9 @@ export namespace snacktime { /** Session mediaLenghtInSec. */ public mediaLenghtInSec: number; + + /** Session fromDevice. */ + public fromDevice: string; } /** Properties of a Duration. */ diff --git a/app/src/logic/api/protogen/types.js b/app/src/logic/api/protogen/types.js index 1058020..13ce4ce 100644 --- a/app/src/logic/api/protogen/types.js +++ b/app/src/logic/api/protogen/types.js @@ -292,6 +292,7 @@ export const snacktime = $root.snacktime = (() => { * Properties of a DownloadFileRequest. * @memberof snacktime.series.file * @interface IDownloadFileRequest + * @property {string|null} [mediaFileId] DownloadFileRequest mediaFileId */ /** @@ -309,6 +310,14 @@ export const snacktime = $root.snacktime = (() => { this[keys[i]] = properties[keys[i]]; } + /** + * DownloadFileRequest mediaFileId. + * @member {string} mediaFileId + * @memberof snacktime.series.file.DownloadFileRequest + * @instance + */ + DownloadFileRequest.prototype.mediaFileId = ""; + return DownloadFileRequest; })(); @@ -1314,6 +1323,7 @@ export const snacktime = $root.snacktime = (() => { * @property {string|null} [mediaId] Session mediaId * @property {snacktime.storage.IDuration|null} [duration] Session duration * @property {number|null} [mediaLenghtInSec] Session mediaLenghtInSec + * @property {string|null} [fromDevice] Session fromDevice */ /** @@ -1379,6 +1389,14 @@ export const snacktime = $root.snacktime = (() => { */ Session.prototype.mediaLenghtInSec = 0; + /** + * Session fromDevice. + * @member {string} fromDevice + * @memberof snacktime.storage.Session + * @instance + */ + Session.prototype.fromDevice = ""; + return Session; })(); diff --git a/app/src/views/Series.vue b/app/src/views/Series.vue index 01a872c..46897a8 100644 --- a/app/src/views/Series.vue +++ b/app/src/views/Series.vue @@ -79,7 +79,13 @@ @@ -159,8 +165,13 @@ export default class SeriesInfo extends Vue { return Number(this.$route.params["id"]); } + private async download(mediaFileId: string): Promise { + let res = await HttpClient.get( + "/api/file/v1/download/" + mediaFileId + ); + } + private getTotalDuration(episode: Episode): number { - console.log("episode"); if ( !episode.progress || !episode.progress.watchedInSec ||