From: <gre...@us...> - 2007-08-30 21:28:58
|
Revision: 878 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=878&view=rev Author: gregmac45 Date: 2007-08-30 14:28:51 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Added ability to set trailer quality Modified Paths: -------------- trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.Designer.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesTrailerUtil.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/AppleTrailers.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/ItmsHelper.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/RegexParsers.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/TrailerStream.cs trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideoSettings.cs Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.Designer.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.Designer.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.Designer.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -39,6 +39,8 @@ { this.tabControl1 = new System.Windows.Forms.TabControl(); this.General_Tab = new System.Windows.Forms.TabPage(); + this.label4 = new System.Windows.Forms.Label(); + this.cmbTrailerSize = new System.Windows.Forms.ComboBox(); this.txtDownloadDir = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); @@ -81,11 +83,13 @@ this.tabControl1.Margin = new System.Windows.Forms.Padding(4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(639, 697); + this.tabControl1.Size = new System.Drawing.Size(639, 715); this.tabControl1.TabIndex = 0; // // General_Tab // + this.General_Tab.Controls.Add(this.label4); + this.General_Tab.Controls.Add(this.cmbTrailerSize); this.General_Tab.Controls.Add(this.txtDownloadDir); this.General_Tab.Controls.Add(this.label3); this.General_Tab.Controls.Add(this.groupBox2); @@ -98,11 +102,27 @@ this.General_Tab.Margin = new System.Windows.Forms.Padding(4); this.General_Tab.Name = "General_Tab"; this.General_Tab.Padding = new System.Windows.Forms.Padding(4); - this.General_Tab.Size = new System.Drawing.Size(631, 668); + this.General_Tab.Size = new System.Drawing.Size(631, 686); this.General_Tab.TabIndex = 0; this.General_Tab.Text = "General"; this.General_Tab.UseVisualStyleBackColor = true; // + // label4 + // + this.label4.Location = new System.Drawing.Point(20, 103); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(188, 23); + this.label4.TabIndex = 22; + this.label4.Text = "Apple Trailers Max Quality"; + // + // cmbTrailerSize + // + this.cmbTrailerSize.FormattingEnabled = true; + this.cmbTrailerSize.Location = new System.Drawing.Point(293, 100); + this.cmbTrailerSize.Name = "cmbTrailerSize"; + this.cmbTrailerSize.Size = new System.Drawing.Size(121, 24); + this.cmbTrailerSize.TabIndex = 21; + // // txtDownloadDir // this.txtDownloadDir.Location = new System.Drawing.Point(293, 70); @@ -130,18 +150,18 @@ this.groupBox2.Controls.Add(this.label26); this.groupBox2.Controls.Add(this.txtRssName); this.groupBox2.Controls.Add(this.label25); - this.groupBox2.Location = new System.Drawing.Point(20, 363); + this.groupBox2.Location = new System.Drawing.Point(20, 391); this.groupBox2.Margin = new System.Windows.Forms.Padding(4); this.groupBox2.Name = "groupBox2"; this.groupBox2.Padding = new System.Windows.Forms.Padding(4); - this.groupBox2.Size = new System.Drawing.Size(548, 294); + this.groupBox2.Size = new System.Drawing.Size(548, 281); this.groupBox2.TabIndex = 18; this.groupBox2.TabStop = false; this.groupBox2.Text = "Site Categories"; // // btnAdd // - this.btnAdd.Location = new System.Drawing.Point(116, 246); + this.btnAdd.Location = new System.Drawing.Point(116, 248); this.btnAdd.Margin = new System.Windows.Forms.Padding(4); this.btnAdd.Name = "btnAdd"; this.btnAdd.Size = new System.Drawing.Size(100, 28); @@ -154,7 +174,7 @@ // this.CategoryList.FormattingEnabled = true; this.CategoryList.ItemHeight = 16; - this.CategoryList.Location = new System.Drawing.Point(29, 23); + this.CategoryList.Location = new System.Drawing.Point(8, 23); this.CategoryList.Margin = new System.Windows.Forms.Padding(4); this.CategoryList.Name = "CategoryList"; this.CategoryList.Size = new System.Drawing.Size(159, 212); @@ -163,7 +183,7 @@ // // btnDeleteRss // - this.btnDeleteRss.Location = new System.Drawing.Point(8, 246); + this.btnDeleteRss.Location = new System.Drawing.Point(8, 248); this.btnDeleteRss.Margin = new System.Windows.Forms.Padding(4); this.btnDeleteRss.Name = "btnDeleteRss"; this.btnDeleteRss.Size = new System.Drawing.Size(100, 28); @@ -231,7 +251,7 @@ this.groupBox1.Controls.Add(this.label27); this.groupBox1.Controls.Add(this.siteList); this.groupBox1.Controls.Add(this.chkEnabled); - this.groupBox1.Location = new System.Drawing.Point(20, 106); + this.groupBox1.Location = new System.Drawing.Point(20, 129); this.groupBox1.Margin = new System.Windows.Forms.Padding(4); this.groupBox1.Name = "groupBox1"; this.groupBox1.Padding = new System.Windows.Forms.Padding(4); @@ -389,7 +409,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(681, 716); + this.ClientSize = new System.Drawing.Size(681, 744); this.Controls.Add(this.tabControl1); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "Configuration"; @@ -405,6 +425,8 @@ this.groupBox1.PerformLayout(); this.ResumeLayout(false); } + private System.Windows.Forms.ComboBox cmbTrailerSize; + private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox txtDownloadDir; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.Label label3; Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/Configuration.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -54,6 +54,13 @@ siteList.Items.Add(site.name); moSiteList.Add(site); } + foreach(ITMSClient.TrailerSize size in Enum.GetValues(typeof(ITMSClient.TrailerSize))){ + + cmbTrailerSize.Items.Add(size); + if(size==OnlineVideoSettings.getInstance().AppleTrailerSize){ + cmbTrailerSize.SelectedIndex = cmbTrailerSize.Items.Count-1; + } + } } @@ -170,6 +177,7 @@ settings.msFilterArray = lsFilterArray; settings.msThumbLocation = txtThumbLoc.Text; settings.msDownloadDir = txtDownloadDir.Text; + settings.AppleTrailerSize = (ITMSClient.TrailerSize) cmbTrailerSize.SelectedItem; settings.moSiteList.Clear(); foreach(GUIOnlineVideos.SiteSettings site in moSiteList){ settings.moSiteList.Add(site.id,site); Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/GUIOnlineVideos.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -37,7 +37,8 @@ private String msSelectedSiteId; private String msSelectedCategoryValue; private String msSelectedCategoryName; - private String msSelectedVideo; + private VideoInfo moSelectedVideo; + private State _CurrentState = State.home; private String msDownloadDir = Directory.GetCurrentDirectory()+"\\"; private List<VideoInfo> moCurrentVideoList = new List<VideoInfo>(); @@ -78,6 +79,7 @@ public class VideoInfo { public String Title; + public String Title2; public String Description = ""; public String VideoUrl = ""; public String ImageUrl = ""; @@ -224,7 +226,7 @@ facadeView.SelectedListItemIndex = miSelectedIndex; } else{ - DisplayVideoDetails(moCurrentVideoList[facadeView.SelectedListItemIndex - 1]); + DisplayVideoDetails(moSelectedVideo); } UpdateViewSate(); //base.OnPageLoad(); @@ -693,7 +695,7 @@ } private void DisplayVideoDetails(VideoInfo foVideo) { - msSelectedVideo = foVideo.Title; + moSelectedVideo = foVideo; SiteUtilBase loSiteUtil = SiteUtilFactory.getSiteUtil(msSelectedSiteId); List<VideoInfo> loVideoList= loSiteUtil.getOtherVideoList(foVideo); moCurrentVideoList.Clear(); @@ -711,6 +713,7 @@ loVideoInfo.Description = cleanString(loVideoInfo.Description); loListItem = new GUIListItem(loVideoInfo.Title); + loListItem.Label2 = loVideoInfo.Title2; loListItem.Path = loVideoInfo.VideoUrl; loListItem.ItemId = liIdx; //loListItem.RetrieveArt = false; @@ -874,7 +877,7 @@ break; case State.info: - GUIPropertyManager.SetProperty("#header.label",msSelectedVideo); + GUIPropertyManager.SetProperty("#header.label",moSelectedVideo.Title); GUIPropertyManager.SetProperty("#header.image","OnlineVidlogo"+msSelectedSiteId+".jpeg"); //DisplayVideoInfo(); break; Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesTrailerUtil.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesTrailerUtil.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesTrailerUtil.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -51,17 +51,11 @@ } */ DownloadTrailers(fsUrl); - GUIOnlineVideos.VideoInfo loItem; + //GUIOnlineVideos.VideoInfo loItem; foreach (ITMSClient.TrailerInfo trailer in HDTrailerPlugin.AppleTrailers.trailers) { - loItem = new GUIOnlineVideos.VideoInfo(); - loItem.Title = trailer.Title; - if(trailer.PosterUrl!=null) - loItem.ImageUrl = trailer.PosterUrl.ToString(); - loItem.Tags = trailer.Genre; - loItem.Other = trailer; /* try{ ITMSClient.TrailerInfo trailerMore = AppleTrailers.ProcessTrailer(trailer); @@ -75,7 +69,7 @@ // //loItem.Length = trailer.. */ - loListItems.Add(loItem); + loListItems.Add(loadVideoInfo(trailer)); /* }catch(Exception e){ Log.Debug("skipped {0}. Unable to parse video url out of {1}",trailer.Title, trailer.Url); @@ -93,13 +87,10 @@ trailer = AppleTrailers.GetTrailerUrls(trailer); Console.WriteLine("Found {0} trailer urls",trailer.trailers.Count); GUIOnlineVideos.VideoInfo newVideo; - foreach (String name in trailer.trailers.Keys){ - newVideo = new GUIOnlineVideos.VideoInfo(); + foreach (String name in trailer.trailers.Keys){ + newVideo = loadVideoInfo(trailer); newVideo.Title = name; - newVideo.VideoUrl = trailer.trailers[name]; - newVideo.Description = trailer.Overview; - Console.WriteLine(newVideo.Description); - newVideo.Other = trailer; + newVideo.VideoUrl = trailer.trailers[name]; videoList.Add(newVideo); } return videoList; @@ -107,12 +98,13 @@ public override String getUrl(GUIOnlineVideos.VideoInfo video,GUIOnlineVideos.SiteSettings foSite) { TrailerInfo trailer = (TrailerInfo)video.Other; - trailer = AppleTrailers.ProcessTrailer(trailer); + trailer = AppleTrailers.ProcessTrailer(trailer,OnlineVideoSettings.getInstance().AppleTrailerSize); + Log.Info("Trailer quality set to {0}",OnlineVideoSettings.getInstance().AppleTrailerSize); Console.WriteLine("Found {0} trailer urls",trailer.TrailerStreamCollection.Count); return trailer.TrailerStreamCollection[0].Uri.ToString(); } public List<GUIOnlineVideos.VideoInfo> getAllTrailers(){ - GUIOnlineVideos.VideoInfo loItem; + //GUIOnlineVideos.VideoInfo loItem; Dictionary<string, GUIOnlineVideos.RssLink> loRssList= OnlineVideoSettings.getInstance().moSiteList[getSiteId()].RssList; List<GUIOnlineVideos.VideoInfo> loListItems = new List<GUIOnlineVideos.VideoInfo>(); foreach(GUIOnlineVideos.RssLink link in loRssList.Values){ @@ -129,16 +121,9 @@ if(loTrailersFound.ContainsKey(trailer.Title) == false){ loTrailersFound.Add(trailer.Title.ToUpper(), ""); - loItem = new GUIOnlineVideos.VideoInfo(); - loItem.Title = trailer.Title; - if(trailer.PosterUrl!=null){ - loItem.ImageUrl = trailer.PosterUrl.ToString(); - } - loItem.Description = trailer.Overview; - loItem.VideoUrl = trailer.Url.ToString(); - loItem.Other = trailer; + //loItem.Length = trailer.. - loListItems.Add(loItem); + loListItems.Add(loadVideoInfo(trailer)); } } @@ -179,5 +164,17 @@ //Log.Info("finished getting trailers from url:"+fsLink.url); } + private GUIOnlineVideos.VideoInfo loadVideoInfo(TrailerInfo trailer){ + GUIOnlineVideos.VideoInfo newVideo = new GUIOnlineVideos.VideoInfo(); + newVideo.Title = trailer.Title; + newVideo.VideoUrl = trailer.Title; + newVideo.Description = trailer.Overview; + if(trailer.PosterUrl!=null){ + newVideo.ImageUrl = trailer.PosterUrl.ToString(); + } + newVideo.Other = trailer; + return newVideo; + + } } } Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/AppleTrailers.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/AppleTrailers.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/AppleTrailers.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -116,7 +116,7 @@ /// </summary> /// <param name="obj">Obj.</param> /// <returns></returns> - public static ITMSClient.TrailerInfo ProcessTrailer(object obj) + public static ITMSClient.TrailerInfo ProcessTrailer(object obj ,ITMSClient.TrailerSize size) { ITMSClient.TrailerInfo trailerInfo = (ITMSClient.TrailerInfo)obj; @@ -124,7 +124,7 @@ // Lookup the trailer in the media library string key = trailerInfo.Title.GetHashCode().ToString(); // Populate the rest of the meta data - trailerInfo = ITMSClient.ITMSHelper.PopulateTrailerDetails(trailerInfo, ITMSClient.TrailerSize.h640); + trailerInfo = ITMSClient.ITMSHelper.PopulateTrailerDetails(trailerInfo, size); // Get the poster image if it doesn't already exist //if (trailerInfo.PosterUrl != null) Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/ItmsHelper.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/ItmsHelper.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/ItmsHelper.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -179,6 +179,7 @@ TrailerStream myStream = GetDesiredTrailerStream(tsc, desiredSize); trailerInfo.TrailerStreamCollection.Add(myStream); + //trailerInfo.TrailerStreamCollection = tsc; } } trailerInfo.TrailerStreamCollection.TrimToSize(); Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/RegexParsers.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/RegexParsers.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/RegexParsers.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -71,7 +71,7 @@ /// </summary> internal static Regex streamRegex = new Regex( //@"<GotoURL.+?url=""(?<url>.*?(?<size>(small|medium|large|fullscreen))\.xml)""", - @"<key>episodeURL</key><string>(?<url>[^<]*(?<size>h[\d]*)[w]*\.mov)", + @"<key>episodeURL</key><string>(?<url>[^<]*(?<size>h[\d]*p*)[w]*\.mov)", RegexOptions.ExplicitCapture | RegexOptions.Compiled ); Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/TrailerStream.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/TrailerStream.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/ItunesUtils/TrailerStream.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -103,4 +103,4 @@ } } -} \ No newline at end of file +} Modified: trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideoSettings.cs =================================================================== --- trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideoSettings.cs 2007-08-30 13:10:21 UTC (rev 877) +++ trunk/plugins/OnlineVideos/Source/OnlineVideos/OnlineVideoSettings.cs 2007-08-30 21:28:51 UTC (rev 878) @@ -24,9 +24,10 @@ public String msDownloadDir; public String[] msFilterArray; public Dictionary<String,GUIOnlineVideos.SiteSettings> moSiteList = new Dictionary<String, GUIOnlineVideos.SiteSettings>(); - + public ITMSClient.TrailerSize AppleTrailerSize = ITMSClient.TrailerSize.h640; private const String SETTINGS_FILE = "OnlineVideoSites.xml"; private const String THUMBNAIL_DIR = "thumbDir"; + private const String TRAILER_SIZE = "trailerSize"; private const String DOWNLOAD_DIR = "downloadDir"; private const String SECTION = "onlinevideos"; private const String FILTER = "filter"; @@ -42,20 +43,24 @@ loadSettings(); } private void loadSettings(){ - + String lsTrailerSize; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { msThumbLocation = xmlreader.GetValueAsString(SECTION, THUMBNAIL_DIR, ""); msDownloadDir = xmlreader.GetValueAsString(SECTION, DOWNLOAD_DIR, ""); String lsFilter = xmlreader.GetValueAsString(SECTION, FILTER, ""); - + lsTrailerSize = xmlreader.GetValueAsString(SECTION,TRAILER_SIZE,"h640"); msFilterArray = lsFilter.Split(new char[] { ',' }); if (msFilterArray.Length == 1 && msFilterArray[0] == "") { msFilterArray = null; } } + if(Enum.IsDefined(typeof(ITMSClient.TrailerSize),lsTrailerSize)){ + AppleTrailerSize = (ITMSClient.TrailerSize)Enum.Parse(typeof(ITMSClient.TrailerSize),lsTrailerSize,true); + } + if(String.IsNullOrEmpty(msThumbLocation)){ msThumbLocation = Config.GetFolder(Config.Dir.Thumbs) +@"\OnlineVideos\"; @@ -157,6 +162,7 @@ } xmlwriter.SetValue(SECTION,THUMBNAIL_DIR,msThumbLocation); xmlwriter.SetValue(SECTION, DOWNLOAD_DIR,msDownloadDir ); + xmlwriter.SetValue(SECTION,TRAILER_SIZE,AppleTrailerSize.ToString()); } Console.WriteLine(System.IO.Directory.GetCurrentDirectory()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |