/// <summary> /// Checks the availability of the link on the service. /// </summary> /// <param name="url">The link to check.</param> /// <returns> /// <c>true</c> if the link is available; otherwise, <c>false</c>. /// </returns> public override bool Check(string url) { var loc = string.Empty; Utils.GetURL(url, request: r => { r.Method = "HEAD"; r.AllowAutoRedirect = false; }, response: r => { loc = r.Headers[HttpResponseHeader.Location]; }); if (string.IsNullOrWhiteSpace(loc) || !CanCheck(loc)) { return(false); } var checker = Extensibility.GetNewInstances <LinkCheckerEngine>().FirstOrDefault(x => x.CanCheck(loc)); if (checker == null) { throw new NotSupportedException(); } return(checker.Check(loc)); }
/// <summary> /// Reloads the parsers list view. /// </summary> private void ReloadParsers() { var idx = listView.SelectedIndex; listView.Items.GroupDescriptions.Clear(); FeedsListViewItemCollection.Clear(); foreach (var engine in Extensibility.GetNewInstances <FeedReaderEngine>().OrderBy(x => x.Language).ThenBy(x => x.Name)) { FeedsListViewItemCollection.Add(new FeedsListViewItem { Enabled = GuidesPage.Actives.Contains(engine.Name), Icon = "/RSTVShowTracker;component/Images/navigation.png", Site = engine.Name, Language = Languages.List[engine.Language], LangIcon = "pack://application:,,,/RSTVShowTracker;component/Images/flag-" + engine.Language + ".png" }); } listView.SelectedIndex = idx; listView.Items.GroupDescriptions.Add(new PropertyGroupDescription("Language")); }
/// <summary> /// Reloads the plugins list view. /// </summary> /// <param name="inclInternal">if set to <c>true</c> internal classes will be included too.</param> private void ReloadPlugins(bool inclInternal = false) { PluginsListViewItemCollection.Clear(); var types = new[] { #pragma warning disable 618 typeof(Parsers.Guides.Guide), typeof(Parsers.Downloads.DownloadSearchEngine), typeof(Parsers.Subtitles.SubtitleSearchEngine), typeof(Parsers.LinkCheckers.LinkCheckerEngine), typeof(Parsers.OnlineVideos.OnlineVideoSearchEngine), typeof(Parsers.Recommendations.RecommendationEngine), typeof(Parsers.Social.SocialEngine), typeof(Parsers.WebSearch.WebSearchEngine), typeof(Parsers.ForeignTitles.ForeignTitleEngine), typeof(Parsers.Senders.SenderEngine), typeof(Parsers.News.FeedReaderEngine), typeof(ContextMenus.Menus.OverviewContextMenu), typeof(ContextMenus.Menus.UpcomingListingContextMenu), typeof(ContextMenus.Menus.EpisodeListingContextMenu), typeof(ContextMenus.Menus.DownloadLinkContextMenu), typeof(ContextMenus.Menus.SubtitleContextMenu), typeof(ContextMenus.Menus.StatisticsContextMenu), typeof(ContextMenus.Menus.RecommendationContextMenu), typeof(LocalProgrammingPlugin), typeof(Scripting.ScriptingPlugin), typeof(StartupPlugin), typeof(IPlugin) #pragma warning restore 618 }; var icons = new[] { "/RSTVShowTracker;component/Images/guides.png", "/RSTVShowTracker;component/Images/torrents.png", "/RSTVShowTracker;component/Images/subtitles.png", "/RSTVShowTracker;component/Images/tick.png", "/RSTVShowTracker;component/Images/monitor.png", "/RSTVShowTracker;component/Images/information.png", "/RSTVShowTracker;component/Images/bird.png", "/RSTVShowTracker;component/Images/magnifier.png", "/RSTVShowTracker;component/Images/language.png", "/RSTVShowTracker;component/Images/server-cast.png", "/RSTVShowTracker;component/Images/feed.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/menu.png", "/RSTVShowTracker;component/Images/table-select-row.png", "/RSTVShowTracker;component/Images/code.png", "/RSTVShowTracker;component/Images/document-insert.png", "/RSTVShowTracker;component/Images/dll.gif" }; foreach (var engine in Extensibility.GetNewInstances <IPlugin>(inclInternal: inclInternal).OrderBy(engine => engine.Name)) { var type = engine.GetType(); var parent = string.Empty; var picon = string.Empty; var i = 0; foreach (var ptype in types) { if (type.IsSubclassOf(ptype)) { parent = ptype.Name; picon = icons[i]; break; } i++; } var file = type.Assembly.ManifestModule.Name; if (file == "<In Memory Module>") { var script = Extensibility.Scripts.FirstOrDefault(s => s.Type == type); if (script != null) { file = Path.GetFileName(script.File); } } PluginsListViewItemCollection.Add(new PluginsListViewItem { Icon = engine.Icon, Name = engine.Name, Type = parent, Icon2 = picon, Version = engine.Version.ToString().PadRight(14, '0'), File = file }); } }
/// <summary> /// Reloads the list. /// </summary> public void ReloadList() { DestinationsListViewItemCollection.Clear(); // load torrent var atr = Utils.GetApplicationForExtension(".torrent"); Tuple <string, BitmapSource> tri; if (!string.IsNullOrWhiteSpace(atr) && (tri = Utils.GetExecutableInfo(atr)) != null) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { Icon = tri.Item2, Name = DownloadLinksPage.CleanExeName(tri.Item1) + " for .torrent", Type = "Default local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application-blue.png" }); } // load usenet var anz = Utils.GetApplicationForExtension(".nzb"); Tuple <string, BitmapSource> nzi; if (!string.IsNullOrWhiteSpace(anz) && (nzi = Utils.GetExecutableInfo(anz)) != null) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { Icon = nzi.Item2, Name = DownloadLinksPage.CleanExeName(nzi.Item1) + " for .nzb", Type = "Default local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application-blue.png" }); } // load dlc var adl = Utils.GetApplicationForExtension(".dlc"); Tuple <string, BitmapSource> dli; if (!string.IsNullOrWhiteSpace(adl) && (dli = Utils.GetExecutableInfo(adl)) != null) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { Icon = dli.Item2, Name = DownloadLinksPage.CleanExeName(dli.Item1) + " for .dlc", Type = "Default local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application-blue.png" }); } // load html var aht = Utils.GetApplicationForExtension(".html"); Tuple <string, BitmapSource> hti; if (!string.IsNullOrWhiteSpace(aht) && (hti = Utils.GetExecutableInfo(aht)) != null) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { Icon = hti.Item2, Name = DownloadLinksPage.CleanExeName(hti.Item1) + " for .html", Type = "Default local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application-blue.png" }); } // load alternatives foreach (var alt in Settings.Get <Dictionary <string, object> >("Alternative Associations")) { var lst = (List <string>)alt.Value; if (lst == null || lst.Count == 0) { continue; } foreach (var app in lst) { Tuple <string, BitmapSource> sci; if ((sci = Utils.GetExecutableInfo(app)) != null) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { ID = alt.Key + "|" + app, Icon = sci.Item2, Name = DownloadLinksPage.CleanExeName(sci.Item1) + " for " + alt.Key, Type = "Alternative local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application.png" }); } else { DestinationsListViewItemCollection.Add(new DestinationListViewItem { ID = alt.Key + "|" + app, Icon = "pack://application:,,,/RSTVShowTracker;component/Images/exclamation.png", Name = Path.GetFileName(app) + " for " + alt.Key + " [File not found!]", Type = "Alternative local associations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/application.png" }); } } } // load senders var senders = Extensibility.GetNewInstances <SenderEngine>().ToList(); foreach (var dest in Settings.Get <Dictionary <string, object> >("Sender Destinations")) { var conf = (Dictionary <string, object>)dest.Value; Uri uri; DestinationsListViewItemCollection.Add(new DestinationListViewItem { ID = dest.Key, Icon = senders.First(s => s.Name == (string)conf["Sender"]).Icon, Name = (string)conf["Sender"] + " at " + (Uri.TryCreate((string)conf["Location"], UriKind.Absolute, out uri) ? uri.DnsSafeHost + ":" + uri.Port : (string)conf["Location"]), Type = "Remote servers", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/server-cast.png" }); } // load folders foreach (var alt in Settings.Get <Dictionary <string, object> >("Folder Destinations")) { var lst = (List <string>)alt.Value; if (lst == null || lst.Count == 0) { continue; } foreach (var app in lst) { if (Directory.Exists(app)) { DestinationsListViewItemCollection.Add(new DestinationListViewItem { ID = alt.Key + "|" + app, Icon = "pack://application:,,,/RSTVShowTracker;component/Images/folder-open-document.png", Name = Path.GetFileName(app) + " for " + alt.Key, Type = "Folder destinations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/folder.png" }); } else { DestinationsListViewItemCollection.Add(new DestinationListViewItem { ID = alt.Key + "|" + app, Icon = "pack://application:,,,/RSTVShowTracker;component/Images/exclamation.png", Name = Path.GetFileName(app) + " for " + alt.Key + " [Folder not found!]", Type = "Folder destinations", GroupIcon = "pack://application:,,,/RSTVShowTracker;component/Images/folder.png" }); } } } DestinationsListViewSelectionChanged(); }