This commit is contained in:
Mike Nolan 2022-06-11 21:14:29 -05:00
parent 4ef759a9d1
commit 5622c194f2
1 changed files with 10 additions and 2 deletions

View File

@ -19,7 +19,7 @@ public class TYTDProxy
RouteServer api_server=new RouteServer(); RouteServer api_server=new RouteServer();
RouteApi(api_server); RouteApi(api_server);
MountableServer mountable_server=new MountableServer(static_server); MountableServer mountable_server=new MountableServer(static_server);
mountable_server.Mount("/api/",api_server); mountable_server.Mount("/api",api_server);
HttpServerListener listener=new HttpServerListener(new System.Net.IPEndPoint(System.Net.IPAddress.Any,3253),mountable_server); HttpServerListener listener=new HttpServerListener(new System.Net.IPEndPoint(System.Net.IPAddress.Any,3253),mountable_server);
await listener.ListenAsync(token.Token); await listener.ListenAsync(token.Token);
@ -99,6 +99,8 @@ public class TYTDProxy
var bestMuxed=res.GetMuxedStreams().GetWithHighestVideoQuality(); var bestMuxed=res.GetMuxedStreams().GetWithHighestVideoQuality();
System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition(); System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition();
contentDisposition.FileName = vid.Title; contentDisposition.FileName = vid.Title;
contentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Inline;
ctx.ResponseHeaders.Add("Content-Disposition",contentDisposition.ToString());
await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestMuxed),$"file.{bestMuxed.Container.Name}"); await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestMuxed),$"file.{bestMuxed.Container.Name}");
} }
} }
@ -113,6 +115,9 @@ public class TYTDProxy
var bestVideoOnly=res.GetVideoOnlyStreams().GetWithHighestVideoQuality(); var bestVideoOnly=res.GetVideoOnlyStreams().GetWithHighestVideoQuality();
System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition(); System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition();
contentDisposition.FileName = vid.Title; contentDisposition.FileName = vid.Title;
contentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Inline;
ctx.ResponseHeaders.Add("Content-Disposition",contentDisposition.ToString());
await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestVideoOnly),$"file.{bestVideoOnly.Container.Name}"); await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestVideoOnly),$"file.{bestVideoOnly.Container.Name}");
} }
} }
@ -127,6 +132,9 @@ public class TYTDProxy
var bestAudioOnly=res.GetAudioOnlyStreams().GetWithHighestBitrate(); var bestAudioOnly=res.GetAudioOnlyStreams().GetWithHighestBitrate();
System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition(); System.Net.Mime.ContentDisposition contentDisposition=new System.Net.Mime.ContentDisposition();
contentDisposition.FileName = vid.Title; contentDisposition.FileName = vid.Title;
contentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Inline;
ctx.ResponseHeaders.Add("Content-Disposition",contentDisposition.ToString());
await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestAudioOnly),$"file.{bestAudioOnly.Container.Name}"); await ctx.SendStreamAsync(await Youtube.Videos.Streams.GetAsync(bestAudioOnly),$"file.{bestAudioOnly.Container.Name}");
} }
} }