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); }
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 ShowSearchResults(DownloadSearchCriteria dsc, List<TorrentLink> results) { if (!dummyPageSearch.Visible) return; m_Facade.Clear(); if (dsc.SearchType == DownloadSearchType.Episode) { AnimeEpisodeVM ep = dsc.SearchParameter as AnimeEpisodeVM; ShowEpisodeDetails(ep); } else dummyEpisodeSearch.Visible = false; setGUIProperty("Search.Summary", string.Format("{0}", dsc.ToString())); foreach (TorrentLink link in results) { GUIListItem item = null; item = new GUIListItem(); string tname = link.TorrentName; if (tname.Length > 50) tname = tname.Substring(0, 50) + "..."; item.Label = string.Format("({0}) {1} ({2})", link.Source, tname, link.Size); item.TVTag = link; m_Facade.Add(item); BaseConfig.MyAnimeLog.Write("TORRENT: " + item.Label); } setGUIProperty("Search.ResultDescription", string.Format("{0} Results", results.Count)); }