From 1c8f94f1d8a6f545fbf1526aec6b1c91d4ede13a Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 25 Jan 2020 17:49:40 -0500 Subject: [PATCH] New: Filelist.ro Indexer Fixes #4061 --- .../Files/Indexers/BitMeTv/BitMeTv.xml | 65 ------------- .../Indexers/BroadcastheNet/RecentFeed.json | 61 ------------ .../Files/Indexers/FileList/recentfeed.json | 74 +++++++++++++++ .../KickassTorrents/KickassTorrents.xml | 93 ------------------- .../KickassTorrents_accents.xml | 93 ------------------- .../Files/Indexers/Wombles/wombles.xml | 78 ---------------- .../FileListTests/FileListFixture.cs | 57 ++++++++++++ .../FileListRequestGeneratorFixture.cs | 78 ++++++++++++++++ .../TorrentRssSettingsDetectorFixture.cs | 3 +- .../Indexers/FileList/FileList.cs | 30 ++++++ .../Indexers/FileList/FileListApi.cs | 24 +++++ .../Indexers/FileList/FileListParser.cs | 89 ++++++++++++++++++ .../FileList/FileListRequestGenerator.cs | 49 ++++++++++ .../Indexers/FileList/FileListSettings.cs | 78 ++++++++++++++++ 14 files changed, 480 insertions(+), 392 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/Files/Indexers/BitMeTv/BitMeTv.xml delete mode 100644 src/NzbDrone.Core.Test/Files/Indexers/BroadcastheNet/RecentFeed.json create mode 100644 src/NzbDrone.Core.Test/Files/Indexers/FileList/recentfeed.json delete mode 100644 src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents.xml delete mode 100644 src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents_accents.xml delete mode 100644 src/NzbDrone.Core.Test/Files/Indexers/Wombles/wombles.xml create mode 100644 src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs create mode 100644 src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs create mode 100644 src/NzbDrone.Core/Indexers/FileList/FileList.cs create mode 100644 src/NzbDrone.Core/Indexers/FileList/FileListApi.cs create mode 100644 src/NzbDrone.Core/Indexers/FileList/FileListParser.cs create mode 100644 src/NzbDrone.Core/Indexers/FileList/FileListRequestGenerator.cs create mode 100644 src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs diff --git a/src/NzbDrone.Core.Test/Files/Indexers/BitMeTv/BitMeTv.xml b/src/NzbDrone.Core.Test/Files/Indexers/BitMeTv/BitMeTv.xml deleted file mode 100644 index 345c51c87..000000000 --- a/src/NzbDrone.Core.Test/Files/Indexers/BitMeTv/BitMeTv.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - 10 - BitMeTV.ORG - http://www.bitmetv.org - This is a private - by registration only - website. You can help keep it alive by donating: http://www.bitmetv.org/donate.php - en-usde - Copyright © 2004 - 2007 BitMeTV.ORG - noreply@bitmetv.org - - BitMeTV.ORG - http://www.bitmetv.org/favicon.ico - http://www.bitmetv.org - 16 - 16 - This is a private - by registration only - website. You can help keep it alive by donating: http://www.bitmetv.org/donate.php - - - Total.Divas.S02E08.HDTV.x264-CRiMSON - http://www.bitmetv.org/download.php/12/Total.Divas.S02E08.HDTV.x264-CRiMSON.torrent - Tue, 13 May 2014 17:04:29 -0000 - - Category: (Reality TV - Un-scripted) - Size: 376.71 MB - - - - Aqua.Teen.Hunger.Force.S10.INTERNAL.HDTV.x264-BitMeTV - http://www.bitmetv.org/download.php/34/Aqua.Teen.Hunger.Force.S10.INTERNAL.HDTV.x264-BitMeTV.torrent - Tue, 13 May 2014 17:03:12 -0000 - - Category: (Adult Swim) - Size: 725.46 MB - - - - Antiques.Roadshow.US.S18E16.720p.HDTV.x264-BAJSKORV - http://www.bitmetv.org/download.php/56/Antiques.Roadshow.US.S18E16.720p.HDTV.x264-BAJSKORV.torrent - Tue, 13 May 2014 16:47:05 -0000 - - Category: (Reality TV - Un-scripted) - Size: 960.15 MB - - - - Seth.Meyers.2014.05.12.Chris.O.Dowd-Emma.Roberts.HDTV.x264-CROOKS - http://www.bitmetv.org/download.php/78/Seth.Meyers.2014.05.12.Chris.O.Dowd-Emma.Roberts.HDTV.x264-CROOKS.torrent - Tue, 13 May 2014 16:01:21 -0000 - - Category: Seth Meyers - Size: 301.31 MB - - - - The.Mole.Australia.Season.4 - http://www.bitmetv.org/download.php/910/The%20Mole%20Australia%20-%20Season%204.torrent - Tue, 13 May 2014 15:52:54 -0000 - - Category: (Reality TV - Competitive) - Size: 2.13 GB - - - - diff --git a/src/NzbDrone.Core.Test/Files/Indexers/BroadcastheNet/RecentFeed.json b/src/NzbDrone.Core.Test/Files/Indexers/BroadcastheNet/RecentFeed.json deleted file mode 100644 index 9ac55ee7c..000000000 --- a/src/NzbDrone.Core.Test/Files/Indexers/BroadcastheNet/RecentFeed.json +++ /dev/null @@ -1,61 +0,0 @@ -{ -"id":"9787693d", -"result":{ -"torrents":{ -"123":{ -"GroupName":"2014.09.15", -"GroupID":"237457", -"TorrentID":"123", -"SeriesID":"1034", -"Series":"Jimmy Kimmel Live", -"SeriesBanner":"https:\/\/cdn2.broadcasthe.net\/tvdb\/banners\/graphical\/71998-g.jpg", -"SeriesPoster":"https:\/\/cdn2.broadcasthe.net\/tvdb\/banners\/posters\/71998-3.jpg", -"YoutubeTrailer":"http:\/\/www.youtube.com\/v\/w3NwB9PLxss", -"Category":"Episode", -"Snatched":"40", -"Seeders":"40", -"Leechers":"9", -"Source":"HDTV", -"Container":"MP4", -"Codec":"x264", -"Resolution":"SD", -"Origin":"Scene", -"ReleaseName":"Jimmy.Kimmel.2014.09.15.Jane.Fonda.HDTV.x264-aAF", -"Size":"505099926", -"Time":"1410902133", -"TvdbID":"71998", -"TvrageID":"4055", -"ImdbID":"0320037", -"InfoHash":"123", -"DownloadURL":"https:\/\/broadcasthe.net\/torrents.php?action=download&id=123&authkey=123&torrent_pass=123" -}, -"1234":{ -"GroupName":"S01E02", -"GroupID":"237456", -"TorrentID":"1234", -"SeriesID":"45853", -"Series":"Mammon", -"SeriesBanner":"https:\/\/cdn2.broadcasthe.net\/tvdb\/banners\/text\/274366.jpg", -"SeriesPoster":"\/\/cdn2.broadcasthe.net\/tvdb\/banners\/posters\/274366-2.jpg", -"YoutubeTrailer":"http:\/\/www.youtube.com\/v\/1VVbJecvHr8", -"Category":"Episode", -"Snatched":"0", -"Seeders":"1", -"Leechers":"23", -"Source":"HDTV", -"Container":"TS", -"Codec":"h.264", -"Resolution":"1080i", -"Origin":"Internal", -"ReleaseName":"Mammon.S01E02.1080i.HDTV.H.264-Irishman", -"Size":"4021238596", -"Time":"1410901918", -"TvdbID":"274366", -"TvrageID":"38472", -"ImdbID":"2377081", -"InfoHash":"1234", -"DownloadURL":"https:\/\/broadcasthe.net\/torrents.php?action=download&id=1234&authkey=1234&torrent_pass=1234" -}}, -"results":"117927" -} -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Files/Indexers/FileList/recentfeed.json b/src/NzbDrone.Core.Test/Files/Indexers/FileList/recentfeed.json new file mode 100644 index 000000000..51d249835 --- /dev/null +++ b/src/NzbDrone.Core.Test/Files/Indexers/FileList/recentfeed.json @@ -0,0 +1,74 @@ +[ + { + "id": 665873, + "name": "Storming.Juno.2010.1080p.BluRay.x264-GUACAMOLE", + "imdb": "tt1776305", + "freeleech": 0, + "upload_date": "2020-01-25 22:20:19", + "download_link": "https://filelist.ro/download.php?id=665873&passkey=somepass", + "size": 8300512414, + "internal": 0, + "moderated": 1, + "category": "Filme HD", + "seeders": 12, + "leechers": 2, + "times_completed": 11, + "comments": 0, + "files": 3, + "small_description": "History, War" + }, + { + "id": 665872, + "name": "Storming.Juno.2010.720p.BluRay.x264-GUACAMOLE", + "imdb": "tt1776305", + "freeleech": 0, + "upload_date": "2020-01-25 22:19:37", + "download_link": "https://filelist.ro/download.php?id=665872&passkey=somepass", + "size": 4731949881, + "internal": 0, + "moderated": 1, + "category": "Filme HD", + "seeders": 9, + "leechers": 1, + "times_completed": 8, + "comments": 0, + "files": 3, + "small_description": "History, War" + }, + { + "id": 665870, + "name": "Summer.Holiday.1963.1080p.BluRay.x264-SPOOKS", + "imdb": "tt0057541", + "freeleech": 1, + "upload_date": "2020-01-25 21:48:20", + "download_link": "https://filelist.ro/download.php?id=665870&passkey=somepass", + "size": 8325717640, + "internal": 0, + "moderated": 1, + "category": "Filme HD", + "seeders": 20, + "leechers": 6, + "times_completed": 22, + "comments": 0, + "files": 5, + "small_description": "Comedy, Musical" + }, + { + "id": 665868, + "name": "Ride.Like.a.Girl.2019.1080p.BluRay.DD5.1.x264-playHD", + "imdb": "tt7600382", + "freeleech": 1, + "upload_date": "2020-01-25 20:32:22", + "download_link": "https://filelist.ro/download.php?id=665868&passkey=somepass", + "size": 15514501683, + "internal": 1, + "moderated": 1, + "category": "Filme HD", + "seeders": 63, + "leechers": 4, + "times_completed": 80, + "comments": 0, + "files": 1, + "small_description": "Biography, Drama, Sport" + } +] \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents.xml b/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents.xml deleted file mode 100644 index c922c55ee..000000000 --- a/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - tv torrents RSS feed - KickassTorrents - http://kickass.to/ - tv torrents RSS feed - - Doctor Stranger.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html - http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html - Mon, 12 May 2014 16:16:49 +0000 - 1205364736 - 208C4F7866612CC88BFEBC7C496FA72C2368D1C0 - - 206 - 311 - 1 - doctor.stranger.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.XViD-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html - http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html - Mon, 12 May 2014 16:16:31 +0000 - 677543936 - BF22A53C9889A7D325F2A3D904E566B7DF4074EB - - 242 - 374 - 1 - triangle.e03.140512.hdtv.xvid.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html - http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html - Mon, 12 May 2014 16:16:10 +0000 - 1196869632 - 8427BFB8884B8228364EBB9B3EA7D8B77E03A7BC - - 177 - 268 - 1 - triangle.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.X264.720p-BarosG_.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html - http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html - Mon, 12 May 2014 16:15:52 +0000 - 1418906266 - 5556B773893DB55287ECEC581E850B853163DB11 - - 522 - 785 - 1 - triangle.e03.140512.hdtv.x264.720p.barosg.avi.ctrg.torrent - - - - Battlestar Galactica 1978 Dvd3 e09 e10 e11 e12 [NL] [FR] [ENG] Sub - - - - TV - http://kickass.to/user/hendriknl/ - http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html - http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html - Mon, 12 May 2014 16:15:46 +0000 - 4680841216 - 3D293CAFEDAC595F6E55F9C284DD76862FE254F6 - - 2 - 5 - 0 - battlestar.galactica.1978.dvd3.e09.e10.e11.e12.nl.fr.eng.sub.torrent - - - - \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents_accents.xml b/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents_accents.xml deleted file mode 100644 index 7deced5f1..000000000 --- a/src/NzbDrone.Core.Test/Files/Indexers/KickassTorrents/KickassTorrents_accents.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - tv torrents RSS feed - KickassTorrents - http://kickass.to/ - tv torrents RSS feed - - Doctor Strangér.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html - http://kickass.to/doctor-stranger-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100648.html - Mon, 12 May 2014 16:16:49 +0000 - 1205364736 - 208C4F7866612CC88BFEBC7C496FA72C2368D1C0 - - 206 - 311 - 1 - doctor.stranger.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.XViD-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html - http://kickass.to/triangle-e03-140512-hdtv-xvid-ipop-avi-ctrg-t9100647.html - Mon, 12 May 2014 16:16:31 +0000 - 677543936 - BF22A53C9889A7D325F2A3D904E566B7DF4074EB - - 242 - 374 - 1 - triangle.e03.140512.hdtv.xvid.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.H264.720p-iPOP.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html - http://kickass.to/triangle-e03-140512-hdtv-h264-720p-ipop-avi-ctrg-t9100646.html - Mon, 12 May 2014 16:16:10 +0000 - 1196869632 - 8427BFB8884B8228364EBB9B3EA7D8B77E03A7BC - - 177 - 268 - 1 - triangle.e03.140512.hdtv.h264.720p.ipop.avi.ctrg.torrent - - - - Triangle.E03.140512.HDTV.X264.720p-BarosG_.avi [CTRG] - TV - http://kickass.to/user/2NE1/ - http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html - http://kickass.to/triangle-e03-140512-hdtv-x264-720p-barosg-avi-ctrg-t9100644.html - Mon, 12 May 2014 16:15:52 +0000 - 1418906266 - 5556B773893DB55287ECEC581E850B853163DB11 - - 522 - 785 - 1 - triangle.e03.140512.hdtv.x264.720p.barosg.avi.ctrg.torrent - - - - Battlestar Galactica 1978 Dvd3 e09 e10 e11 e12 [NL] [FR] [ENG] Sub - - - - TV - http://kickass.to/user/hendriknl/ - http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html - http://kickass.to/battlestar-galactica-1978-dvd3-e09-e10-e11-e12-nl-fr-eng-sub-t9100642.html - Mon, 12 May 2014 16:15:46 +0000 - 4680841216 - 3D293CAFEDAC595F6E55F9C284DD76862FE254F6 - - 2 - 5 - 0 - battlestar.galactica.1978.dvd3.e09.e10.e11.e12.nl.fr.eng.sub.torrent - - - - \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Files/Indexers/Wombles/wombles.xml b/src/NzbDrone.Core.Test/Files/Indexers/Wombles/wombles.xml deleted file mode 100644 index ee0f7e362..000000000 --- a/src/NzbDrone.Core.Test/Files/Indexers/Wombles/wombles.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - Womble's NZB Index - http://indexer.local/ - NZB Index - my.email@internet.me - 15 - - - - One.Child.S01E01.720p.HDTV.x264-TLA - http://indexer.local/nzb/bb4/One.Child.S01E01.720p.HDTV.x264-TLA.nzb - - One.Child.S01E01.720p.HDTV.x264-TLA - (Size:956 Mb) - - tv-hd - 2/17/2016 11:03:52 PM - http://indexer.local/nzb/bb4/One.Child.S01E01.720p.HDTV.x264-TLA.nzb - - - - - Midsomer.Murders.S18E06.Harvest.Of.Souls.HDTV.x264-ORGANiC - http://indexer.local/nzb/17c/Midsomer.Murders.S18E06.Harvest.Of.Souls.HDTV.x264-ORGANiC.nzb - - Midsomer.Murders.S18E06.Harvest.Of.Souls.HDTV.x264-ORGANiC - (Size:730 Mb) - - tv-sd - 2/17/2016 10:55:33 PM - http://indexer.local/nzb/17c/Midsomer.Murders.S18E06.Harvest.Of.Souls.HDTV.x264-ORGANiC.nzb - - - - - Forget.and.Forgive.2014.HDTV.x264-SQUEAK - http://indexer.local/nzb/f3f/Forget.and.Forgive.2014.HDTV.x264-SQUEAK.nzb - - Forget.and.Forgive.2014.HDTV.x264-SQUEAK - (Size:719 Mb) - - tv-sd - 2/17/2016 10:25:28 PM - http://indexer.local/nzb/f3f/Forget.and.Forgive.2014.HDTV.x264-SQUEAK.nzb - - - - - National.Geographic.The.Lakeshore.Killers.HDTV.x264-SQUEAK - http://indexer.local/nzb/828/National.Geographic.The.Lakeshore.Killers.HDTV.x264-SQUEAK.nzb - - National.Geographic.The.Lakeshore.Killers.HDTV.x264-SQUEAK - (Size:436 Mb) - - tv-sd - 2/17/2016 10:20:36 PM - http://indexer.local/nzb/828/National.Geographic.The.Lakeshore.Killers.HDTV.x264-SQUEAK.nzb - - - - - Desert.Lands.of.The.Middle.East.E01.Turkeys.Harsh.Paradise.HDTV.x264-SQUEAK - http://indexer.local/nzb/210/Desert.Lands.of.The.Middle.East.E01.Turkeys.Harsh.Paradise.HDTV.x264-SQUEAK.nzb - - Desert.Lands.of.The.Middle.East.E01.Turkeys.Harsh.Paradise.HDTV.x264-SQUEAK - (Size:460 Mb) - - tv-sd - 2/17/2016 10:18:29 PM - http://indexer.local/nzb/210/Desert.Lands.of.The.Middle.East.E01.Turkeys.Harsh.Paradise.HDTV.x264-SQUEAK.nzb - - - - - \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs new file mode 100644 index 000000000..b39dd6407 --- /dev/null +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs @@ -0,0 +1,57 @@ +using System; +using System.Linq; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.FileList; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.IndexerTests.FileListTests +{ + [TestFixture] + public class FileListFixture : CoreTest + { + [SetUp] + public void Setup() + { + Subject.Definition = new IndexerDefinition() + { + Name = "FileList", + Settings = new FileListSettings() { Username = "someuser", Passkey = "somepass" } + }; + } + + [Test] + public void should_parse_recent_feed_from_FileList() + { + var recentFeed = ReadAllText(@"Files/Indexers/FileList/recentfeed.json"); + + Mocker.GetMock() + .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) + .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); + + var releases = Subject.FetchRecent(); + + releases.Should().HaveCount(4); + releases.First().Should().BeOfType(); + + var torrentInfo = releases.First() as TorrentInfo; + + torrentInfo.Title.Should().Be("Storming.Juno.2010.1080p.BluRay.x264-GUACAMOLE"); + torrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); + torrentInfo.DownloadUrl.Should().Be("https://filelist.ro/download.php?id=665873&passkey=somepass"); + torrentInfo.InfoUrl.Should().Be("https://filelist.ro/details.php?id=665873"); + torrentInfo.CommentUrl.Should().BeNullOrEmpty(); + torrentInfo.Indexer.Should().Be(Subject.Definition.Name); + torrentInfo.PublishDate.Should().Be(DateTime.Parse("2020-01-25 22:20:19")); + torrentInfo.Size.Should().Be(8300512414); + torrentInfo.InfoHash.Should().Be(null); + torrentInfo.MagnetUrl.Should().Be(null); + torrentInfo.Peers.Should().Be(2 + 12); + torrentInfo.Seeders.Should().Be(12); + } + } +} diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs new file mode 100644 index 000000000..702d800cf --- /dev/null +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs @@ -0,0 +1,78 @@ +using System.Linq; +using FluentAssertions; +using Newtonsoft.Json; +using NUnit.Framework; +using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers.FileList; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.IndexerTests.FileListTests +{ + public class FileListRequestGeneratorFixture : CoreTest + { + private MovieSearchCriteria _movieSearchCriteria; + + [SetUp] + public void Setup() + { + Subject.Settings = new FileListSettings() + { + BaseUrl = "http://127.0.0.1:1234/", + Categories = new[] { 1, 2 }, + Passkey = "abcd", + Username = "somename" + }; + + _movieSearchCriteria = new MovieSearchCriteria + { + Movie = new Movies.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 } + }; + } + + private void MovieWithoutIMDB() + { + _movieSearchCriteria.Movie.ImdbId = null; + } + + [Test] + public void should_use_categories_for_feed() + { + var results = Subject.GetRecentRequests(); + + results.GetAllTiers().Should().HaveCount(1); + + var page = results.GetAllTiers().First().First(); + + page.Url.Query.Should().Contain("&category=1,2&"); + } + + [Test] + public void should_not_search_by_imdbid_if_not_supported() + { + var results = Subject.GetSearchRequests(_movieSearchCriteria); + + results.GetAllTiers().Should().HaveCount(1); + + var page = results.GetAllTiers().First().First(); + + page.Url.Query.Should().Contain("type=imdb"); + page.Url.Query.Should().Contain("query=tt0076759"); + } + + [Test] + public void should_search_by_name_and_year_if_missing_imdbid() + { + MovieWithoutIMDB(); + + var results = Subject.GetSearchRequests(_movieSearchCriteria); + + results.GetAllTiers().Should().HaveCount(1); + + var page = results.GetAllTiers().First().First(); + + page.Url.Query.Should().Contain("type=name"); + page.Url.Query.Should().Contain("query=Star Wars 1977"); + } + } +} diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs index 298023513..f8e0d0b3c 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Http; @@ -252,7 +252,6 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests }); } - [TestCase("BitMeTv/BitMeTv.xml")] [TestCase("IPTorrents/IPTorrents.xml")] [TestCase("Nyaa/Nyaa.xml")] [TestCase("Torznab/torznab_hdaccess_net.xml")] diff --git a/src/NzbDrone.Core/Indexers/FileList/FileList.cs b/src/NzbDrone.Core/Indexers/FileList/FileList.cs new file mode 100644 index 000000000..acb8da35d --- /dev/null +++ b/src/NzbDrone.Core/Indexers/FileList/FileList.cs @@ -0,0 +1,30 @@ +using NLog; +using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Parser; + +namespace NzbDrone.Core.Indexers.FileList +{ + public class FileList : HttpIndexerBase + { + public override string Name => "FileList.ro"; + public override DownloadProtocol Protocol => DownloadProtocol.Torrent; + public override bool SupportsRss => true; + public override bool SupportsSearch => true; + + public FileList(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) + : base(httpClient, indexerStatusService, configService, parsingService, logger) + { + } + + public override IIndexerRequestGenerator GetRequestGenerator() + { + return new FileListRequestGenerator() { Settings = Settings }; + } + + public override IParseIndexerResponse GetParser() + { + return new FileListParser(Settings); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListApi.cs b/src/NzbDrone.Core/Indexers/FileList/FileListApi.cs new file mode 100644 index 000000000..eea73fae6 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/FileList/FileListApi.cs @@ -0,0 +1,24 @@ +using System; +using Newtonsoft.Json; + +namespace NzbDrone.Core.Indexers.FileList +{ + public class FileListTorrent + { + public string Id { get; set; } + public string Name { get; set; } + public long Size { get; set; } + public int Leechers { get; set; } + public int Seeders { get; set; } + [JsonProperty(PropertyName = "times_completed")] + public uint TimesCompleted { get; set; } + public uint Comments { get; set; } + public uint Files { get; set; } + [JsonProperty(PropertyName = "imdb")] + public string ImdbId { get; set; } + [JsonProperty(PropertyName = "freeleech")] + public bool FreeLeech { get; set; } + [JsonProperty(PropertyName = "upload_date")] + public DateTime UploadDate { get; set; } + } +} diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs b/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs new file mode 100644 index 000000000..3debd213f --- /dev/null +++ b/src/NzbDrone.Core/Indexers/FileList/FileListParser.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Net; +using Newtonsoft.Json; +using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers.Exceptions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.Indexers.FileList +{ + public class FileListParser : IParseIndexerResponse + { + private readonly FileListSettings _settings; + + public FileListParser(FileListSettings settings) + { + _settings = settings; + } + + public IList ParseResponse(IndexerResponse indexerResponse) + { + var torrentInfos = new List(); + + if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + { + throw new IndexerException(indexerResponse, + "Unexpected response status {0} code from API request", + indexerResponse.HttpResponse.StatusCode); + } + + var queryResults = JsonConvert.DeserializeObject>(indexerResponse.Content); + + foreach (var result in queryResults) + { + var id = result.Id; + + IndexerFlags flags = 0; + + if (result.FreeLeech) + { + flags |= IndexerFlags.G_Freeleech; + } + + var imdbId = 0; + if (result.ImdbId.Length > 2) + { + imdbId = int.Parse(result.ImdbId.Substring(2)); + } + + torrentInfos.Add(new TorrentInfo() + { + Guid = string.Format("FileList-{0}", id), + Title = result.Name, + Size = result.Size, + DownloadUrl = GetDownloadUrl(id), + InfoUrl = GetInfoUrl(id), + Seeders = result.Seeders, + Peers = result.Leechers + result.Seeders, + PublishDate = result.UploadDate, + ImdbId = imdbId, + IndexerFlags = flags + }); + } + + return torrentInfos.ToArray(); + } + + public Action, DateTime?> CookiesUpdater { get; set; } + + private string GetDownloadUrl(string torrentId) + { + var url = new HttpUri(_settings.BaseUrl) + .CombinePath("/download.php") + .AddQueryParam("id", torrentId) + .AddQueryParam("passkey", _settings.Passkey); + + return url.FullUri; + } + + private string GetInfoUrl(string torrentId) + { + var url = new HttpUri(_settings.BaseUrl) + .CombinePath("/details.php") + .AddQueryParam("id", torrentId); + + return url.FullUri; + } + } +} diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListRequestGenerator.cs b/src/NzbDrone.Core/Indexers/FileList/FileListRequestGenerator.cs new file mode 100644 index 000000000..c462bdc2e --- /dev/null +++ b/src/NzbDrone.Core/Indexers/FileList/FileListRequestGenerator.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Common.Extensions; +using NzbDrone.Common.Http; +using NzbDrone.Core.IndexerSearch.Definitions; + +namespace NzbDrone.Core.Indexers.FileList +{ + public class FileListRequestGenerator : IIndexerRequestGenerator + { + public FileListSettings Settings { get; set; } + public Func> GetCookies { get; set; } + public Action, DateTime?> CookiesUpdater { get; set; } + + public virtual IndexerPageableRequestChain GetRecentRequests() + { + var pageableRequests = new IndexerPageableRequestChain(); + pageableRequests.Add(GetRequest("latest-torrents", "")); + return pageableRequests; + } + + public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) + { + var pageableRequests = new IndexerPageableRequestChain(); + + if (searchCriteria.Movie.ImdbId.IsNotNullOrWhiteSpace()) + { + pageableRequests.Add(GetRequest("search-torrents", string.Format("&type=imdb&query={0}", searchCriteria.Movie.ImdbId))); + } + else + { + var titleYearSearchQuery = string.Format("{0} {1}", searchCriteria.Movie.Title, searchCriteria.Movie.Year); + pageableRequests.Add(GetRequest("search-torrents", string.Format("&type=name&query={0}", titleYearSearchQuery.Trim()))); + } + + return pageableRequests; + } + + private IEnumerable GetRequest(string searchType, string parameters) + { + var categoriesQuery = string.Join(",", Settings.Categories.Distinct()); + + var baseUrl = string.Format("{0}/api.php?action={1}&category={2}&username={3}&passkey={4}{5}", Settings.BaseUrl.TrimEnd('/'), searchType, categoriesQuery, Settings.Username.Trim(), Settings.Passkey.Trim(), parameters); + + yield return new IndexerRequest(baseUrl, HttpAccept.Json); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs b/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs new file mode 100644 index 000000000..2988f9974 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using FluentValidation; +using NzbDrone.Core.Annotations; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.Indexers.FileList +{ + public class FileListSettingsValidator : AbstractValidator + { + public FileListSettingsValidator() + { + RuleFor(c => c.BaseUrl).ValidRootUrl(); + RuleFor(c => c.Username).NotEmpty(); + RuleFor(c => c.Passkey).NotEmpty(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); + } + } + + public class FileListSettings : ITorrentIndexerSettings + { + private static readonly FileListSettingsValidator Validator = new FileListSettingsValidator(); + + public FileListSettings() + { + BaseUrl = "https://filelist.ro"; + MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS; + + Categories = new int[] { (int)FileListCategories.Movie_HD, (int)FileListCategories.Movie_SD, (int)FileListCategories.Movie_4K }; + MultiLanguages = new List(); + RequiredFlags = new List(); + } + + [FieldDefinition(0, Label = "Username")] + public string Username { get; set; } + + [FieldDefinition(1, Label = "Passkey")] + public string Passkey { get; set; } + + //[FieldDefinition(2, Type = FieldType.Tag, SelectOptions = typeof(Language), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)] + public IEnumerable MultiLanguages { get; set; } + + [FieldDefinition(3, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")] + public string BaseUrl { get; set; } + + [FieldDefinition(4, Label = "Categories", Type = FieldType.TagSelect, SelectOptions = typeof(FileListCategories), Advanced = true, HelpText = "Categories for use in search and feeds. If unspecified, all options are used.")] + public IEnumerable Categories { get; set; } + + [FieldDefinition(5, Type = FieldType.Number, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] + public int MinimumSeeders { get; set; } + + [FieldDefinition(6, Type = FieldType.TagSelect, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://github.com/Radarr/Radarr/wiki/Indexer-Flags#1-required-flags", Advanced = true)] + public IEnumerable RequiredFlags { get; set; } + + [FieldDefinition(7)] + public SeedCriteriaSettings SeedCriteria { get; set; } = new SeedCriteriaSettings(); + + public NzbDroneValidationResult Validate() + { + return new NzbDroneValidationResult(Validator.Validate(this)); + } + } + + public enum FileListCategories + { + Movie_SD = 1, + Movie_DVD = 2, + Movie_DVDRO = 3, + Movie_HD = 4, + Movie_HDRO = 19, + Movie_BluRay = 20, + Movie_BluRay4K = 26, + Movie_3D = 25, + Movie_4K = 6, + Xxx = 7 + } +}