public static List<TorrentLink> SearchTorrents(DownloadSearchCriteria search) { List<string> parms = search.GetParms(); List<TorrentLink> links = new List<TorrentLink>(); TorrentsAnimeSuki suki = new TorrentsAnimeSuki(); TorrentsBakaUpdates bakau = new TorrentsBakaUpdates(); List<string> episodeGroupParms = new List<string>(); // lets do something special for episodes if (BaseConfig.Settings.TorrentPreferOwnGroups && search.SearchType == DownloadSearchType.Episode) { AnimeEpisodeVM ep = search.SearchParameter as AnimeEpisodeVM; AnimeSeriesVM series = JMMServerHelper.GetSeries(ep.AnimeSeriesID); if (series != null && series.AniDB_Anime != null) { List<GroupVideoQualityVM> videoQualityRecords = new List<GroupVideoQualityVM>(); List<JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(series.AniDB_Anime.AnimeID); foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ) { GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract); videoQualityRecords.Add(vidQual); } // apply sorting if (videoQualityRecords.Count > 0) { List<SortPropOrFieldAndDirection> sortlist = new List<SortPropOrFieldAndDirection>(); sortlist.Add(new SortPropOrFieldAndDirection("FileCountNormal", true, SortType.eInteger)); videoQualityRecords = Sorting.MultiSort<GroupVideoQualityVM>(videoQualityRecords, sortlist); } //only use the first 2 int i = 0; foreach (GroupVideoQualityVM gvq in videoQualityRecords) { if (i == 2) break; if (!episodeGroupParms.Contains(gvq.GroupNameShort)) { episodeGroupParms.Add(gvq.GroupNameShort); i++; } } } } // if searching by series and BakaBT is enabled, use that first bool doneBakaBT = false; if (BaseConfig.Settings.TorrentSources.Contains(MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT) && search.SearchType == DownloadSearchType.Series) { doneBakaBT = true; TorrentsBakaBT bakbt = new TorrentsBakaBT(); List<TorrentLink> bakbtLinks = bakbt.GetTorrents(parms); links.AddRange(bakbtLinks); } bool doneAnimeBytes = false; if (BaseConfig.Settings.TorrentSources.Contains(MyAnimePlugin3.Constants.TorrentSourceNames.AnimeBytes) && search.SearchType == DownloadSearchType.Series) { doneAnimeBytes = true; TorrentsAnimeBytes abytes = new TorrentsAnimeBytes(); List<TorrentLink> abytesLinks = abytes.GetTorrents(parms); links.AddRange(abytesLinks); } foreach (string src in BaseConfig.Settings.TorrentSources) { if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT && !doneBakaBT) { TorrentsBakaBT bakbt = new TorrentsBakaBT(); List<TorrentLink> bakbtLinks = bakbt.GetTorrents(parms); links.AddRange(bakbtLinks); } if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaBT && !doneAnimeBytes) { TorrentsAnimeBytes abytes = new TorrentsAnimeBytes(); List<TorrentLink> abytesLinks = abytes.GetTorrents(parms); links.AddRange(abytesLinks); } if (src == MyAnimePlugin3.Constants.TorrentSourceNames.Nyaa) { TorrentsNyaa nyaa = new TorrentsNyaa(); List<TorrentLink> ttLinks = null; Dictionary<string, TorrentLink> dictLinks = new Dictionary<string, TorrentLink>(); foreach (string grp in episodeGroupParms) { List<string> tempParms = new List<string>(); foreach (string parmTemp in parms) tempParms.Add(parmTemp); tempParms.Insert(0, grp); ttLinks = nyaa.GetTorrents(tempParms); BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString() + "(" + grp + ")"); // only use the first 20 int x = 0; foreach (TorrentLink link in ttLinks) { if (x == 20) break; dictLinks[link.TorrentDownloadLink] = link; BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString()); } } BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString()); ttLinks = nyaa.GetTorrents(parms); foreach (TorrentLink link in ttLinks) { dictLinks[link.TorrentDownloadLink] = link; BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString()); } links.AddRange(dictLinks.Values); } if (src == MyAnimePlugin3.Constants.TorrentSourceNames.AnimeSuki) { List<TorrentLink> sukiLinks = suki.GetTorrents(parms); links.AddRange(sukiLinks); } if (src == MyAnimePlugin3.Constants.TorrentSourceNames.TT) { TorrentsTokyoToshokan tt = new TorrentsTokyoToshokan(); List<TorrentLink> ttLinks = null; Dictionary<string, TorrentLink> dictLinks = new Dictionary<string, TorrentLink>(); foreach (string grp in episodeGroupParms) { List<string> tempParms = new List<string>(); foreach (string parmTemp in parms) tempParms.Add(parmTemp); tempParms.Insert(0, grp); ttLinks = tt.GetTorrents(tempParms); BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString() + "(" + grp + ")"); // only use the first 20 int x = 0; foreach (TorrentLink link in ttLinks) { if (x == 20) break; dictLinks[link.TorrentDownloadLink] = link; BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString()); } } BaseConfig.MyAnimeLog.Write("Searching for: " + search.ToString()); ttLinks = tt.GetTorrents(parms); foreach (TorrentLink link in ttLinks) { dictLinks[link.TorrentDownloadLink] = link; BaseConfig.MyAnimeLog.Write("Adding link: " + link.ToString()); } links.AddRange(dictLinks.Values); } if (src == MyAnimePlugin3.Constants.TorrentSourceNames.BakaUpdates) { List<TorrentLink> bakauLinks = bakau.GetTorrents(parms); links.AddRange(bakauLinks); } } return links; }
private void ShowEpisodeDetails(AnimeEpisodeVM ep) { dummyEpisodeSearch.Visible = false; AnimeSeriesVM series = JMMServerHelper.GetSeries(ep.AnimeSeriesID); if (series != null && series.AniDB_Anime != null) { setGUIProperty("SubGroup.AnimeName", series.AniDB_Anime.FormattedTitle); setGUIProperty("SubGroup.EpisodeName", ep.EpisodeNumberAndName); setGUIProperty("SubGroup.FileDetails", "-"); List<GroupVideoQualityVM> videoQualityRecords = new List<GroupVideoQualityVM>(); List<JMMServerBinary.Contract_GroupVideoQuality> summ = JMMServerVM.Instance.clientBinaryHTTP.GetGroupVideoQualitySummary(series.AniDB_Anime.AnimeID); foreach (JMMServerBinary.Contract_GroupVideoQuality contract in summ) { GroupVideoQualityVM vidQual = new GroupVideoQualityVM(contract); videoQualityRecords.Add(vidQual); } // apply sorting if (videoQualityRecords.Count > 0) { List<SortPropOrFieldAndDirection> sortlist = new List<SortPropOrFieldAndDirection>(); sortlist.Add(new SortPropOrFieldAndDirection("FileCountNormal", true, SortType.eInteger)); videoQualityRecords = Sorting.MultiSort<GroupVideoQualityVM>(videoQualityRecords, sortlist); string fileDetails = ""; foreach (GroupVideoQualityVM gvq in videoQualityRecords) fileDetails += string.Format("{0}({1}/{2}/{3}bit) - {4} Files ({5})", gvq.GroupNameShort, gvq.Resolution, gvq.VideoSource, gvq.VideoBitDepth, gvq.FileCountNormal, gvq.NormalEpisodeNumberSummary) + Environment.NewLine; setGUIProperty("SubGroup.FileDetails", fileDetails); } dummyEpisodeSearch.Visible = true; } }