From: <fc...@us...> - 2007-09-26 22:16:18
|
Revision: 957 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=957&view=rev Author: fcsobel Date: 2007-09-26 15:16:15 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyTorrents/AzureusWrapper/AzureusWrapper.csproj trunk/plugins/MyTorrents/My PodCasts/GUIPodCasts/GUIPodCasts.cs trunk/plugins/MyTorrents/My Torrents/GUITorrents/GUITorrents.cs trunk/plugins/MyTorrents/My uTorrent/GUIuTorrent/GUIuTorrent.cs trunk/plugins/MyTorrents/My uTorrent/Skin/media/downloading.png trunk/plugins/MyTorrents/My uTorrent/Skin/media/inactive.PNG trunk/plugins/MyTorrents/My uTorrent/Skin/media/seeding.png trunk/plugins/MyTorrents/c3o.Plugins/Shared/GUIRssBaseWindow.cs trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.Designer.cs trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.cs trunk/plugins/MyTorrents/c3o.Plugins/Web/Opml.cs trunk/plugins/MyTorrents/c3o.Plugins/Web/RSSReader.cs trunk/plugins/MyTorrents/c3o.Plugins/Web/SiteReader.cs trunk/plugins/MyTorrents/c3o.Plugins/Web/WebHelper.cs trunk/plugins/MyTorrents/c3o.Plugins/Web/uTorrentData.cs Modified: trunk/plugins/MyTorrents/AzureusWrapper/AzureusWrapper.csproj =================================================================== --- trunk/plugins/MyTorrents/AzureusWrapper/AzureusWrapper.csproj 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/AzureusWrapper/AzureusWrapper.csproj 2007-09-26 22:16:15 UTC (rev 957) @@ -9,6 +9,10 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AzureusWrapper</RootNamespace> <AssemblyName>AzureusWrapper</AssemblyName> + <SccProjectName>SAK</SccProjectName> + <SccLocalPath>SAK</SccLocalPath> + <SccAuxPath>SAK</SccAuxPath> + <SccProvider>SAK</SccProvider> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> Modified: trunk/plugins/MyTorrents/My PodCasts/GUIPodCasts/GUIPodCasts.cs =================================================================== --- trunk/plugins/MyTorrents/My PodCasts/GUIPodCasts/GUIPodCasts.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/My PodCasts/GUIPodCasts/GUIPodCasts.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -6,6 +6,7 @@ using MediaPortal.Util; using MediaPortal.Dialogs; using MediaPortal.Player; +using MediaPortal.Configuration; using System.Data; using System.ComponentModel; using c3o.Framework.Web; @@ -19,6 +20,8 @@ { public class GUIPodCasts : GUIRssBaseWindow, ISetupForm { + public static bool useVMR9 = true; + public override int GetID { get @@ -62,7 +65,12 @@ GUIPropertyManager.SetProperty("#header.label", "My PodCasts"); - base.OnPageLoad(); + base.OnPageLoad(); + + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + useVMR9 = xmlreader.GetValueAsBool("general", "usevrm9forwebstreams", true); + } } @@ -227,53 +235,267 @@ if (url != null && url.Length > 0) { - if (url.ToLower().Contains(".avi") || - url.ToLower().Contains(".mpeg") || - url.ToLower().Contains(".mov") || - url.ToLower().Contains(".wmv") || - url.ToLower().Contains(".divx") || - url.ToLower().Contains(".mpg")) - { - //g_Player.FullScreen = true; - //if (g_Player.Play(url)) - //{ - // GUIGraphicsContext.IsFullScreenVideo = true; - // GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); - //} + //this.PlayVideo(url); + this.PlayIt(url, this.facadeView.SelectedListItem.Label); - if (g_Player.Play(url)) - { - GUIGraphicsContext.IsFullScreenVideo = true; - GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); - g_Player.FullScreen = true; - } - } - else - { - g_Player.PlayAudioStream(url); + //// PlayUrl(url, this.facadeView.SelectedListItem.Label); + // if (url.Contains(".mp3") || + // url.Contains(".wav") || + // url.Contains(".wma") || + // url.Contains(".aac")) + // { + // if (g_Player.PlayAudioStream(url)) + // { + // //g_Player.FullScreen = false; + // } + // else + // { + // Log.Info("GUIPodCasts: Unable to play {0}", url); + // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // dlg.SetHeading("ERROR"); + // dlg.SetText("Unable to play the selected stream. Please try again later."); + // dlg.DoModal(GUIWindowManager.ActiveWindow); + // } + // } + // else + // { + // if (g_Player.Play(url)) + // { + // GUIGraphicsContext.IsFullScreenVideo = true; + // GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); + // g_Player.FullScreen = true; - //if (url.ToLower().Contains(".mp3")) - //{ - // //this.PlayPodCast(url); - // g_Player.Play(url); - // //g_Player.PlayAudioStream(url); - //} - //else - //{ - // if (url.ToLower().Contains(".m4v") || - // url.ToLower().Contains(".mp4")) - // { - // System.Diagnostics.Process.Start(@"QuickTimePlayer.exe", url); - // } - // else - // { - // System.Diagnostics.Process.Start(url); - // } - //} - } + // //g_Player.ShowFullScreenWindow(); + // //g_Player.FullScreen = true; + // } + // else + // { + // Log.Info("GUIPodCasts: Unable to play {0}", url); + // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // dlg.SetHeading("ERROR"); + // dlg.SetText("Unable to play the selected stream. Please try again later."); + // dlg.DoModal(GUIWindowManager.ActiveWindow); + // } + // } + } } } } + +// void PlayItOld(string url) +// { +// if (url.ToLower().StartsWith("mms:")) +// { +// if (g_Player.PlayVideoStream(url)) +// { +//// g_Player.ShowFullScreenWindow(); +// GUIGraphicsContext.IsFullScreenVideo = true; +// GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); +// g_Player.FullScreen = true; +// } +// else +// { +// Log.Info("GUIPodCasts: Unable to play {0}", url); +// GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); +// dlg.SetHeading("ERROR"); +// dlg.SetText("Unable to play the video stream. Please try again later."); +// dlg.DoModal(GUIWindowManager.ActiveWindow); +// } +// } + +// if (g_Player.Play(url)) +// { +// url = url.ToLower(); + +// if (url.Contains(".mp3") || +// url.Contains(".wav") || +// url.Contains(".wma") || +// url.Contains(".aac")) +// { +// // Playing audio only +// } +// else +// { +// // Play video full screen +// GUIGraphicsContext.IsFullScreenVideo = true; +// GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); +// g_Player.FullScreen = true; + +// //g_Player.ShowFullScreenWindow(); +// //g_Player.FullScreen = true; +// } +// } +// else +// { +// Log.Info("GUIPodCasts: Unable to play {0}", url); +// GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); +// dlg.SetHeading("ERROR"); +// dlg.SetText("Unable to play the stream. Please try again later."); +// dlg.DoModal(GUIWindowManager.ActiveWindow); +// } +// } + + + void PlayIt(string url, string name) + { + if (url.ToLower().StartsWith("mms:")) + { + if (g_Player.PlayVideoStream(url, name)) + { + g_Player.ShowFullScreenWindow(); + g_Player.FullScreen = true; + } + else + { + Log.Info("GUIPodCasts: Unable to play {0}", url); + GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + dlg.SetHeading("ERROR"); + dlg.SetText("Unable to play the video stream."); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + } + + if (url.Contains(".mp3") || + url.Contains(".wav") || + url.Contains(".wma") || + url.Contains(".aac")) + { + if (!g_Player.PlayAudioStream(url)) + { + Log.Info("GUIPodCasts: Unable to play {0}", url); + GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + dlg.SetHeading("ERROR"); + dlg.SetText("Unable to play the audio stream."); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + } + else + { + if (g_Player.Play(url)) + { + // Play video full screen + g_Player.ShowFullScreenWindow(); + g_Player.FullScreen = true; + } + else + { + Log.Info("GUIPodCasts: Unable to play {0}", url); + GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + dlg.SetHeading("ERROR"); + dlg.SetText("Unable to play the video."); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + + } + } + + //void PlayVideoOld(string url) + //{ + // if (url.ToLower().Contains(".avi") || + // url.ToLower().Contains(".mpeg") || + // url.ToLower().Contains(".mov") || + // url.ToLower().Contains(".wmv") || + // url.ToLower().Contains(".divx") || + // url.ToLower().Contains(".mpg")) + // { + // if (g_Player.Play(url)) + // { + // //GUIGraphicsContext.IsFullScreenVideo = true; + // //GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); + // //g_Player.FullScreen = true; + + // g_Player.ShowFullScreenWindow(); + // g_Player.FullScreen = true; + // } + // else + // { + // Log.Info("GUIPodCasts: Unable to play {0}", url); + // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // dlg.SetHeading("ERROR"); + // dlg.SetText("Unable to play the selected stream. Please try again later."); + // dlg.DoModal(GUIWindowManager.ActiveWindow); + // } + // } + // else + // { + // if (g_Player.PlayAudioStream(url)) + // { + // g_Player.FullScreen = false; + // } + // else + // { + // Log.Info("GUIPodCasts: Unable to play {0}", url); + // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // dlg.SetHeading("ERROR"); + // dlg.SetText("Unable to play the selected stream. Please try again later."); + // dlg.DoModal(GUIWindowManager.ActiveWindow); + // } + // } + //} + + + //void playVideo(string url) + //{ + // if (useVMR9) + // { + // g_Player.PlayVideoStream(url, "test"); + // g_Player.ShowFullScreenWindow(); + // } + // else + // { + // g_Player.PlayAudioStream(url); + // } + + // //if (g_Player.Playing) + // //{ + // // g_Player.ShowFullScreenWindow(); + // //} + // //else + // //{ + // // Log.Info("GUIPodCasts: Unable to play {0}", url); + // // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // // dlg.SetHeading("ERROR"); + // // dlg.SetText("useVMR9 Unable to play this stream. Please try again later."); + // // dlg.DoModal(GUIWindowManager.ActiveWindow); + // //} + //} + + //public void PlayUrl(string url, string videoName) + //{ + // //GetGUIProperties(); + // //MMSUrl = string.Empty; + // //GetMMSURL(url); + // //Log.Debug("Url: {0}, mmsurl: {1}, videoname: {2}", url, MMSUrl, videoName); + + // bool playOk = false; + + // if (useVMR9) + // { + // playOk = g_Player.PlayVideoStream(url, videoName); + // } + // else + // { + // playOk = g_Player.PlayAudioStream(url); + // //playOk = g_Player.PlayAudioStream(url, true); + // } + + // if (playOk) + // { + // g_Player.ShowFullScreenWindow(); + // g_Player.FullScreen = true; + // } + // else + // { + // Log.Info("GUIPodCasts: Unable to play {0}", url); + // GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + // dlg.SetHeading("ERROR"); + // dlg.SetText("Unable to play the selected stream. Please try again later."); + // dlg.DoModal(GUIWindowManager.ActiveWindow); + // } + //} + + + } } \ No newline at end of file Modified: trunk/plugins/MyTorrents/My Torrents/GUITorrents/GUITorrents.cs =================================================================== --- trunk/plugins/MyTorrents/My Torrents/GUITorrents/GUITorrents.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/My Torrents/GUITorrents/GUITorrents.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -14,6 +14,7 @@ using System.Xml.Serialization; using System.IO; using AzureusWrapper; +using System.Text.RegularExpressions; namespace MediaPortal.GUI.Rss @@ -551,14 +552,23 @@ } + //protected void GetTorrent(string url, string pattern, string replace) + //{ + // Regex reg = new Regex(pattern); + // url = reg.Replace(JsonData, replace); + //} + protected void GetTorrent(string url) { if (url != null && url.Length > 0) { // Added for mininova rss - url = url.Replace(@"/tor/", @"/get/"); + //url = url.Replace(@"/tor/", @"/get/"); + //Regex reg = new Regex(@".*www\.torrentspy\.com/torrent/(.*)/.*"); + //url = reg.Replace(JsonData, @"http://cache.torrentspy.com/download.asp?id=\1"); + if (this.CurrentSite == "UKNova") { dtUKNova.DownloadTorrent(url); @@ -571,7 +581,8 @@ } else { - dtUKNova.DownloadTorrent(url); + this.dtRss.DownloadTorrent(url); + //dtUKNova.DownloadTorrent(url); } } } Modified: trunk/plugins/MyTorrents/My uTorrent/GUIuTorrent/GUIuTorrent.cs =================================================================== --- trunk/plugins/MyTorrents/My uTorrent/GUIuTorrent/GUIuTorrent.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/My uTorrent/GUIuTorrent/GUIuTorrent.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -184,7 +184,9 @@ string lSize = uTrow["Size"].ToString(); string lUpSpeed = uTrow["UpSpeed"].ToString(); string lDownSpeed = uTrow["DownSpeed"].ToString(); + string ETA = uTrow["ETA"].ToString(); + if (ETA.Length > 0) ETA = SecondsToDaysHoursMinutes(int.Parse(ETA)); if (lRatio.Length > 0) lRatio = String.Format("{0:N2}", Double.Parse(lRatio) / 1000); // 24 = 0.024 if (lSize.Length > 0) lSize = GUIHelper.FormatSize(ulong.Parse(lSize), 1); if (lUpSpeed.Length > 0) lUpSpeed = GUIHelper.FormatSize(ulong.Parse(lUpSpeed), 1); @@ -193,20 +195,20 @@ string DownLoadPercent = String.Format("{0:P2}", Double.Parse(lPercentage) / 1000); string UploadPercent = "0%"; - string IconImage = "Inactive.PNG"; + string IconImage = "utInactive.png"; switch (status) { case "136": - IconImage = "Inactive.PNG"; + IconImage = "utInactive.png"; status = "Stopped"; break; case "233": - IconImage = "Inactive.PNG"; + IconImage = "utInactive.png"; status = "Paused"; break; case "137": - IconImage = "seeding.PNG"; + IconImage = "utSeeding.png"; status = "Seeding(F)"; break; case "200": @@ -214,17 +216,17 @@ if (lPercentage == "1000") { status = "Seeding"; - IconImage = "seeding.PNG"; + IconImage = "utSeeding.png"; } else { status = "Downloading"; - IconImage = "Downloading.PNG"; + IconImage = "utDownloading.png"; } break; } - string DVDLabel = lFileName + "\n" + status + "\nSize: " + lSize + "\nRatio: " + lRatio + "\nSeeds: " + lSeeds + " (" + lSeeds2 + ")\nPeers: " + lPeers + " (" + lPeers2 + ")" + "\nDown Speed: " + lDownSpeed + "\nUp Speed: " + lUpSpeed; + string DVDLabel = lFileName + "\n" + status + "\nSize: " + lSize + "\nRatio: " + lRatio + "\nSeeds: " + lSeeds + " (" + lSeeds2 + ")\nPeers: " + lPeers + " (" + lPeers2 + ")" + "\nDown Speed: " + lDownSpeed + "\nUp Speed: " + lUpSpeed + "\nETA: " + ETA; dt.Rows.Add(lFileName, lKey, status + " (" + DownLoadPercent + ")", DVDLabel, IconImage); @@ -249,8 +251,22 @@ + public string SecondsToDaysHoursMinutes(int time) + { + int days = time / 86400; + int hours = (time / 3600) - (days * 24); + int minutes = (time / 60) - (days * 1440) - (hours * 60); + int seconds = time % 60; // Modulous + if (days > 0) return String.Format("{3}d {2}h {1}m {0}s", seconds, minutes, hours, days); + if (hours > 0) return String.Format("{2}h {1}m {0}s", seconds, minutes, hours); + if (minutes > 0) return String.Format("{1}m {0}s", seconds, minutes); + if (seconds > 0) return String.Format("{0}s", seconds); + return ""; + } + + public override bool Init() { //this.RssFileName = "MyPodCasts.Feeds.opml.xml"; @@ -440,7 +456,7 @@ uTorrentData.StartDownload(WebUiUrl, WebUiLogin, WebUiPassword, dl); break; case "Stop": - if (item.IconImage == "Inactive.PNG") + if (item.IconImage == "utInactive.png") { this.uTorentAction("Remove"); } Modified: trunk/plugins/MyTorrents/My uTorrent/Skin/media/downloading.png =================================================================== (Binary files differ) Modified: trunk/plugins/MyTorrents/My uTorrent/Skin/media/inactive.PNG =================================================================== (Binary files differ) Modified: trunk/plugins/MyTorrents/My uTorrent/Skin/media/seeding.png =================================================================== (Binary files differ) Modified: trunk/plugins/MyTorrents/c3o.Plugins/Shared/GUIRssBaseWindow.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Shared/GUIRssBaseWindow.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Shared/GUIRssBaseWindow.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -13,8 +13,8 @@ using System.Xml; using System.Xml.Serialization; using System.IO; +using System.Text.RegularExpressions; - namespace MediaPortal.GUI.Rss { public class GUIRssBaseWindow : GUIVideoBaseWindow @@ -330,27 +330,47 @@ this.SelectOutline(this.opmlFeeds, null, this.DefaultView); } } - + + protected void SearchOpml(string url) { this.ListMode = "Sites.Opml.List"; string Source = null; - // Cache The Page - MediaPortal.Utils.Web.HTMLCache.WebCacheInitialise(); + //// SVN version + //// Cache The Page + MediaPortal.Utils.Web.HTMLCache hc = new MediaPortal.Utils.Web.HTMLCache(); - if (MediaPortal.Utils.Web.HTMLCache.LoadPage(new Uri(url))) - { - Source = MediaPortal.Utils.Web.HTMLCache.GetPage(); - } - else - { - SiteReader sr = new SiteReader(); - Source = sr.ReadPage(url); - MediaPortal.Utils.Web.HTMLCache.SavePage(new Uri(url), Source); - } + hc.WebCacheInitialise(); + if (hc.LoadPage(new MediaPortal.Utils.Web.HTTPRequest(url))) + { + Source = hc.GetPage(); + } + else + { + SiteReader sr = new SiteReader(); + Source = sr.ReadPage(url); + hc.SavePage(new MediaPortal.Utils.Web.HTTPRequest(url), Source); + } + + //// 0.2.2 version + //MediaPortal.Utils.Web.HTMLCache hc = new MediaPortal.Utils.Web.HTMLCache(); + + //MediaPortal.Utils.Web.HTMLCache.WebCacheInitialise(); + + //if (MediaPortal.Utils.Web.HTMLCache.LoadPage(new Uri(url))) + //{ + // Source = MediaPortal.Utils.Web.HTMLCache.GetPage(); + //} + //else + //{ + // SiteReader sr = new SiteReader(); + // Source = sr.ReadPage(url); + // MediaPortal.Utils.Web.HTMLCache.SavePage(new Uri(url), Source); + //} + // Read rss feed into XmlDocument XmlDocument xml = new XmlDocument(); xml.LoadXml(Source); @@ -605,6 +625,8 @@ string SiteName = this.selectedOutline.text; string SiteUrl = this.selectedOutline.url; + string pattern = this.selectedOutline.search; + string replacement = this.selectedOutline.replace; GUIPropertyManager.SetProperty("#selecteditem", "Loading " + SiteUrl + "..."); GUIWindowManager.Process(); @@ -626,7 +648,7 @@ GUIPropertyManager.SetProperty("#selecteditem", "Loading " + SiteUrl); // Read rss feed - dtRss = new RssReader(SiteUrl); + dtRss = new RssReader(SiteUrl, pattern, replacement); DataTable dt = dtRss.Detail; Modified: trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.Designer.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.Designer.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.Designer.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -28,216 +28,256 @@ /// </summary> private void InitializeComponent() { - this.bttnOK = new System.Windows.Forms.Button(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.gbDetail = new System.Windows.Forms.GroupBox(); - this.bttnAddDetail = new System.Windows.Forms.Button(); - this.bttnDelete = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.tbxItemName = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.tbxItemUrl = new System.Windows.Forms.TextBox(); - this.tbxItemImage = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.bttnAdd = new System.Windows.Forms.Button(); - this.label6 = new System.Windows.Forms.Label(); - this.bttnBrowseRss = new System.Windows.Forms.Button(); - this.tbxUrl = new System.Windows.Forms.TextBox(); - this.tvList = new System.Windows.Forms.TreeView(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.bttnCancel = new System.Windows.Forms.Button(); - this.gbDetail.SuspendLayout(); - this.SuspendLayout(); - // - // bttnOK - // - this.bttnOK.Location = new System.Drawing.Point(15, 462); - this.bttnOK.Name = "bttnOK"; - this.bttnOK.Size = new System.Drawing.Size(75, 23); - this.bttnOK.TabIndex = 5; - this.bttnOK.Text = "OK"; - this.bttnOK.UseVisualStyleBackColor = true; - this.bttnOK.Click += new System.EventHandler(this.button1_Click); - // - // gbDetail - // - this.gbDetail.Controls.Add(this.bttnAddDetail); - this.gbDetail.Controls.Add(this.bttnDelete); - this.gbDetail.Controls.Add(this.button1); - this.gbDetail.Controls.Add(this.tbxItemName); - this.gbDetail.Controls.Add(this.label9); - this.gbDetail.Controls.Add(this.tbxItemUrl); - this.gbDetail.Controls.Add(this.tbxItemImage); - this.gbDetail.Controls.Add(this.label8); - this.gbDetail.Controls.Add(this.label7); - this.gbDetail.Location = new System.Drawing.Point(326, 45); - this.gbDetail.Name = "gbDetail"; - this.gbDetail.Size = new System.Drawing.Size(260, 404); - this.gbDetail.TabIndex = 21; - this.gbDetail.TabStop = false; - this.gbDetail.Text = "Details"; - // - // bttnAddDetail - // - this.bttnAddDetail.Location = new System.Drawing.Point(86, 111); - this.bttnAddDetail.Name = "bttnAddDetail"; - this.bttnAddDetail.Size = new System.Drawing.Size(75, 23); - this.bttnAddDetail.TabIndex = 22; - this.bttnAddDetail.Text = "Add"; - this.bttnAddDetail.UseVisualStyleBackColor = true; - this.bttnAddDetail.Click += new System.EventHandler(this.bttnAddDetail_Click); - // - // bttnDelete - // - this.bttnDelete.Location = new System.Drawing.Point(162, 111); - this.bttnDelete.Name = "bttnDelete"; - this.bttnDelete.Size = new System.Drawing.Size(75, 23); - this.bttnDelete.TabIndex = 21; - this.bttnDelete.Text = "Delete"; - this.bttnDelete.UseVisualStyleBackColor = true; - this.bttnDelete.Click += new System.EventHandler(this.bttnDelete_Click); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(8, 111); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 20; - this.button1.Text = "Update"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click_2); - // - // tbxItemName - // - this.tbxItemName.Location = new System.Drawing.Point(56, 30); - this.tbxItemName.Name = "tbxItemName"; - this.tbxItemName.Size = new System.Drawing.Size(176, 20); - this.tbxItemName.TabIndex = 14; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(12, 85); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(39, 13); - this.label9.TabIndex = 19; - this.label9.Text = "Image:"; - // - // tbxItemUrl - // - this.tbxItemUrl.Location = new System.Drawing.Point(56, 56); - this.tbxItemUrl.Name = "tbxItemUrl"; - this.tbxItemUrl.Size = new System.Drawing.Size(176, 20); - this.tbxItemUrl.TabIndex = 15; - // - // tbxItemImage - // - this.tbxItemImage.Location = new System.Drawing.Point(56, 82); - this.tbxItemImage.Name = "tbxItemImage"; - this.tbxItemImage.Size = new System.Drawing.Size(176, 20); - this.tbxItemImage.TabIndex = 16; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(23, 63); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(23, 13); - this.label8.TabIndex = 18; - this.label8.Text = "Url:"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(12, 33); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(38, 13); - this.label7.TabIndex = 17; - this.label7.Text = "Name:"; - // - // bttnAdd - // - this.bttnAdd.Location = new System.Drawing.Point(354, 13); - this.bttnAdd.Name = "bttnAdd"; - this.bttnAdd.Size = new System.Drawing.Size(75, 23); - this.bttnAdd.TabIndex = 15; - this.bttnAdd.Text = "Add"; - this.bttnAdd.UseVisualStyleBackColor = true; - this.bttnAdd.Click += new System.EventHandler(this.bttnAdd_Click_1); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(17, 18); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(59, 13); - this.label6.TabIndex = 14; - this.label6.Text = "XML Feed:"; - // - // bttnBrowseRss - // - this.bttnBrowseRss.Location = new System.Drawing.Point(435, 13); - this.bttnBrowseRss.Name = "bttnBrowseRss"; - this.bttnBrowseRss.Size = new System.Drawing.Size(75, 23); - this.bttnBrowseRss.TabIndex = 13; - this.bttnBrowseRss.Text = "Browse"; - this.bttnBrowseRss.UseVisualStyleBackColor = true; - this.bttnBrowseRss.Click += new System.EventHandler(this.button1_Click_1); - // - // tbxUrl - // - this.tbxUrl.Location = new System.Drawing.Point(77, 15); - this.tbxUrl.Name = "tbxUrl"; - this.tbxUrl.Size = new System.Drawing.Size(269, 20); - this.tbxUrl.TabIndex = 12; - // - // tvList - // - this.tvList.AllowDrop = true; - this.tvList.Location = new System.Drawing.Point(15, 51); - this.tvList.Name = "tvList"; - this.tvList.Size = new System.Drawing.Size(301, 398); - this.tvList.TabIndex = 13; - this.tvList.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvList_DragDrop); - this.tvList.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvList_AfterSelect); - this.tvList.DragEnter += new System.Windows.Forms.DragEventHandler(this.tvList_DragEnter); - this.tvList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.tvList_ItemDrag); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // bttnCancel - // - this.bttnCancel.Location = new System.Drawing.Point(102, 462); - this.bttnCancel.Name = "bttnCancel"; - this.bttnCancel.Size = new System.Drawing.Size(75, 23); - this.bttnCancel.TabIndex = 22; - this.bttnCancel.Text = "Cancel"; - this.bttnCancel.UseVisualStyleBackColor = true; - this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); - // - // MyRssBaseSetupForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(611, 499); - this.Controls.Add(this.bttnCancel); - this.Controls.Add(this.gbDetail); - this.Controls.Add(this.bttnAdd); - this.Controls.Add(this.bttnOK); - this.Controls.Add(this.label6); - this.Controls.Add(this.tvList); - this.Controls.Add(this.bttnBrowseRss); - this.Controls.Add(this.tbxUrl); - this.Name = "MyRssBaseSetupForm"; - this.Text = "My Torrents"; - this.Load += new System.EventHandler(this.SetupForm_Load); - this.gbDetail.ResumeLayout(false); - this.gbDetail.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.bttnOK = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.gbDetail = new System.Windows.Forms.GroupBox(); + this.label2 = new System.Windows.Forms.Label(); + this.tbxReplacement = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.tbxPattern = new System.Windows.Forms.TextBox(); + this.bttnAddDetail = new System.Windows.Forms.Button(); + this.bttnDelete = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.tbxItemName = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.tbxItemUrl = new System.Windows.Forms.TextBox(); + this.tbxItemImage = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.bttnAdd = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.bttnBrowseRss = new System.Windows.Forms.Button(); + this.tbxUrl = new System.Windows.Forms.TextBox(); + this.tvList = new System.Windows.Forms.TreeView(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.bttnCancel = new System.Windows.Forms.Button(); + this.gbDetail.SuspendLayout(); + this.SuspendLayout(); + // + // bttnOK + // + this.bttnOK.Location = new System.Drawing.Point(15, 462); + this.bttnOK.Name = "bttnOK"; + this.bttnOK.Size = new System.Drawing.Size(75, 23); + this.bttnOK.TabIndex = 5; + this.bttnOK.Text = "OK"; + this.bttnOK.UseVisualStyleBackColor = true; + this.bttnOK.Click += new System.EventHandler(this.button1_Click); + // + // gbDetail + // + this.gbDetail.Controls.Add(this.label2); + this.gbDetail.Controls.Add(this.tbxReplacement); + this.gbDetail.Controls.Add(this.label1); + this.gbDetail.Controls.Add(this.tbxPattern); + this.gbDetail.Controls.Add(this.bttnAddDetail); + this.gbDetail.Controls.Add(this.bttnDelete); + this.gbDetail.Controls.Add(this.button1); + this.gbDetail.Controls.Add(this.tbxItemName); + this.gbDetail.Controls.Add(this.label9); + this.gbDetail.Controls.Add(this.tbxItemUrl); + this.gbDetail.Controls.Add(this.tbxItemImage); + this.gbDetail.Controls.Add(this.label8); + this.gbDetail.Controls.Add(this.label7); + this.gbDetail.Location = new System.Drawing.Point(326, 45); + this.gbDetail.Name = "gbDetail"; + this.gbDetail.Size = new System.Drawing.Size(285, 404); + this.gbDetail.TabIndex = 21; + this.gbDetail.TabStop = false; + this.gbDetail.Text = "Details"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(30, 140); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(50, 13); + this.label2.TabIndex = 26; + this.label2.Text = "Replace:"; + // + // tbxReplacement + // + this.tbxReplacement.Location = new System.Drawing.Point(86, 137); + this.tbxReplacement.Name = "tbxReplacement"; + this.tbxReplacement.Size = new System.Drawing.Size(176, 20); + this.tbxReplacement.TabIndex = 18; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(36, 112); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 13); + this.label1.TabIndex = 24; + this.label1.Text = "Search:"; + // + // tbxPattern + // + this.tbxPattern.Location = new System.Drawing.Point(86, 109); + this.tbxPattern.Name = "tbxPattern"; + this.tbxPattern.Size = new System.Drawing.Size(176, 20); + this.tbxPattern.TabIndex = 17; + // + // bttnAddDetail + // + this.bttnAddDetail.Location = new System.Drawing.Point(104, 176); + this.bttnAddDetail.Name = "bttnAddDetail"; + this.bttnAddDetail.Size = new System.Drawing.Size(75, 23); + this.bttnAddDetail.TabIndex = 22; + this.bttnAddDetail.Text = "Add"; + this.bttnAddDetail.UseVisualStyleBackColor = true; + this.bttnAddDetail.Click += new System.EventHandler(this.bttnAddDetail_Click); + // + // bttnDelete + // + this.bttnDelete.Location = new System.Drawing.Point(180, 176); + this.bttnDelete.Name = "bttnDelete"; + this.bttnDelete.Size = new System.Drawing.Size(75, 23); + this.bttnDelete.TabIndex = 21; + this.bttnDelete.Text = "Delete"; + this.bttnDelete.UseVisualStyleBackColor = true; + this.bttnDelete.Click += new System.EventHandler(this.bttnDelete_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(26, 176); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 20; + this.button1.Text = "Update"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click_2); + // + // tbxItemName + // + this.tbxItemName.Location = new System.Drawing.Point(86, 30); + this.tbxItemName.Name = "tbxItemName"; + this.tbxItemName.Size = new System.Drawing.Size(176, 20); + this.tbxItemName.TabIndex = 14; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(41, 85); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(39, 13); + this.label9.TabIndex = 19; + this.label9.Text = "Image:"; + // + // tbxItemUrl + // + this.tbxItemUrl.Location = new System.Drawing.Point(86, 56); + this.tbxItemUrl.Name = "tbxItemUrl"; + this.tbxItemUrl.Size = new System.Drawing.Size(176, 20); + this.tbxItemUrl.TabIndex = 15; + // + // tbxItemImage + // + this.tbxItemImage.Location = new System.Drawing.Point(86, 82); + this.tbxItemImage.Name = "tbxItemImage"; + this.tbxItemImage.Size = new System.Drawing.Size(176, 20); + this.tbxItemImage.TabIndex = 16; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(57, 56); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(23, 13); + this.label8.TabIndex = 18; + this.label8.Text = "Url:"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(42, 30); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(38, 13); + this.label7.TabIndex = 17; + this.label7.Text = "Name:"; + // + // bttnAdd + // + this.bttnAdd.Location = new System.Drawing.Point(354, 13); + this.bttnAdd.Name = "bttnAdd"; + this.bttnAdd.Size = new System.Drawing.Size(75, 23); + this.bttnAdd.TabIndex = 15; + this.bttnAdd.Text = "Add"; + this.bttnAdd.UseVisualStyleBackColor = true; + this.bttnAdd.Click += new System.EventHandler(this.bttnAdd_Click_1); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(17, 18); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(59, 13); + this.label6.TabIndex = 14; + this.label6.Text = "XML Feed:"; + // + // bttnBrowseRss + // + this.bttnBrowseRss.Location = new System.Drawing.Point(435, 13); + this.bttnBrowseRss.Name = "bttnBrowseRss"; + this.bttnBrowseRss.Size = new System.Drawing.Size(75, 23); + this.bttnBrowseRss.TabIndex = 13; + this.bttnBrowseRss.Text = "Browse"; + this.bttnBrowseRss.UseVisualStyleBackColor = true; + this.bttnBrowseRss.Click += new System.EventHandler(this.button1_Click_1); + // + // tbxUrl + // + this.tbxUrl.Location = new System.Drawing.Point(77, 15); + this.tbxUrl.Name = "tbxUrl"; + this.tbxUrl.Size = new System.Drawing.Size(269, 20); + this.tbxUrl.TabIndex = 12; + // + // tvList + // + this.tvList.AllowDrop = true; + this.tvList.Location = new System.Drawing.Point(15, 51); + this.tvList.Name = "tvList"; + this.tvList.Size = new System.Drawing.Size(301, 398); + this.tvList.TabIndex = 13; + this.tvList.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvList_DragDrop); + this.tvList.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvList_AfterSelect); + this.tvList.DragEnter += new System.Windows.Forms.DragEventHandler(this.tvList_DragEnter); + this.tvList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.tvList_ItemDrag); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // bttnCancel + // + this.bttnCancel.Location = new System.Drawing.Point(102, 462); + this.bttnCancel.Name = "bttnCancel"; + this.bttnCancel.Size = new System.Drawing.Size(75, 23); + this.bttnCancel.TabIndex = 22; + this.bttnCancel.Text = "Cancel"; + this.bttnCancel.UseVisualStyleBackColor = true; + this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); + // + // RssBaseSetupForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(626, 499); + this.Controls.Add(this.bttnCancel); + this.Controls.Add(this.gbDetail); + this.Controls.Add(this.bttnAdd); + this.Controls.Add(this.bttnOK); + this.Controls.Add(this.label6); + this.Controls.Add(this.tvList); + this.Controls.Add(this.bttnBrowseRss); + this.Controls.Add(this.tbxUrl); + this.Name = "RssBaseSetupForm"; + this.Text = "RSS Setup"; + this.Load += new System.EventHandler(this.SetupForm_Load); + this.gbDetail.ResumeLayout(false); + this.gbDetail.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -262,5 +302,9 @@ private System.Windows.Forms.Button bttnAddDetail; private System.Windows.Forms.Button bttnDelete; private System.Windows.Forms.Button bttnCancel; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tbxReplacement; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tbxPattern; } } \ No newline at end of file Modified: trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Shared/RssBaseSetupForm.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -421,6 +421,8 @@ this.tbxItemName.Text = item.text; this.tbxItemUrl.Text = item.url; this.tbxItemImage.Text = item.image; + this.tbxPattern.Text = item.search; + this.tbxReplacement.Text = item.replace; } } } @@ -439,7 +441,9 @@ item.text = this.tbxItemName.Text; item.url = this.tbxItemUrl.Text; item.image = this.tbxItemImage.Text; - + item.search = this.tbxPattern.Text; + item.replace = this.tbxReplacement.Text; + tn.Text = this.tbxItemName.Text; tn.Tag = item; @@ -522,7 +526,7 @@ if (tn != null) { - OpmlOutline item = new OpmlOutline(this.tbxItemName.Text, "link", this.tbxItemUrl.Text, this.tbxItemImage.Text, null, null); + OpmlOutline item = new OpmlOutline(this.tbxItemName.Text, "link", this.tbxItemUrl.Text, this.tbxItemImage.Text, this.tbxPattern.Text, this.tbxReplacement.Text, null, null); TreeNode newtn = tn.Nodes.Add(this.tbxItemName.Text); Modified: trunk/plugins/MyTorrents/c3o.Plugins/Web/Opml.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Web/Opml.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Web/Opml.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -160,12 +160,14 @@ public string type; public string url; public string image; + public string search; + public string replace; public OpmlOutline[] outlines; public OpmlOutline parent = null; public OpmlBody body = null; public bool isDeleted = false; - public OpmlOutline(string text, string type, string url, string image, OpmlBody body, OpmlOutline parent) + public OpmlOutline(string text, string type, string url, string image, OpmlBody body, OpmlOutline parent) { this.text = text; this.type = type; @@ -173,8 +175,22 @@ this.parent = parent; this.body = body; this.image = image; + this.search = null; + this.replace = null; } + public OpmlOutline(string text, string type, string url, string image, string search, string replace, OpmlBody body, OpmlOutline parent) + { + this.text = text; + this.type = type; + this.url = url; + this.parent = parent; + this.body = body; + this.image = image; + this.search = search; + this.replace = replace; + } + public OpmlOutline(XmlNode parentNode, OpmlBody body ) { this.body = body; @@ -220,6 +236,12 @@ case "itunes:image_href": this.image = attribute.Value; break; + case "search": + this.search = attribute.Value; + break; + case "replace": + this.replace = attribute.Value; + break; default: this.Add(attribute.Name, attribute.Value); break; @@ -245,6 +267,8 @@ xmlOutline.SetAttribute("url", this.url); xmlOutline.SetAttribute("image", this.image); xmlOutline.SetAttribute("type", this.type); + xmlOutline.SetAttribute("search", this.search); + xmlOutline.SetAttribute("replace", this.replace); foreach (string key in this.Keys) { Modified: trunk/plugins/MyTorrents/c3o.Plugins/Web/RSSReader.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Web/RSSReader.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Web/RSSReader.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -3,6 +3,7 @@ using System.Text; using System.Data; using System.Xml; +using System.Text.RegularExpressions; namespace c3o.Framework.Web { @@ -10,20 +11,36 @@ { public DataTable Header = null; public DataTable Detail = null; + private SiteReader sr; + public string TorrentPath = "Torrents"; public RssReader(string url) { - SiteReader sr = new SiteReader(); - XmlDocument xml = new XmlDocument(); + this.LoadData(url, null, null); - // Read rss feed into XmlDocument - xml.LoadXml(sr.ReadPage(url)); + //SiteReader sr = new SiteReader(); + //XmlDocument xml = new XmlDocument(); - this.LoadData(xml); + //// Read rss feed into XmlDocument + //xml.LoadXml(sr.ReadPage(url)); + + //this.LoadData(xml); } + public RssReader(string url, string pattern, string replacement) + { + this.sr = new SiteReader(); + + this.LoadData(url, pattern, replacement); + } + + public RssReader(XmlDocument xml) { + this.sr = new SiteReader(); + + this.LoadData(xml); + //XmlDocument xml = new XmlDocument(); // Read rss feed into XmlDocument @@ -34,10 +51,29 @@ //// Load items into datatable //this.Detail = this.GetRssItems(xml); - this.LoadData(xml); + } + public void LoadData(string url, string pattern, string replacement) + { + XmlDocument xml = new XmlDocument(); + + // Read rss feed into XmlDocument + string xmlstring = this.sr.ReadPage(url); + + if (pattern != null && pattern.Length > 0 && replacement != null && replacement.Length > 0) + { + Regex reg = new Regex(pattern); + xmlstring = reg.Replace(xmlstring, replacement); + } + + xml.LoadXml(xmlstring); + + this.LoadData(xml); + } + + public void LoadData(XmlDocument xml) { // Load header into datatable @@ -47,6 +83,33 @@ this.Detail = this.GetRssItems(xml); } + + + + public void DownloadTorrent(string url) + { + int i = 1; + if (url != null && url.Length > 0) + { + if (!System.IO.Directory.Exists(this.TorrentPath)) System.IO.Directory.CreateDirectory(this.TorrentPath); + + // Find file name + string FileName = this.TorrentPath + @"\temp" + i.ToString() + ".torrent"; + while (System.IO.File.Exists(FileName)) + { + i++; + FileName = this.TorrentPath + @"\temp" + i.ToString() + ".torrent"; + } + + // Save Torrent file to disk + this.sr.Download(url, FileName); + + // Launch client + System.Diagnostics.Process.Start(FileName); + } + } + + public DataTable GetRssHeader(XmlDocument xml) { DataTable dt = null; Modified: trunk/plugins/MyTorrents/c3o.Plugins/Web/SiteReader.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Web/SiteReader.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Web/SiteReader.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -6,7 +6,7 @@ { public class SiteReader { - private CookieContainer cookies; + private CookieContainer cookies = new CookieContainer(); public SiteReader() { @@ -57,7 +57,7 @@ /// <returns></returns> public string ReadPage(string url) { - return WebHelper.ReadPage(url, cookies); + return WebHelper.ReadPage(url, ref cookies); //// Setup the request //HttpWebRequest wr = WebRequest.Create(url) as HttpWebRequest; @@ -81,7 +81,7 @@ /// <returns></returns> public byte[] ReadFile(string url) { - return WebHelper.ReadFile(url, cookies); + return WebHelper.ReadFile(url, ref cookies); //byte[] result; //byte[] buffer = new byte[4096]; @@ -121,7 +121,7 @@ /// <param name="filename"></param> public void Download(string url, string filename) { - WebHelper.Download(url, filename, cookies); + WebHelper.Download(url, filename, ref cookies); //byte[] FileData = this.ReadFile(url); Modified: trunk/plugins/MyTorrents/c3o.Plugins/Web/WebHelper.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Web/WebHelper.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Web/WebHelper.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -51,7 +51,7 @@ /// </summary> /// <param name="url"></param> /// <returns></returns> - public static string ReadPage(string url, CookieContainer cookies) + public static string ReadPage(string url, ref CookieContainer cookies) { // Setup the request HttpWebRequest wr = WebRequest.Create(url) as HttpWebRequest; @@ -73,7 +73,7 @@ /// </summary> /// <param name="url"></param> /// <returns></returns> - public static byte[] ReadFile(string url, CookieContainer cookies) + public static byte[] ReadFile(string url, ref CookieContainer cookies) { byte[] result; byte[] buffer = new byte[4096]; @@ -111,9 +111,9 @@ /// </summary> /// <param name="url"></param> /// <param name="filename"></param> - public static void Download(string url, string filename, CookieContainer cookies) + public static void Download(string url, string filename, ref CookieContainer cookies) { - byte[] FileData = ReadFile(url, cookies); + byte[] FileData = ReadFile(url, ref cookies); // Create file FileStream fs = File.Create(filename); Modified: trunk/plugins/MyTorrents/c3o.Plugins/Web/uTorrentData.cs =================================================================== --- trunk/plugins/MyTorrents/c3o.Plugins/Web/uTorrentData.cs 2007-09-26 07:34:18 UTC (rev 956) +++ trunk/plugins/MyTorrents/c3o.Plugins/Web/uTorrentData.cs 2007-09-26 22:16:15 UTC (rev 957) @@ -54,41 +54,54 @@ if (JsonData != null) { // Clean up string + JsonData = JsonData.Replace("'", ""); // Remove Any single quotes + JsonData = JsonData.Replace("\"", "'"); JsonData = JsonData.Replace("\n\r", ""); JsonData = JsonData.Replace("\r\n", ""); JsonData = JsonData.Replace("\n", ""); JsonData = JsonData.Replace("\r", ""); - JsonData = JsonData.Replace("{\"\":\"\",\"label\": [],\"torrents\":", ""); - JsonData = JsonData.Replace("[[", "["); - JsonData = JsonData.Substring(0, (JsonData.IndexOf("]]") + 1)); - JsonData = JsonData.Replace("],[", "]\n\r["); - JsonData = JsonData.Replace("[", "#"); - JsonData = JsonData.Replace("]", "#"); + string start = "'torrents':"; + JsonData = JsonData.Substring(JsonData.IndexOf("'torrents':") + start.Length); + + // Replace [ outside of quotes with #[# + Regex reg = new Regex("\\[(?=([^']*'[^']*')*(?![^']*'))"); + JsonData = reg.Replace(JsonData, "<<<"); + + // Replace ] outside of quotes with #]# + reg = new Regex("\\](?=([^']*'[^']*')*(?![^']*'))"); + JsonData = reg.Replace(JsonData, ">>>"); + + JsonData = JsonData.Replace("<<<<<<", "<<<"); + JsonData = JsonData.Replace("<<< <<<", "<<<"); + JsonData = JsonData.Substring(0, (JsonData.IndexOf(">>>>>>") + 3)); + JsonData = JsonData.Replace(">>>, <<<", ">>>\n\r<<<"); + JsonData = JsonData.Replace(">>>,<<<", ">>>\n\r<<<"); + // Create DataTable to hold list dt = new DataTable(); dt.Columns.Add("key", typeof(string)); - dt.Columns.Add("status", typeof(Int64)); + dt.Columns.Add("status", typeof(Int64)); dt.Columns.Add("FileName", typeof(string)); - dt.Columns.Add("Size", typeof(Int64)); - dt.Columns.Add("percentage", typeof(Int64)); - dt.Columns.Add("bytes", typeof(Int64)); + dt.Columns.Add("Size", typeof(Int64)); + dt.Columns.Add("percentage", typeof(Int64)); + dt.Columns.Add("bytes", typeof(Int64)); dt.Columns.Add("i5", typeof(Int64)); - dt.Columns.Add("ratio", typeof(Int64)); // 24 = 0.024 - dt.Columns.Add("UpSpeed", typeof(Int64)); - dt.Columns.Add("DownSpeed", typeof(Int64)); - dt.Columns.Add("i9", typeof(Int64)); + dt.Columns.Add("ratio", typeof(Int64)); // 24 = 0.024 + dt.Columns.Add("UpSpeed", typeof(Int64)); + dt.Columns.Add("DownSpeed", typeof(Int64)); + dt.Columns.Add("ETA", typeof(Int64)); dt.Columns.Add("s1", typeof(string)); - dt.Columns.Add("peers", typeof(int)); + dt.Columns.Add("peers", typeof(int)); dt.Columns.Add("peers2", typeof(int)); dt.Columns.Add("seeds", typeof(int)); dt.Columns.Add("seeds2", typeof(int)); - dt.Columns.Add("i14", typeof(Int64)); - dt.Columns.Add("i15", typeof(Int64)); - dt.Columns.Add("i16", typeof(Int64)); + dt.Columns.Add("i14", typeof(Int64)); + dt.Columns.Add("i15", typeof(Int64)); + dt.Columns.Add("i16", typeof(Int64)); // Regular Expression to parse data - string pattern = @"#(?<row>.*)#"; + string pattern = @"<<<(?<row>.*)>>>"; // Find data MatchCollection mc = Regex.Matches(JsonData, pattern); @@ -100,12 +113,16 @@ string RowString... [truncated message content] |