diff --git a/OpenDirectoryDownloader.Tests/DirectoryParser101_125Tests.cs b/OpenDirectoryDownloader.Tests/DirectoryParser101_125Tests.cs index d7efe21e..07f42d89 100644 --- a/OpenDirectoryDownloader.Tests/DirectoryParser101_125Tests.cs +++ b/OpenDirectoryDownloader.Tests/DirectoryParser101_125Tests.cs @@ -1,4 +1,4 @@ -using OpenDirectoryDownloader.Shared.Models; +using OpenDirectoryDownloader.Shared.Models; using System; using System.Threading.Tasks; using Xunit; @@ -23,7 +23,7 @@ public async Task TestDirectoryListing101aAsync() Assert.Equal("Rulebooklet-PNP.pdf", webDirectory.Files[0].FileName); Assert.Equal(14680064, webDirectory.Files[0].FileSize); } - + /// /// Url: https://media.thqnordic.com/?dir=Monkey_King/Trailer /// @@ -84,5 +84,36 @@ public async Task TestDirectoryListing103cAsync() Assert.Equal("Amazon.cbr", webDirectory.Files[0].FileName); Assert.Equal(-1, webDirectory.Files[0].FileSize); } + + /// + /// Url: http://51.158.144.75:8081/ + /// + [Fact] + public async Task TestDirectoryListing104aAsync() + { + WebDirectory webDirectory = await ParseHtml(GetSample()); + + Assert.Equal("ROOT", webDirectory.Name); + Assert.Equal(165, webDirectory.Subdirectories.Count); + Assert.Equal("1917.2019.DVDSCR.x264-TOPKEK[TGx]", webDirectory.Subdirectories[0].Name); + Assert.Equal(30, webDirectory.Files.Count); + Assert.Equal("Arrow.S07E01.HDTV.x264-SVA[eztv].mkv", webDirectory.Files[0].FileName); + Assert.Equal(307526887, webDirectory.Files[0].FileSize); + } + + /// + /// Url: http://51.158.144.75:8081/1917.2019.DVDSCR.x264-TOPKEK%5BTGx%5D/ + /// + [Fact] + public async Task TestDirectoryListing104bAsync() + { + WebDirectory webDirectory = await ParseHtml(GetSample()); + + Assert.Equal("ROOT", webDirectory.Name); + Assert.Empty(webDirectory.Subdirectories); + Assert.Equal(2, webDirectory.Files.Count); + Assert.Equal("1917.2019.DVDSCR.x264-TOPKEK.mp4", webDirectory.Files[0].FileName); + Assert.Equal(1202701165, webDirectory.Files[0].FileSize); + } } } \ No newline at end of file diff --git a/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104a.html.dat b/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104a.html.dat new file mode 100644 index 00000000..50925324 --- /dev/null +++ b/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104a.html.dat @@ -0,0 +1,209 @@ + + + + / + + +

/

