From f1d34cabeb204660a734ac332b305b809f604951 Mon Sep 17 00:00:00 2001 From: irodai-majom <181323284+irodai-majom@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:37:10 +0200 Subject: [PATCH] Added MSSExtractorTest --- .../Extractor/MSSExtractorTest.cs | 86 ++++++++++++++++++ .../SuperSpeedway_720.ism.manifest.xml | Bin 0 -> 13718 bytes .../N_m3u8DL-RE.Parser.Tests.csproj | 7 ++ 3 files changed, 93 insertions(+) create mode 100644 src/N_m3u8DL-RE.Parser.Tests/Extractor/MSSExtractorTest.cs create mode 100644 src/N_m3u8DL-RE.Parser.Tests/Extractor/SuperSpeedway_720.ism.manifest.xml diff --git a/src/N_m3u8DL-RE.Parser.Tests/Extractor/MSSExtractorTest.cs b/src/N_m3u8DL-RE.Parser.Tests/Extractor/MSSExtractorTest.cs new file mode 100644 index 0000000..ef1b75a --- /dev/null +++ b/src/N_m3u8DL-RE.Parser.Tests/Extractor/MSSExtractorTest.cs @@ -0,0 +1,86 @@ +using System.Reflection; +using FluentAssertions; +using N_m3u8DL_RE.Parser.Config; +using N_m3u8DL_RE.Parser.Extractor; + + +namespace N_m3u8DL_RE.Parser.Tests.Extractor; + +[TestClass] +public class MSSExtractorTest +{ + [TestMethod] + public void TestMethod1() + { + var uri = getResourceUri("Extractor/SuperSpeedway_720.ism.manifest.xml"); + var rawText = File.ReadAllText(uri.LocalPath); + var parserConfig = new ParserConfig + { + Url = uri.AbsoluteUri, + OriginalUrl = uri.AbsoluteUri + }; + var extractor = new MSSExtractor(parserConfig); + var streamSpecs = extractor.ExtractStreamsAsync(rawText).Result; + streamSpecs.Should().HaveCount(9); + var streamSpec0 = streamSpecs[0]; + streamSpec0.PeriodId.Should().Be("0"); + streamSpec0.GroupId.Should().Be("video"); + streamSpec0.Bandwidth.Should().Be(2962000); + streamSpec0.Codecs.Should().Be("avc1.64001F"); + streamSpec0.Resolution.Should().Be("1280x720"); + streamSpec0.Channels.Should().Be(null); + streamSpec0.MSSData!.SamplingRate.Should().Be(48000); + streamSpec0.MSSData.BitsPerSample.Should().Be(16); + streamSpec0.MSSData.NalUnitLengthField.Should().Be(4); + streamSpec0.MSSData.Duration.Should().Be(1209510000L); + streamSpec0.MSSData.Timesacle.Should().Be(10000000); + streamSpec0.Playlist!.IsLive.Should().BeFalse(); + streamSpec0.Playlist!.MediaParts[0].MediaSegments.Should().HaveCount(61); + + var streamSpec1 = streamSpecs[1]; + streamSpec1.PeriodId.Should().Be("1"); + streamSpec1.GroupId.Should().Be("video"); + streamSpec1.Bandwidth.Should().Be(2056000); + streamSpec1.Codecs.Should().Be("avc1.64001F"); + streamSpec1.Resolution.Should().Be("992x560"); + streamSpec1.Channels.Should().Be(null); + streamSpec1.MSSData!.SamplingRate.Should().Be(48000); + streamSpec1.MSSData.BitsPerSample.Should().Be(16); + streamSpec1.MSSData.NalUnitLengthField.Should().Be(4); + streamSpec1.MSSData.Duration.Should().Be(1209510000L); + streamSpec1.MSSData.Timesacle.Should().Be(10000000); + + var streamSpec5 = streamSpecs[5]; + streamSpec5.PeriodId.Should().Be("5"); + streamSpec5.GroupId.Should().Be("video"); + streamSpec5.Bandwidth.Should().Be(477000); + streamSpec5.Codecs.Should().Be("avc1.64000D"); + streamSpec5.Resolution.Should().Be("368x208"); + streamSpec5.Channels.Should().Be(null); + streamSpec5.MSSData!.SamplingRate.Should().Be(48000); + streamSpec5.MSSData.BitsPerSample.Should().Be(16); + streamSpec5.MSSData.NalUnitLengthField.Should().Be(4); + streamSpec5.MSSData.Duration.Should().Be(1209510000L); + streamSpec5.MSSData.Timesacle.Should().Be(10000000); + + var streamSpec8 = streamSpecs[8]; + streamSpec8.PeriodId.Should().Be(null); + streamSpec8.GroupId.Should().Be("audio"); + streamSpec8.Bandwidth.Should().Be(128000); + streamSpec8.Codecs.Should().Be("mp4a.40.2"); + streamSpec8.Resolution.Should().Be(null); + streamSpec8.Channels.Should().Be("2"); + streamSpec8.MSSData!.SamplingRate.Should().Be(44100); + streamSpec8.MSSData.BitsPerSample.Should().Be(16); + streamSpec8.MSSData.NalUnitLengthField.Should().Be(4); + streamSpec8.MSSData.Duration.Should().Be(1209510000L); + streamSpec8.MSSData.Timesacle.Should().Be(10000000); + } + + private Uri getResourceUri(string resourceName) + { + var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var path = System.IO.Path.Combine(directory, resourceName); + return new Uri("file://" + path); + } +} \ No newline at end of file diff --git a/src/N_m3u8DL-RE.Parser.Tests/Extractor/SuperSpeedway_720.ism.manifest.xml b/src/N_m3u8DL-RE.Parser.Tests/Extractor/SuperSpeedway_720.ism.manifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..829885c7d96519d8cb505ba5fbbb30f59d8c9483 GIT binary patch literal 13718 zcmeI3?Nc1b5yt0ps`5V&eR3*=eJ{X4l_b~R8#ocRFd$j_cDzU;Mo49ZjFig1Zs+;+ zbHnZ(hv486lFHT9E;~Ct-97zu_sr}JzyJ0yeVfkH+jN{3(#Ld|eo3e4D7{N3=}~%+ z>gnrL)87TvoTPodKTz#SdL6ZA=|g&z7Dcrpns3wN^f3KN<;BzypTjgz{h?Ycq+iwQ zLwcj9o}|5x+S3b3yv^LvU|f@hv=n-Lotl!hoK~ZR93*Z_`*-@me_MA;emm52Gc-7o zE(>W>_rHtsm-I|;M|;|cUT#LK$rSaV=%zEZq-RwtHDskVX;#-?{~k!UKc+uO>O$yP z>h+!adLa4ds@X}OWR1hH=0|bl{kxF!y=1(dSkqBI&&1I+9arK2Ad8>(HAA5(W%6guLKr|hSv zl5nJ6JJP!GcM$TjANns5+6wuU>(Z`}UJYG^yp}ghabHm+_Vw#rc(Og3dVC~bg`V@T zC9l9g%(*2wJe3@3l2C+fTJvj*TSpe_OBxZ~QLTAX+YrB|?r6j>w??nJH0bHx700@0 z8WD4}9{tf@DA)9UP284)@`1djjLPYdcZ^L!9u2bw4{m|{nl#MWhv*!S7ITO5>~U|( zMm1TwB}}j{&$eV!rB2ulMDmppv=7-Qj8RwAHCfsh@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(-h`s{oh1AREJTI<<`@#?xz3wqP!pWz+Pa2z0m(yPwt=X^Iqlku-9JD zuc_P#eZSX}?Zf^)`eAkSb^qNT__L>9$Rojn{u|$CQEuyAtw-~0AMio*Ufj3DJD2Ij zPUyQH_1OPu$mgjizs7&S^JSFL%H<#QWO|F8~aSw*Z%)Pl3BaA z)feypm7TD^{SU9QJ?Vx0aWm?FQn?rO_TPHc*K~J0;9u(zuh^$hw!mK0SM33Qh|^%A7AObV3||q35|h`r%K`7sijC zSN#!x=|_K_MSG&6>d&?xUTppB&u}IF+xlhuIv$)4!GA0C=dJDU{^BK7{(n{3{$l>G zqKxLd(H?!+DJS1z5Bnp%FumJbpVGgbe<+{p%JB?W=Oe5%9{*MR(BJr>ujMTxHv1H~Ndbjj)ID_jm;go^KF2rni6FA9*_|f8~6S{`M~{XMZjI&-|vHAG!S_ Y&HcWSZeO1LF+-e8<(ixRpVH&>FKRJvxc~qF literal 0 HcmV?d00001 diff --git a/src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj b/src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj index aa593d2..add5ee3 100644 --- a/src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj +++ b/src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj @@ -11,6 +11,7 @@ + @@ -21,4 +22,10 @@ + + + PreserveNewest + + +