Added HttpStream

This commit is contained in:
Mike Nolan 2022-06-16 06:12:27 -05:00
parent b1fe28c637
commit 4f31f73b6d
5 changed files with 19 additions and 25 deletions

View File

@ -867,4 +867,6 @@ This is also the License to this Project due to YouTubeExplode
Other Licenses:<br> Other Licenses:<br>
[DiscUtils](LICENSE.DiskUtils)<br> [DiscUtils](LICENSE.DiskUtils)<br>
[Tesses.WebServer](LICENSE.Tesses.WebServer)<br> [Tesses.WebServer](LICENSE.Tesses.WebServer)<br>
[Zio](LICENSE.Zio)<br> [Zio](LICENSE.Zio)<br>
I also use HttpStream which is MIT according to github repo

View File

@ -470,7 +470,7 @@ namespace Tesses.YouTubeDownloader.Server
public async Task AddVideo(ServerContext ctx) public async Task AddVideo(ServerContext ctx)
{ {
string id; string id;
Console.WriteLine(ctx.RawUrl);
if(ctx.QueryParams.TryGetFirst("v",out id)) if(ctx.QueryParams.TryGetFirst("v",out id))
{ {
Resolution resolution=Resolution.PreMuxed; Resolution resolution=Resolution.PreMuxed;

View File

@ -15,9 +15,9 @@
<PackageId>Tesses.YouTubeDownloader.Server</PackageId> <PackageId>Tesses.YouTubeDownloader.Server</PackageId>
<Author>Mike Nolan</Author> <Author>Mike Nolan</Author>
<Company>Tesses</Company> <Company>Tesses</Company>
<Version>1.1.0</Version> <Version>1.1.1</Version>
<AssemblyVersion>1.1.0</AssemblyVersion> <AssemblyVersion>1.1.1</AssemblyVersion>
<FileVersion>1.1.0</FileVersion> <FileVersion>1.1.1</FileVersion>
<Description>Adds WebServer to TYTD</Description> <Description>Adds WebServer to TYTD</Description>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression> <PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>

View File

@ -12,6 +12,7 @@ using YoutubeExplode.Channels;
using YoutubeExplode.Playlists; using YoutubeExplode.Playlists;
using System.Net.Http; using System.Net.Http;
using System.Net; using System.Net;
using Espresso3389.HttpStream;
namespace Tesses.YouTubeDownloader namespace Tesses.YouTubeDownloader
{ {
@ -243,31 +244,20 @@ namespace Tesses.YouTubeDownloader
return GetQueueListAsync().GetAwaiter().GetResult(); return GetQueueListAsync().GetAwaiter().GetResult();
} }
public override async Task<long> GetLengthAsync(string path)
{
try{
var item=await client.GetAsync($"{url}api/Storage/File/{path}");
return item.Content.Headers.ContentLength.GetValueOrDefault();
}catch(Exception ex)
{
_=ex;
}
return 0;
}
public async override Task<Stream> OpenReadAsync(string path) public async override Task<Stream> OpenReadAsync(string path)
{ {
try{ try{
Stream v=await client.GetStreamAsync($"{url}api/Storage/File/{path}");
return v; HttpStream v=new HttpStream(new Uri($"{url}api/Storage/File/{path}"),new MemoryStream(),true,32 * 1024,null,client);
return await Task.FromResult(v);
}catch(Exception ex) }catch(Exception ex)
{ {
_=ex; _=ex;
} }
return Stream.Null; return await Task.FromResult(Stream.Null);
} }

View File

@ -7,9 +7,9 @@
<PackageId>Tesses.YouTubeDownloader</PackageId> <PackageId>Tesses.YouTubeDownloader</PackageId>
<Author>Mike Nolan</Author> <Author>Mike Nolan</Author>
<Company>Tesses</Company> <Company>Tesses</Company>
<Version>1.1.3</Version> <Version>1.1.4</Version>
<AssemblyVersion>1.1.3</AssemblyVersion> <AssemblyVersion>1.1.4</AssemblyVersion>
<FileVersion>1.1.3</FileVersion> <FileVersion>1.1.4</FileVersion>
<Description>A YouTube Downloader</Description> <Description>A YouTube Downloader</Description>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression> <PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
@ -18,6 +18,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Espresso3389.HttpStream" Version="2.0.52.3" />
<PackageReference Include="HttpStream" Version="2.0.50" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YouTubeExplode" Version="6.1.2" /> <PackageReference Include="YouTubeExplode" Version="6.1.2" />