twitch clips support added
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Sources.Twitch.Models
|
||||
{
|
||||
public class TwitchClip : TwitchVideo
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public string Creator { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using SimpleToolkit.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using System.Web;
|
||||
using VDownload.Models;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
using VDownload.Services.Data.Settings;
|
||||
using VDownload.Sources.Twitch.Models.Internal;
|
||||
|
||||
namespace VDownload.Sources.Twitch.Models
|
||||
{
|
||||
public class TwitchClipStream : VideoStream
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly HttpClient _httpClient;
|
||||
|
||||
protected readonly IConfigurationService _configurationService;
|
||||
protected readonly ISettingsService _settingsService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public int Height { get; set; }
|
||||
public double FrameRate { get; set; }
|
||||
public Uri Url { get; set; }
|
||||
public string Signature { get; set; }
|
||||
public string Token { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TwitchClipStream(HttpClient httpClient, IConfigurationService configurationService, ISettingsService settingsService)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
|
||||
_configurationService = configurationService;
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async override Task<VideoStreamDownloadResult> Download(string taskTemporaryDirectory, IProgress<double> onProgress, CancellationToken token, TimeSpan duration, TimeSpan trimStart, TimeSpan trimEnd)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
string location = Path.Combine(taskTemporaryDirectory, _configurationService.Twitch.Download.Clip.FileName);
|
||||
|
||||
string url = $"{Url.OriginalString}?sig={Signature}&token={HttpUtility.UrlEncode(Token)}";
|
||||
using (FileStream fileStream = File.Create(location))
|
||||
{
|
||||
await _httpClient.DownloadAsync(url, fileStream, token, onProgress);
|
||||
token.ThrowIfCancellationRequested();
|
||||
}
|
||||
|
||||
return new VideoStreamDownloadResult
|
||||
{
|
||||
File = location,
|
||||
NewDuration = duration,
|
||||
NewTrimEnd = trimEnd,
|
||||
NewTrimStart = trimStart
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,10 @@ namespace VDownload.Sources.Twitch.Models
|
||||
{
|
||||
public class TwitchVod : TwitchVideo
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace VDownload.Sources.Twitch.Models
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async override Task<VideoStreamDownloadResult> Download(string taskTemporaryDirectory, IProgress<double> onProgress, CancellationToken token, TimeSpan trimStart, TimeSpan trimEnd)
|
||||
public async override Task<VideoStreamDownloadResult> Download(string taskTemporaryDirectory, IProgress<double> onProgress, CancellationToken token, TimeSpan duration, TimeSpan trimStart, TimeSpan trimEnd)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -92,8 +92,6 @@ namespace VDownload.Sources.Twitch.Models
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
TimeSpan duration = TimeSpan.FromTicks(chunks.Sum(x => x.Duration.Ticks));
|
||||
|
||||
if (_settingsService.Data.Twitch.Vod.PassiveTrimming)
|
||||
{
|
||||
PassiveTrimming(chunks, ref trimStart, ref trimEnd, ref duration);
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SimpleToolkit.Extensions" Version="1.7.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Models\VDownload.Models.csproj" />
|
||||
<ProjectReference Include="..\..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user