diff --git a/src/Jackett/Content/logos/bakabt.png b/src/Jackett/Content/logos/bakabt.png new file mode 100644 index 000000000..b0761f625 Binary files /dev/null and b/src/Jackett/Content/logos/bakabt.png differ diff --git a/src/Jackett/Indexers/BakaBT.cs b/src/Jackett/Indexers/BakaBT.cs new file mode 100644 index 000000000..cdd7106ca --- /dev/null +++ b/src/Jackett/Indexers/BakaBT.cs @@ -0,0 +1,198 @@ +using CsQuery; +using Jackett.Models; +using Jackett.Services; +using Jackett.Utils; +using Jackett.Utils.Clients; +using Newtonsoft.Json.Linq; +using NLog; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using Jackett.Models.IndexerConfig; + +namespace Jackett.Indexers +{ + public class BakaBT : BaseIndexer, IIndexer + { + public string SearchUrl { get { return SiteLink + "browse.php?only=0&incomplete=1&lossless=1&hd=1&multiaudio=1&bonus=1&reorder=1&q="; } } + public string LoginUrl { get { return SiteLink + "login.php"; } } + public string id = "bakabt"; + + new ConfigurationDataBasicLogin configData + { + get { return (ConfigurationDataBasicLogin)base.configData; } + set { base.configData = value; } + } + + public BakaBT(IIndexerManagerService i, IWebClient wc, Logger l, IProtectionService ps) + : base(name: "BakaBT", + description: "Anime Comunity", + link: "https://bakabt.me/", + caps: new TorznabCapabilities(TorznabCatType.TVAnime), + manager: i, + client: wc, + logger: l, + p: ps, + configData: new ConfigurationDataBasicLogin()) + { + } + + + public async Task ApplyConfiguration(JToken configJson) + { + configData.LoadValuesFromJson(configJson); + + var loginForm = await webclient.GetString(new Utils.Clients.WebRequest() + { + Url = LoginUrl, + Type = RequestType.GET + }); + + var pairs = new Dictionary { + { "username", configData.Username.Value }, + { "password", configData.Password.Value }, + { "returnto", "/index.php" } + }; + + var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginForm.Cookies, true, null, SiteLink); + var responseContent = response.Content; + await ConfigureIfOK(response.Cookies, responseContent.Contains("Logout"), () => + { + CQ dom = responseContent; + var messageEl = dom[".error"].First(); + var errorMessage = messageEl.Text().Trim(); + throw new ExceptionWithConfigData(errorMessage, configData); + }); + + return IndexerConfigurationStatus.RequiresTesting; + } + + public async Task> PerformQuery(TorznabQuery query) + { + + // This tracker only deals with full seasons so chop off the episode/season number if we have it D: + if (!string.IsNullOrWhiteSpace(query.SearchTerm)) + { + var splitindex = query.SearchTerm.LastIndexOf(' '); + if (splitindex > -1) + query.SearchTerm = query.SearchTerm.Substring(0, splitindex); + } + + var releases = new List(); + var searchString = query.SanitizedSearchTerm; + var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString); + var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl); + + try + { + CQ dom = response.Content; + var rows = dom[".torrents tr.torrent"]; + + foreach (var row in rows) + { + + var qRow = row.Cq(); + var qTitleLink = qRow.Find("a.title").First(); + var title = qTitleLink.Text().Trim(); + + // Insert before the release info + var taidx = title.IndexOf('('); + var tbidx = title.IndexOf('['); + + if (taidx == -1) + taidx = title.Length; + + if (tbidx == -1) + tbidx = title.Length; + var titleSplit = Math.Min(taidx, tbidx); + var titleSeries = title.Substring(0, titleSplit); + var releaseInfo = title.Substring(titleSplit); + + // For each over each pipe deliminated name + foreach (var name in titleSeries.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) + { + var release = new ReleaseInfo(); + + release.Title = (name + releaseInfo).Trim(); + // Ensure the season is defined as this tracker only deals with full seasons + if (release.Title.IndexOf("Season") == -1) + { + // Insert before the release info + var aidx = release.Title.IndexOf('('); + var bidx = release.Title.IndexOf('['); + + if (aidx == -1) + aidx = release.Title.Length; + + if (bidx == -1) + bidx = release.Title.Length; + + var insertPoint = Math.Min(aidx, bidx); + release.Title = release.Title.Substring(0, insertPoint) + "Season 1 " + release.Title.Substring(insertPoint); + } + + release.Description = release.Title; + release.Guid = new Uri(SiteLink + qTitleLink.Attr("href")); + release.Comments = release.Guid; + + release.Link = new Uri(SiteLink + qRow.Find(".peers a").First().Attr("href")); + + release.Seeders = int.Parse(qRow.Find(".peers a").Get(0).InnerText); + release.Peers = release.Seeders + int.Parse(qRow.Find(".peers a").Get(1).InnerText); + + release.MinimumRatio = 1; + + var size = qRow.Find(".size").First().Text(); + release.Size = ReleaseInfo.GetBytes(size); + + //22 Jul 15 + var dateStr = qRow.Find(".added").First().Text().Replace("'", string.Empty); + if (dateStr.Split(' ')[0].Length == 1) + dateStr = "0" + dateStr; + + if (string.Equals(dateStr, "yesterday", StringComparison.InvariantCultureIgnoreCase)) + { + release.PublishDate = DateTime.Now.AddDays(-1); + } + else if (string.Equals(dateStr, "today", StringComparison.InvariantCultureIgnoreCase)) + { + release.PublishDate = DateTime.Now; + } + else + { + release.PublishDate = DateTime.ParseExact(dateStr, "dd MMM yy", CultureInfo.InvariantCulture); + } + + releases.Add(release); + } + } + } + catch (Exception ex) + { + OnParseError(response.Content, ex); + } + + return releases; + } + + public override async Task Download(Uri link) + { + var downloadPage = await RequestStringWithCookies(link.ToString()); + CQ dom = downloadPage.Content; + var downloadLink = dom.Find(".download_link").First().Attr("href"); + + if (string.IsNullOrWhiteSpace(downloadLink)) + { + throw new Exception("Unable to find download link."); + } + + var response = await RequestBytesWithCookies(SiteLink + downloadLink); + return response.Content; + } + } +} \ No newline at end of file diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index f09eb64f7..8711c6d4b 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -49,134 +49,100 @@ prompt 4 - - - - - - - - - - ..\packages\AngleSharp.0.9.7\lib\net45\AngleSharp.dll - True - - - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - True - - - ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll - True - - - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - True - - - ..\packages\Autofac.WebApi2.Owin.3.3.0\lib\net45\Autofac.Integration.WebApi.Owin.dll - True - - - ..\packages\AutoMapper.4.1.1\lib\net45\AutoMapper.dll - True - - - ..\packages\CsQuery.1.3.4\lib\net40\CsQuery.dll - True - - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - True - - - ..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll - True - - - ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll - True - - - ..\packages\Microsoft.Owin.FileSystems.3.0.1\lib\net45\Microsoft.Owin.FileSystems.dll - True - - - ..\packages\Microsoft.Owin.Host.HttpListener.3.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll - True - - - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - True - - - ..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll - True - - - ..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll - True - - - ..\packages\MonoTorrent.0.9.0\lib\net20\MonoTorrent.dll - True - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\NLog.4.3.7\lib\net45\NLog.dll - True - - - ..\packages\NLog.Windows.Forms.4.2.3\lib\net35\NLog.Windows.Forms.dll - True - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll - True - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll - True - - - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll - True - - - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll - True - - - ..\packages\Microsoft.AspNet.WebApi.Tracing.5.2.3\lib\net45\System.Web.Http.Tracing.dll - True - + + ..\packages\AngleSharp.0.9.7\lib\net45\AngleSharp.dll + + + ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll + + + ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll + + + ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll + + + ..\packages\Autofac.WebApi2.Owin.3.3.0\lib\net45\Autofac.Integration.WebApi.Owin.dll + + + ..\packages\AutoMapper.4.1.1\lib\net45\AutoMapper.dll + + + ..\packages\CsQuery.1.3.4\lib\net40\CsQuery.dll + + + ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + + ..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll + + + ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll + + + ..\packages\Microsoft.Owin.FileSystems.3.0.1\lib\net45\Microsoft.Owin.FileSystems.dll + + + ..\packages\Microsoft.Owin.Host.HttpListener.3.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll + + + ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll + + + ..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll + + + ..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll + + + ..\packages\MonoTorrent.0.9.0\lib\net20\MonoTorrent.dll + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\NLog.4.3.7\lib\net45\NLog.dll + + + ..\packages\NLog.Windows.Forms.4.2.3\lib\net35\NLog.Windows.Forms.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + + + ..\packages\Microsoft.AspNet.WebApi.Tracing.5.2.3\lib\net45\System.Web.Http.Tracing.dll + @@ -338,6 +304,7 @@ + @@ -629,6 +596,9 @@ PreserveNewest + + PreserveNewest +