+
+../
+1917.2019.DVDSCR.x264-TOPKEK[TGx]/
+28.Days.Later.2002.720p.BluRay.H264.AAC-RARBG/
+365 Days (2020) [720p] [WEBRip] [YTS.MX]/
+6.Underground.2019.720p.NF.WEBRip.900MB.x264-GalaxyRG[TGx]/
+9-1-1.S03E01.WEB.x264-TBS[rarbg]/
+9-1-1.S03E02.WEB.x264-TBS[rarbg]/
+9-1-1.S03E03.WEBRip.x264-ION10/
+9-1-1.S03E04.WEBRip.x264-ION10/
+9-1-1.S03E05.WEBRip.x264-ION10/
+9-1-1.S03E06.WEBRip.x264-ION10/
+9-1-1.S03E07.WEBRip.x264-ION10/
+9-1-1.S03E08.WEB.x264-TBS[ettv]/
+9-1-1.S03E09.WEB.x264-PHOENiX[TGx]/
+9-1-1.S03E10.WEB.x264-TBS[ettv]/
+9-1-1.Season.2.S02.1080p.AMZN.x265.10bit.6CH.ReEnc-LUMI/
+A Quiet Place (2018) [BluRay] [720p] [YTS.AM]/
+Ad.Astra.2019.HDRip.XviD.AC3-EVO[TGx]/
+Air Crash Imvestigation S19/
+Angel Has Fallen (2019) [BluRay] [1080p] [YTS.LT]/
+Animal Kingdom (2010) [BluRay] [720p] [YTS.AM]/
+Apocalypse Now (1979) [BluRay] [720p] [YTS.AM]/
+Arrow.S07E01.HDTV.x264-SVA[eztv].mkv                                                               307526887
+Arrow.S08E01.720p.HDTV.x265-MiNX[TGx]/
+Arrow.S08E02.720p.HDTV.x265-MiNX[TGx]/
+Arrow.S08E04.720p.HDTV.x265-MiNX[TGx]/
+Arrow.S08E05.720p.HDTV.x265-MiNX[TGx]/
+Arrow.S08E06.HDTV.x264-SVA[ettv]/
+Arrow.S08E07.HDTV.x264-SVA[ettv]/
+Arrow.S08E08.HDTV.x264-SVA[eztv].mkv                                                               311080192
+Arrow.S08E09.HDTV.x264-SVA[ettv]/
+Arrow.S08E10.720p.HDTV.x265-MiNX[TGx]/
+BBC.This.World.2020.Terror.in.Paradise.1080p.HDTV.x264.AAC.MVGroup.org.mkv                        1264182952
+Black Death.2010.BRRip.XViD-ETRG/
+Blindspot.S05E01.720p.WEB.x265-MiNX[TGx]/
+Blindspot.S05E02.720p.HDTV.x265-MiNX[TGx]/
+Blindspot.S05E03.720p.HDTV.x265-MiNX[TGx]/
+Blindspot.S05E04.HDTV.x264-SVA[TGx]/
+Blindspot.S05E05.720p.HDTV.x265-MiNX[TGx]/
+Blindspot.S05E06.HDTV.x264-KILLERS[TGx]/
+Carriers.2009.720p.BluRay.H264.AAC-RARBG/
+Contagion (2011) [720p] [BluRay] [YTS.MX]/
+Covert.Affairs.S05.HDTV.x264-BTN (Silver Torrent)/
+Crawl (2019) [BluRay] [720p] [YTS.LT]/
+Dark Phoenix (2019) [BluRay] [720p] [YTS.LT]/
+Dark S02 Season 02 Complete 720p WEB-DL x264-XpoZ/
+Dark.SEASON.01.S01.COMPLETE.DUAL-AUDIO.GER-ENG.720p.10bit.WEBRip.2CH.x265.HEVC-PSA/
+Dirty Money (2018)/
+Dooplay 2.1.7 - Movies and Tv Shows WordPress Theme/
+Double Jeopardy-DVDRip[Eng]1999.avi                                                                738455552
+Double Jeopardy-DVDRip[Eng]1999.srt                                                                    73303
+Earthlings [2006] [Special Extended Edition] DvDrip [Eng] + 12 languages' subtitles/
+Elite.S01.SPANISH.WEBRip.x264-ION10/
+Elite.S02.SPANISH.WEBRip.x264-ION10/
+Elite.S03.SPANISH.PROPER.WEBRip.x264-ION10/
+Extraction (2020) English UNTOUCHED 720p NF WEBRip DD-5.1 ⭐800 MB⭐ ESub x264 - Shadow/
+Fantasy.Island.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+Gangs.Of.London.S01.COMPLETE.720p.HDTV.x264-GalaxyTV[TGx]/
+Gemini.Man.2019.1080p.HC.HDRip.1400MB.DD2.0.x264-GalaxyRG[TGx]/
+Glass (2019) [WEBRip] [720p] [YTS.AM]/
+Gnomeo and Juliet (2011)/
+Gone Girl (2014)/
+Heat (1995)/
+High.Life.2019.BRRip.XviD.AC3-EVO/
+How To Train Your Dragon The Hidden World (2019) [BluRay] [720p] [YTS.AM]/
+How to Train Your Dragon 2 (2014) [1080p]/
+Hunters.2020.S01.COMPLETE.720p.AMZN.WEBRip.x264-GalaxyTV[TGx]/
+Inheritance.2020.HDRip.XviD.AC3-EVO[TGx]/
+Istana_Banjir.mp4                                                                                    4729255
+Jason.Bourne.2016.720p.WEBRip.x264.AAC-ETRG/
+John Wick Chapter 3 - Parabellum (2019) [BluRay] [720p] [YTS.LT]/
+Joker.2019.HC.1080p.HDRip.X264.AC3-EVO[TGx]/
+La Casa De Papel(Money Heist) S01-S02 720p NF WEB-DL x265-HETeam/
+Lion.King.2019.1080p.BluRay.1400MB.DD5.1.x264-GalaxyRG[TGx]/
+Lost.in.Space.2018.S01.COMPLETE.720p.BluRay.x264-GalaxyTV[TGx]/
+Lost.in.Space.2018.S02.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+Mayday Air Crash Investigation Season 17 Complete HQW/
+Mayday.Air.Crash.Investigation.S18/
+Messiah.2020.S01.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+Money Heist aka La Casa de Papel S03 Season 03 Complete 720p WEB-DL x264-XpoZ/
+Money.Heist.S04.720p.WEB.x264-GHOSTS[rartv]/
+Money.Heist.S04.SPANISH.WEBRip.x264-ION10/
+My.Spy.2020.720p.BluRay.800MB.x264-GalaxyRG[TGx]/
+Obsession.Dark.Desires.S01E01.Paging.Sarah.iNTERNAL.WEB.h264-CAFFEiNE[eztv].mkv                    279706394
+Obsession.Dark.Desires.S01E02.Hiding.in.Plain.Sight.iNTERNAL.WEB.h264-CAFFEiNE[eztv].mkv           300457971
+Obsession.Dark.Desires.S01E03.Help.Wanted.iNTERNAL.WEB.h264-CAFFEiNE[eztv].mkv                     262410834
+Obsession.Dark.Desires.S02.WEBRip.AAC2.0.x264-CAFFEiNE[TGx]/
+Official Secrets.2019.HDRip.XviD.AC3-EVO[TGx]/
+Onward.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+Outbreak (1995)/
+Ozark.S03.WEBRip.x264-ION10/
+PMDK 2019/
+Parasite.2019.1080p.HDRip.X264.AC3-EVO[TGx]/
+Rambo.Last.Blood.2019.HC.HDRip.XviD.AC3-EVO[TGx]/
+Red.Shoes.and.the.Seven.Dwarfs.2020.720p.HDRip.800MB.x264-GalaxyRG[TGx]/
+Reprisal.S01.COMPLETE.720p.HULU.WEBRip.x264-GalaxyTV[TGx]/
+Rise.of.Empires.Ottoman.S01.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+SEAL.Team.S02E22.HDTV.x264-SVA[ettv]/
+SEAL.Team.S03E01.720p.WEB.x264-worldmkv.mkv                                                        331659673
+SEAL.Team.S03E02.HDTV.x264-KILLERS[rarbg]/
+SEAL.Team.S03E03.HDTV.x264-SVA[TGx]/
+SEAL.Team.S03E04.HDTV.x264-KILLERS[eztv].mkv                                                       363699674
+SEAL.Team.S03E07.HDTV.x264-KILLERS[ettv]/
+SEAL.Team.S03E08.HDTV.x264-SVA[TGx]/
+SEAL.Team.S03E10.720p.HDTV.x265-MiNX[TGx]/
+SEAL.Team.S03E15.HDTV.x264-SVA[eztv].mkv                                                           364765529
+SEAL.Team.S03E16.HDTV.x264-SVA[rarbg]/
+SEAL.Team.S03E17.HDTV.x264-SVA[rarbg]/
+SEAL.Team.S03E18.HDTV.x264-SVA[eztv].mkv                                                           342988893
+SEAL.Team.S03E19.720p.HDTV.x265-MiNX[TGx]/
+SEAL.Team.S03E20.HDTV.x264-KILLERS[TGx]/
+See.S01E01.WEB.x264-PHOENiX[TGx]/
+See.S01E02.WEB.x264-PHOENiX[TGx]/
+See.S01E03.WEB.x264-PHOENiX[TGx]/
+See.S01E04.WEB.x264-PHOENiX[TGx]/
+See.S01E05.WEB.x264-PHOENiX[TGx]/
+See.S01E06.WEB.x264-PHOENiX[TGx]/
+See.S01E07.WEB.x264-PHOENiX[TGx]/
+See.S01E08.WEB.x264-PHOENiX[TGx]/
+Sherlock Gnomes (2018) [BluRay] [720p] [YTS.AM]/
+Spaceship.Earth.2020.HULU.WEB-DL.AAC2.0.H.264-NTG[TGx]/
+Spies In Disguise (2019) [720p] [BluRay] [YTS.MX]/
+Split.2016.720p.BRRip.x264.AAC-ETRG/
+Strike.Back.S08E06.WEB.H264-XLF[TGx]/
+Strike.Back.S08E07.WEB.H264-XLF[eztv].mkv                                                          337254112
+Strike.Back.S08E08.WEB.H264-XLF[rarbg]/
+Strike.Back.S08E09.WEB.H264-XLF[rarbg]/
+Strike.Back.S08E10.HDTV.x264-PHOENiX[TGx]/
+Tarzan (1999) [1080p]/
+The Affair S01 Season 1 Complete HDTV 480p x264 AAC E-Subs [GWC]/
+The Affair Season 2 HDTV.XviD-AFG[Pawulon]/
+The Banker (2020) [720p] [WEBRip] [YTS.MX]/
+The Bourne Legacy (2012)/
+The Bourne Supremacy (2004)/
+The Bourne Ultimatum (2007)/
+The Bourne identity (2002)/
+The Call Of The Wild (2020) [720p] [WEBRip] [YTS.MX]/
+The Glass House (2001) [WEBRip] [720p] [YTS.LT]/
+The Irishman.2019.HDRip.XviD.AC3-EVO[TGx]/
+The Iron Mask (2019) [720p] [WEBRip] [YTS.MX]/
+The Thin Red Line (1998)/
+The UNIT (2006-2009) - Complete TV Series (Seasons 1,2,3,4 S01-S04) - 720p Web-DL x264/
+The.100.S07E01.720p.HDTV.x265-MiNX[TGx]/
+The.100.S07E02.720p.HDTV.x265-MiNX[TGx]/
+The.100.S07E03.720p.WEB.x265-MiNX[TGx]/
+The.100.S07E04.720p.HDTV.x265-MiNX[TGx]/
+The.100.S07E05.720p.WEB.x265-MiNX[TGx]/
+The.100.S07E06.720p.HDTV.x265-MiNX[TGx]/
+The.Affair.S04.WEBRip.XviD-FUM[ettv]/
+The.Bourne.Collection.2002-2012.BRRip.XviD-KiNGS-AbSurdiTy/
+The.Boy.2.2020.HC.720p.HDRip.800MB.x264-GalaxyRG[TGx]/
+The.Boys.2019.S01.COMPLETE.720p.AMZN.WEBRip.x264-GalaxyTV[TGx]/
+The.Call.of.the.Wild.2020.WEBRip.x264-ION10/
+The.Capture.S01/
+The.Flu.2013.KOREAN.720p.BrRip.x265.HEVCBay.com.mkv                                                575780346
+The.Gentlemen.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+The.Grudge.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+The.Hunt.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+The.Invisible.Man.2020.720p.WEBRip.800MB.x264-GalaxyRG[TGx]/
+The.Occupant.2020.SPANISH.720p.NF.WEBRip.DDP5.1.x264-NTb/
+The.Stranger.2020.S01.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+The.Witcher.S01.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+The.Wrong.Missy.2020.HDRip.XviD.AC3-EVO/
+Tom.Clancys.Jack.Ryan.S02.COMPLETE.720p.AMZN.WEBRip.x264-GalaxyTV[TGx]/
+Tom.and.Jerry.The.Golden.Collection.Volume.One.1940-1948.720p.BrRip.x265.HEVC-PSA/
+Tomorrow.Never.Dies.1997.mp4                                                                      1005670583
+Trolls.World.Tour.2020.HDRip.XviD.AC3-EVO[TGx]/
+Twilight.Saga.Complete.2008-2012.1080p.Rifftrax.6ch.2ch.v2/
+Underwater (2020) BluRay 1080p 10bit HEVC AAC 7.1 x265 ESubs ~RONIN~/
+Underwater.2020.720p.HDRip.800MB.x264-GalaxyRG[TGx]/
+Unparalleled Mulan 2020 720p HDRip Mandarin HC CHI-ENG H264 BONE.mp4                               729827741
+Virgin.River.S01.COMPLETE.720p.NF.WEB.x264-GalaxyTV[TGx]/
+Vivarium (2019) [720p] [WEBRip] [YTS.MX]/
+YOU.S01.720p.AMZN.WEBRip.DDP5.1.x264-NTb[rartv]/
+YOU.S02.COMPLETE.720p.NF.WEBRip.x264-GalaxyTV[TGx]/
+Zeitgeist Trilogy - WAKE UP AND SHARE THE TRUTH WITH EVERYONE YOU KNOW!! MUST SEE DOCUMENTARY PACK/
+jp191.nordvpn.com.udp.ovpn                                                                              2810
+jp247.nordvpn.com.udp.ovpn                                                                              2810
+parasite.2019.korean.720p.bluray.hevc.x265.mkv                                                     610041206
+seal.team.s03e06.mkv                                                                               433259279
+uc                                                                                                      3298
+us3087.nordvpn.com.udp.ovpn                                                                             2811
+us3299.nordvpn.com.udp.ovpn                                                                             2810
+us3942.nordvpn.com.udp.ovpn                                                                             2808
+us4362.nordvpn.com.udp.ovpn                                                                             2808
+us4363.nordvpn.com.udp.ovpn                                                                             2808
+us4664.nordvpn.com.udp.ovpn                                                                             2811
+us4874.nordvpn.com.udp.ovpn                                                                             2809
+us5101.nordvpn.com.udp.ovpn                                                                             2808
+www.SceneTime.com - Blindspot S05E07 480p x264-mSD/
+www.Scenetime.com - Arrow S08E03 720p HEVC x265-MeGusta/
+www.Scenetime.com - SEAL Team S03E09 480p x264-mSD/
+www.Scenetime.com - The Blacklist S07E07 720p HEVC x265-MeGusta/
+www.Scenetime.com - The Blacklist S07E08 720p HEVC x265-MeGusta/
+www.Torrenting.org       SEAL Team S03E09 720p HDTV x264-KILLERS/
+www.Torrenting.org - The.Blacklist.S07E19.480p.x264-mSD/
+
+
+Generated by darkhttpd/1.12 on Tue, 30 Jun 2020 10:33:21 GMT + + diff --git a/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104b.html.dat b/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104b.html.dat new file mode 100644 index 00000000..8711b39f --- /dev/null +++ b/OpenDirectoryDownloader.Tests/Samples/DirectoryListing104b.html.dat @@ -0,0 +1,16 @@ + + + + /1917.2019.DVDSCR.x264-TOPKEK%5BTGx%5D/ + + +

