Archived
1
0

ManifestGenerator upate

This commit is contained in:
Michael Gordeev
2019-05-14 21:48:35 +03:00
parent cebbf4fef5
commit af989c5c45
2 changed files with 36 additions and 30 deletions
+13 -7
View File
@@ -37,24 +37,22 @@ namespace FoxTube.Controls.Player
XmlElement mpd = doc.CreateElement("MPD"); XmlElement mpd = doc.CreateElement("MPD");
mpd.SetAttribute("mediaPresentationDuration", meta.ContentDetails.Duration); mpd.SetAttribute("mediaPresentationDuration", meta.ContentDetails.Duration);
mpd.SetAttribute("minBufferTime", "PT2S"); mpd.SetAttribute("minBufferTime", "PT2S");
mpd.SetAttribute("profiles", "urn:mpeg:dash:profile:isoff-on-demand:2011");
mpd.SetAttribute("type", "static");
XmlElement period = doc.CreateElement("Period"); XmlElement period = doc.CreateElement("Period");
period.SetAttribute("duration", meta.ContentDetails.Duration);
period.SetAttribute("start", "PT0S");
XmlElement videoSet = doc.CreateElement("AdaptationSet"); XmlElement videoSet = doc.CreateElement("AdaptationSet");
XmlElement videoMeta = doc.CreateElement("ContentComponent"); XmlElement videoMeta = doc.CreateElement("ContentComponent");
videoMeta.SetAttribute("contentType", "video"); videoMeta.SetAttribute("contentType", "video");
videoMeta.SetAttribute("id", "1");
videoSet.AppendChild(videoMeta); videoSet.AppendChild(videoMeta);
StreamInfo streamInfo = await GetInfoAsync(meta, requestedQuality, list); StreamInfo streamInfo = await GetInfoAsync(meta, requestedQuality);
XmlElement representation = doc.CreateElement("Representation"); XmlElement representation = doc.CreateElement("Representation");
representation.SetAttribute("bandwidth", GetBandwidth(requestedQuality.VideoQuality)); representation.SetAttribute("bandwidth", GetBandwidth(requestedQuality.VideoQuality));
representation.SetAttribute("height", requestedQuality.Resolution.Height.ToString());
representation.SetAttribute("width", requestedQuality.Resolution.Width.ToString());
representation.SetAttribute("id", "1"); representation.SetAttribute("id", "1");
representation.SetAttribute("codecs", requestedQuality.VideoEncoding.ToString());
representation.SetAttribute("mimeType", $"video/{requestedQuality.Container.GetFileExtension()}"); representation.SetAttribute("mimeType", $"video/{requestedQuality.Container.GetFileExtension()}");
XmlElement baseUrl = doc.CreateElement("BaseURL"); XmlElement baseUrl = doc.CreateElement("BaseURL");
@@ -74,6 +72,7 @@ namespace FoxTube.Controls.Player
XmlElement audioSet = doc.CreateElement("AdaptationSet"); XmlElement audioSet = doc.CreateElement("AdaptationSet");
XmlElement audioMeta = doc.CreateElement("ContentComponent"); XmlElement audioMeta = doc.CreateElement("ContentComponent");
audioMeta.SetAttribute("contentType", "audio"); audioMeta.SetAttribute("contentType", "audio");
audioMeta.SetAttribute("id", "2");
audioSet.AppendChild(audioMeta); audioSet.AppendChild(audioMeta);
XmlElement audio = doc.CreateElement("Representation"); XmlElement audio = doc.CreateElement("Representation");
@@ -109,7 +108,9 @@ namespace FoxTube.Controls.Player
return $"ms-appdata:///roaming/{manifest.Name}".ToUri(); return $"ms-appdata:///roaming/{manifest.Name}".ToUri();
} }
private static async Task<StreamInfo> GetInfoAsync(Video info, VideoStreamInfo requestedQuality, MediaStreamInfoSet list) private static async Task<StreamInfo> GetInfoAsync(Video info, VideoStreamInfo requestedQuality)
{
try
{ {
HttpClient http = new HttpClient(); HttpClient http = new HttpClient();
string response = HttpUtility.HtmlDecode(await http.GetStringAsync($"https://youtube.com/embed/{info.Id}?disable_polymer=true&hl=en")); string response = HttpUtility.HtmlDecode(await http.GetStringAsync($"https://youtube.com/embed/{info.Id}?disable_polymer=true&hl=en"));
@@ -140,6 +141,11 @@ namespace FoxTube.Controls.Player
return si; return si;
} }
catch
{
return null;
}
}
public static Dictionary<string, string> SplitQuery(string query) public static Dictionary<string, string> SplitQuery(string query)
{ {
+2 -2
View File
@@ -442,8 +442,8 @@ namespace FoxTube
object tag; object tag;
if (MediaStreams.Muxed.Any(m => m.VideoQualityLabel == i && m.Resolution.Height <= screenHeight)) if (MediaStreams.Muxed.Any(m => m.VideoQualityLabel == i && m.Resolution.Height <= screenHeight))
tag = MediaStreams.Muxed.Find(m => m.VideoQualityLabel == i); tag = MediaStreams.Muxed.Find(m => m.VideoQualityLabel == i);
else if (MediaStreams.Video.Any(m => m.VideoQualityLabel == i && m.Resolution.Height <= screenHeight && m.Container.GetFileExtension() == "webm")) else if (MediaStreams.Video.Any(m => m.VideoQualityLabel == i && m.Resolution.Height <= screenHeight && m.Container.GetFileExtension() == "mp4"))
tag = MediaStreams.Video.Find(m => m.VideoQualityLabel == i && m.Container.GetFileExtension() == "webm"); tag = MediaStreams.Video.Find(m => m.VideoQualityLabel == i && m.Container.GetFileExtension() == "mp4");
else else
continue; continue;