public WatchList() { _watchItemList = new List <WatchItem>(); //_seriesList = new List<SeriesItem>(); _sqlClient = new SQLiteClient(Config.GetFile(Config.Dir.Database, "MyTorrents.db3")); DatabaseUtility.SetPragmas(_sqlClient); if (!DatabaseUtility.TableExists(_sqlClient, "WatchList")) { SQLiteResultSet result = _sqlClient.Execute("CREATE TABLE WatchList (Search CHAR(256), Added BIGINT, Label CHAR(256) );"); } if (!DatabaseUtility.TableExists(_sqlClient, "SeriesWatchList")) { SQLiteResultSet result = _sqlClient.Execute("CREATE TABLE SeriesWatchList (SeriesName CHAR(256), OriginalSeriesName CHAR(256), SeriesID CHAR(256), Added BIGINT, Quality CHAR(256), Tracker CHAR(256), Type CHAR(256), Source CHAR(256), Folder CHAR(256), IncludeSpecials CHAR (256));"); } RSSChannelManager channelManager = RSSChannelManager.Instance(); channelManager.RSSChannelUpdated += new RSSChannelUpdated(channelManager_RSSChannelUpdated); System.Timers.Timer SearchTimer = new System.Timers.Timer(30 * 60 * 1000); SearchTimer.Elapsed += new ElapsedEventHandler(SearchTimer_Elapsed); SearchTimer.Start(); if (IsMPTVSeriesAvailable()) { MPTVSeriesWorker.DoWork += new DoWorkEventHandler(MPTVSeriesWorker_DoWork); MPTVSeriesWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(MPTVSeriesWorker_Completed); MPTVSeriesWorker.RunWorkerAsync(); } }
///RSSChannelManager channelManager = RSSChannelManager.Instance(); //GUIPropertyManager.SetProperty("#MyTorrents.Count", String.Format("{0}", channelManager.Channels.Count)); //add utorrent inbuit rss feeds //if (TorrentEngine.Instance().TorrentSession.GetType() == typeof(UTorrentClient)) //{ // GUIListItem item = new GUIListItem(); // item.Label = "UTorrent Inbuit RSS Feeds"; // item.AlbumInfoTag = RSSParser.GetUtorrentFeeds(UTorrentClient.baseresponse); // rssList.Add(item); //} public List <GUIListItem> ShowRSS() { List <GUIListItem> rsslist = new List <GUIListItem>(); rsslist.Clear(); RSSChannelManager.Instance().UpdateChannels(true); //channelManager.UpdateChannels(true); foreach (IRSSChannel channel in RSSChannelManager.Instance().Channels) { GUIListItem listItem = new GUIListItem(); listItem.Label = channel.Title + " " + channel.Description; listItem.Label2 = channel.Updated.ToShortDateString() + " " + channel.Updated.ToShortTimeString(); listItem.AlbumInfoTag = channel; rsslist.Add(listItem); } return(rsslist); }
protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (!TorrentEngine.Instance().IsConnected) { base.OnClicked(controlId, control, actionType); return; } if (controlId > 201 && controlId < 208 && controlId == 210) { GiveFocus(torrentList); } switch (control.GetID) { case 202: //button_SwitchView UnfocusMenu(); ViewTorrents.ViewButtonHandler(); GiveFocus(torrentList); UpdateScreen(); break; case 203: //button_Sort UnfocusMenu(); ViewTorrents.SortButtonHandler(); GiveFocus(torrentList); UpdateScreen(); break; case 204: //button_SearchTorrents ListType = "Search"; UnfocusMenu(); ShowSearch(); GiveFocus(torrentList); break; case 205: //button_watchItemList ListType = "WatchList"; UnfocusMenu(); ShowTorrentWatch(); GiveFocus(torrentList); break; case 206: //button_RSS ListType = "RSS"; UnfocusMenu(); UpdateScreen(); GiveFocus(torrentList); RSSChannelManager.Instance().UpdateChannels(true); break; case 207: //button_Log ListType = "Log"; ShowLog(); UnfocusMenu(); GiveFocus(torrentList); break; case 209: //button_Settings //List<UTorrentSettings> settings = TorrentEngine.Instance().TorrentSession.GetSettings(); break; case 210: //button_Labels ViewTorrents.LabelButtonHandler(); UnfocusMenu(); GiveFocus(torrentList); UpdateScreen(); break; case 208: //TorrentList if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) { switch (ListType) { case "Torrents": Torrent torrent = torrentList.SelectedListItem.AlbumInfoTag as Torrent; if (torrent != null) { ListType = "TorrentDetails"; UpdateScreen(); } break; case "Search": ViewSearch.SearchItemClicked(torrentList.SelectedListItem.AlbumInfoTag as TorrentSearch.TorrentMatch); break; case "SelectedRSS": ViewRSS.RSSDownload(torrentList.SelectedListItem.AlbumInfoTag as RSSItem); break; case "RSS": ListType = "SelectedRSS"; ViewRSS.ShowSelectedRSS(torrentList.SelectedListItem.AlbumInfoTag as IRSSChannel); UpdateScreen(); break; case "WatchList": ListType = "SeriesInfo"; UnfocusMenu(); torrentList.Visible = false; GiveFocus(button_Quality); ViewAutoGrabber.ShowSeries(torrentList.SelectedListItem.AlbumInfoTag); button_IncludeSpecials.Selected = (torrentList.SelectedListItem.AlbumInfoTag as SeriesItem).includespecials; button_IncludeSpecials.IsFocused = false; break; } } break; case 501: //FolderList if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) { if (!FolderList.SelectedListItem.Selected) { FolderList.ListItems = ViewFolders.GetGUIFolders(FolderList.SelectedListItem); FolderList.SelectedListItemIndex = 0; } else { ViewFolders.FolderClickMenu(FolderList.SelectedListItem, torrentList.SelectedListItem, ViewSearch.label); } } break; case 502: //FileList if (ListType == "TorrentDetails") { lock (UpdateLocker) { int index = FileList.SelectedListItemIndex; File selectedfile = FileList.SelectedListItem.AlbumInfoTag as File; ViewDetails.TorrentDetailsOnClick(selectedfile, index); } } break; case 302: case 303: case 304: case 305: case 306: case 307: ViewAutoGrabber.OnClicked(control); break; } base.OnClicked(controlId, control, actionType); }
public void ContextMenu(object info) { WatchItem watch = info as WatchItem; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading("Torrent watchlist"); dlg.Add("Add Series"); dlg.Add("Search Series"); dlg.Add("Add Movie"); dlg.Add("Add custom"); dlg.Add("Manual Search"); dlg.Add("Remove selected"); dlg.Add("Clear list"); dlg.Add("Force RSS update"); dlg.DoModal(GUIWindowManager.ActiveWindow); switch (dlg.SelectedLabelText) { case "Add Series": { AddSeries(); MyTorrents.Instance().ShowTorrentWatch(); break; } case "Search Series": { SearchSeries(); } break; case "Add Movie": break; case "Manual Search": MyTorrents.Instance()._torrentWatchlist.SearchTorrent(); break; case "Add custom": { VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (!keyboard.IsConfirmed) { return; } watch = new WatchItem(); watch.SearchTerm = keyboard.Text; TorrentLabel label = DialogAskLabel.Ask(); if (label != null) { watch.Label = label.Name; MyTorrents.Instance()._torrentWatchlist.AddWatch(watch); Log.Instance().Print(String.Format("Watch [{0}] added.", watch.SearchTerm)); } break; } case "Clear list": { MyTorrents.Instance()._torrentWatchlist.Clear(); break; } case "Remove selected": { MyTorrents.Instance()._torrentWatchlist.RemoveWatch(watch); // torrentList.RemoveItem(torrentList.SelectedListItemIndex); break; } case "Force RSS update": { RSSChannelManager.Instance().UpdateChannels(true); break; } } MyTorrents.Instance().ShowTorrentWatch(); }
public bool LoadRssChannels(ConfigData _config) { XmlDocument xmlDoc = _config.MyTorrentsConfiguration; RSSChannelManager channelManager = RSSChannelManager.Instance(); XmlNodeList nodes = xmlDoc.SelectSingleNode("config/feed").ChildNodes; foreach (XmlNode node in nodes) { IRSSChannel rssChannel = null; string type = ""; if (node.Name == "rss") { type = "rss"; } if (node.Name == "atom") { type = "atom"; } XmlNodeList nUrls = node.SelectNodes("url"); if (nUrls.Count >= 2) { //combined! XmlNode nTitle = node.SelectSingleNode("title"); XmlNode nDesc = node.SelectSingleNode("description"); if (nTitle == null || nDesc == null) { continue; } RSSCombined combined = new RSSCombined(nTitle.InnerText, nDesc.InnerText); foreach (XmlNode nUrl in node.SelectNodes("url")) { RSSChannel channel = new RSSChannel(nUrl.InnerText); combined.Channels.Add(channel); } rssChannel = combined; } else { if (node.SelectSingleNode("transform") != null) { XmlNode nurl = node.SelectSingleNode("url"); XmlNode trans = node.SelectSingleNode("transform/origin"); XmlNode basedownload = node.SelectSingleNode("transform/basedownload"); rssChannel = new RSSChannel(nurl.InnerText, new Regex(trans.InnerText, RegexOptions.IgnoreCase), basedownload.InnerText); } else { XmlNode nUrl = node.SelectSingleNode("url"); rssChannel = new RSSChannel(nUrl.InnerText); } } XmlNode expireTime = node.SelectSingleNode("expires"); if (expireTime == null) { //5minutes rssChannel.ExpireTime = new TimeSpan(0, 5, 0); } else { rssChannel.ExpireTime = new TimeSpan(0, 0, Convert.ToInt32(expireTime.InnerText)); } rssChannel.Type = type; channelManager.Channels.Add(rssChannel); } Log.Instance().Print("Started RssChanel"); return(true); }
public IRSSChannel RSSContextMenu(IRSSChannel channel) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return(null); } dlg.Reset(); dlg.SetHeading("RSS Feeds"); dlg.Add("Search"); dlg.Add("Update selected"); dlg.Add("Update all"); dlg.DoModal(GUIWindowManager.ActiveWindow); switch (dlg.SelectedLabelText) { case "Update selected": { if (channel == null) { return(null); } if (channel != null) { channel.Update(); } return(null); } case "Update all": { RSSChannelManager.Instance().UpdateChannels(true); return(null); } case "Search": { VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (!keyboard.IsConfirmed) { return(null); } Regex re = new Regex(keyboard.Text, RegexOptions.IgnoreCase); RSSChannel search = new RSSChannel("MediaPortal"); if (channel != null && channel.Url != "MediaPortal") { foreach (RSSItem item in channel.Items) { if (re.IsMatch(item.Title)) { search.Items.Add(item); } } } //this.ShowSelectedRSS() = search; //UpdateListItems(); return(search); } } return(null); }