/1917.2019.DVDSCR.x264-TOPKEK%5BTGx%5D/

+
+../
+1917.2019.DVDSCR.x264-TOPKEK.mp4          1202701165
+[TGx]Downloaded from torrentgalaxy.to .txt       689
+
+
+Generated by darkhttpd/1.12 on Tue, 30 Jun 2020 10:33:46 GMT + + diff --git a/OpenDirectoryDownloader/DirectoryParser.cs b/OpenDirectoryDownloader/DirectoryParser.cs index 65664c77..82a83b5d 100644 --- a/OpenDirectoryDownloader/DirectoryParser.cs +++ b/OpenDirectoryDownloader/DirectoryParser.cs @@ -1154,6 +1154,65 @@ private static WebDirectory ParseTablesDirectoryListing(string baseUrl, WebDirec return match.Success; }; + private static readonly Func> RegexParser8 = async (webDirectory, baseUrl, line) => + { + Match match = Regex.Match(line, @"\s*\/?(?\S+)?"); + + if (match.Success) + { + bool isFile = !string.IsNullOrWhiteSpace(match.Groups["FileSize"].Value); + + if (match.Groups["FileSize"].Value.Contains("<")) + { + return false; + } + + IHtmlDocument parsedLine = await HtmlParser.ParseDocumentAsync(line); + + if (parsedLine.QuerySelector("a") != null) + { + IElement link = parsedLine.QuerySelector("a"); + string linkHref = link.Attributes["href"].Value; + + if (IsValidLink(link)) + { + Uri uri = new Uri(new Uri(baseUrl), linkHref); + string fullUrl = uri.ToString(); + + if (!isFile) + { + webDirectory.Subdirectories.Add(new WebDirectory(webDirectory) + { + Parser = "RegexParser8", + Url = fullUrl, + Name = WebUtility.UrlDecode(linkHref) + }); + } + else + { + try + { + string fileSize = match.Groups["FileSize"].Value; + + webDirectory.Files.Add(new WebFile + { + Url = fullUrl, + FileName = Path.GetFileName(WebUtility.UrlDecode(new Uri(fullUrl).AbsolutePath)), + FileSize = FileSizeHelper.ParseFileSize(fileSize) + }); + } + catch (Exception ex) + { + Logger.Error(ex, $"Error parsing with RegexParser8"); + } + } + } + } + } + + return match.Success; + }; + private static async Task ParsePreDirectoryListing(string baseUrl, WebDirectory parsedWebDirectory, IHtmlCollection pres) { List>> regexFuncs = new List>> @@ -1165,6 +1224,7 @@ private static async Task ParsePreDirectoryListing(string baseUrl, RegexParser5, RegexParser6, RegexParser7, + RegexParser8, }; foreach (IElement pre in pres)