SHARE
TWEET

Untitled

a guest Jan 2nd, 2017 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  .../TVLibrary/Plugins/XmlTvImport/XMLTVImport.cs   | 13 +++++-
  2.  TvEngine3/TVLibrary/TVDatabase/Program.cs          | 23 +++++++--
  3.  .../TVDatabase/TvBusinessLayer/BusinessLayer.cs    | 11 +++--
  4.  .../TVLibrary/TvPlugin/TvPlugin/TVScheduler.cs     |  2 +
  5.  TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVSearch.cs  |  2 +
  6.  .../TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs     |  2 +
  7.  mediaportal/Core/guilib/DownloadedImage.cs         | 54 +++++++++++++++++-----
  8.  mediaportal/Core/guilib/GUIImage.cs                | 22 ++++++++-
  9.  mediaportal/Core/guilib/GUITextureManager.cs       | 38 ++++++++++++---
  10.  9 files changed, 140 insertions(+), 27 deletions(-)
  11.  
  12. diff --git a/TvEngine3/TVLibrary/Plugins/XmlTvImport/XMLTVImport.cs b/TvEngine3/TVLibrary/Plugins/XmlTvImport/XMLTVImport.cs
  13. index feff189..1745cf5 100644
  14. --- a/TvEngine3/TVLibrary/Plugins/XmlTvImport/XMLTVImport.cs
  15. +++ b/TvEngine3/TVLibrary/Plugins/XmlTvImport/XMLTVImport.cs
  16. @@ -425,6 +425,7 @@ namespace TvEngine
  17.                  String nodeDate = null;
  18.                  String nodeStarRating = null;
  19.                  String nodeClassification = null;
  20. +                String nodeIcon = null;
  21.  
  22.                  XmlReader xmlProg = xmlReader.ReadSubtree();
  23.                  xmlProg.ReadStartElement(); // read programme
  24. @@ -475,6 +476,10 @@ namespace TvEngine
  25.                          if (nodeClassification == null) nodeClassification = xmlProg.ReadInnerXml();
  26.                          else xmlProg.Skip();
  27.                          break;
  28. +                      case "icon":
  29. +                        if (nodeIcon == null) nodeIcon = xmlProg.GetAttribute("src");
  30. +                        else xmlProg.Skip();
  31. +                        break;
  32.                        default:
  33.                          // unknown, skip entire node
  34.                          xmlProg.Skip();
  35. @@ -507,6 +512,7 @@ namespace TvEngine
  36.                    string episodePart = "";
  37.                    int starRating = -1;
  38.                    string classification = "";
  39. +                  string icon = "";
  40.  
  41.                    string title = ConvertHTMLToAnsi(nodeTitle);
  42.  
  43. @@ -666,6 +672,11 @@ namespace TvEngine
  44.                      classification = nodeClassification;
  45.                    }
  46.  
  47. +                  if (nodeIcon != null)
  48. +                  {
  49. +                    icon = nodeIcon;
  50. +                  }
  51. +
  52.                    if (showProgress && ShowProgress != null && (_status.Programs % 100) == 0) ShowProgress(_status);
  53.  
  54.                    #endregion
  55. @@ -710,7 +721,7 @@ namespace TvEngine
  56.                          Program prog = new Program(chan.IdChannel, longtodate(startDate), longtodate(stopDate), title,
  57.                                                     description, category, Program.ProgramState.None,
  58.                                                     System.Data.SqlTypes.SqlDateTime.MinValue.Value, seriesNum,
  59. -                                                   episodeNum, episodeName, episodePart, starRating, classification, -1);
  60. +                                                   episodeNum, episodeName, episodePart, starRating, classification, -1, icon);
  61.                          channelPrograms.programs.Add(prog);
  62.                          programIndex++;
  63.                          //prog.Description = ConvertHTMLToAnsi(strDescription);
  64. diff --git a/TvEngine3/TVLibrary/TVDatabase/Program.cs b/TvEngine3/TVLibrary/TVDatabase/Program.cs
  65. index 79c218a..6557de9 100644
  66. --- a/TvEngine3/TVLibrary/TVDatabase/Program.cs
  67. +++ b/TvEngine3/TVLibrary/TVDatabase/Program.cs
  68. @@ -50,6 +50,7 @@ namespace TvDatabase
  69.      [TableColumn("starRating", NotNull = true)] private int starRating;
  70.      [TableColumn("classification", NotNull = true)] private string classification;
  71.      [TableColumn("parentalRating", NotNull = true)] private int parentalRating;
  72. +    [TableColumn("icon", NotNull = true)] private string icon;
  73.  
  74.      #endregion
  75.  
  76. @@ -80,7 +81,7 @@ namespace TvDatabase
  77.      public Program(int idChannel, DateTime startTime, DateTime endTime, string title, string description, string genre,
  78.                     ProgramState state, DateTime originalAirDate, string seriesNum, string episodeNum, string episodeName,
  79.                     string episodePart, int starRating,
  80. -                   string classification, int parentalRating)
  81. +                   string classification, int parentalRating, string icon = "")
  82.      {
  83.        isChanged = true;
  84.        this.idChannel = idChannel;
  85. @@ -98,6 +99,7 @@ namespace TvDatabase
  86.        this.starRating = starRating;
  87.        this.classification = classification;
  88.        this.parentalRating = parentalRating;
  89. +      this.icon = icon;
  90.      }
  91.  
  92.      /// <summary>
  93. @@ -107,7 +109,7 @@ namespace TvDatabase
  94.      public Program(int idProgram, int idChannel, DateTime startTime, DateTime endTime, string title, string description,
  95.                     string genre, ProgramState state, DateTime originalAirDate, string seriesNum, string episodeNum,
  96.                     string episodeName, string episodePart,
  97. -                   int starRating, string classification, int parentalRating)
  98. +                   int starRating, string classification, int parentalRating, string icon = "")
  99.      {
  100.        this.idProgram = idProgram;
  101.        this.idChannel = idChannel;
  102. @@ -125,6 +127,7 @@ namespace TvDatabase
  103.        this.starRating = starRating;
  104.        this.classification = classification;
  105.        this.parentalRating = parentalRating;
  106. +      this.icon = icon;
  107.      }
  108.  
  109.      #endregion
  110. @@ -538,6 +541,20 @@ namespace TvDatabase
  111.        }
  112.      }
  113.  
  114. +    /// <summary>
  115. +    /// The programs icon (url) from the distributor
  116. +    /// </summary>
  117. +    public string Icon
  118. +    {
  119. +      get { return icon; }
  120. +      set
  121. +      {
  122. +        isChanged |= icon != value;
  123. +        icon = value;
  124. +      }
  125. +    }
  126. +
  127. +
  128.      #endregion
  129.  
  130.      #region Storage and Retrieval
  131. @@ -1162,7 +1179,7 @@ namespace TvDatabase
  132.        Program p = new Program(idProgram, idChannel, StartTime, EndTime, Title, Description, Genre, (ProgramState)state,
  133.                                OriginalAirDate,
  134.                                SeriesNum, EpisodeNum, EpisodeName, EpisodePart, StarRating, Classification,
  135. -                              parentalRating);
  136. +                              parentalRating, icon);
  137.        return p;
  138.      }
  139.  
  140. diff --git a/TvEngine3/TVLibrary/TVDatabase/TvBusinessLayer/BusinessLayer.cs b/TvEngine3/TVLibrary/TVDatabase/TvBusinessLayer/BusinessLayer.cs
  141. index ab9d378..146dd01 100644
  142. --- a/TvEngine3/TVLibrary/TVDatabase/TvBusinessLayer/BusinessLayer.cs
  143. +++ b/TvEngine3/TVLibrary/TVDatabase/TvBusinessLayer/BusinessLayer.cs
  144. @@ -1468,7 +1468,8 @@ namespace TvDatabase
  145.            Convert.ToString(prog["episodePart"]),
  146.            Convert.ToInt32(prog["starRating"]),
  147.            Convert.ToString(prog["classification"]),
  148. -          Convert.ToInt32(prog["parentalRating"])
  149. +          Convert.ToInt32(prog["parentalRating"]),
  150. +          Convert.ToString(prog["icon"])
  151.            );
  152.  
  153.          int idChannel = p.IdChannel;
  154. @@ -2602,7 +2603,7 @@ namespace TvDatabase
  155.        List<Program> currentInserts = new List<Program>(aProgramList);
  156.  
  157.        sqlCmd.CommandText =
  158. -        "INSERT INTO Program (idChannel, startTime, endTime, title, description, seriesNum, episodeNum, genre, originalAirDate, classification, starRating, state, parentalRating, episodeName, episodePart) VALUES (?idChannel, ?startTime, ?endTime, ?title, ?description, ?seriesNum, ?episodeNum, ?genre, ?originalAirDate, ?classification, ?starRating, ?state, ?parentalRating, ?episodeName, ?episodePart)";
  159. +        "INSERT INTO Program (idChannel, startTime, endTime, title, description, seriesNum, episodeNum, genre, originalAirDate, classification, starRating, state, parentalRating, episodeName, episodePart, icon) VALUES (?idChannel, ?startTime, ?endTime, ?title, ?description, ?seriesNum, ?episodeNum, ?genre, ?originalAirDate, ?classification, ?starRating, ?state, ?parentalRating, ?episodeName, ?episodePart, ?icon)";
  160.  
  161.        sqlCmd.Parameters.Add("?idChannel", MySqlDbType.Int32);
  162.        sqlCmd.Parameters.Add("?startTime", MySqlDbType.DateTime);
  163. @@ -2619,6 +2620,7 @@ namespace TvDatabase
  164.        sqlCmd.Parameters.Add("?parentalRating", MySqlDbType.Int32);
  165.        sqlCmd.Parameters.Add("?episodeName", MySqlDbType.Text);
  166.        sqlCmd.Parameters.Add("?episodePart", MySqlDbType.Text);
  167. +      sqlCmd.Parameters.Add("?icon", MySqlDbType.Text);
  168.  
  169.        try
  170.        {
  171. @@ -2648,6 +2650,7 @@ namespace TvDatabase
  172.          sqlCmd.Parameters["?parentalRating"].Value = prog.ParentalRating;
  173.          sqlCmd.Parameters["?episodeName"].Value = prog.EpisodeName;
  174.          sqlCmd.Parameters["?episodePart"].Value = prog.EpisodePart;
  175. +        sqlCmd.Parameters["?icon"].Value = prog.Icon;
  176.          try
  177.          {
  178.            // Finally insert all our data
  179. @@ -2791,7 +2794,7 @@ namespace TvDatabase
  180.        List<Program> currentInserts = new List<Program>(aProgramList);
  181.  
  182.        sqlCmd.CommandText =
  183. -        "INSERT INTO Program (idChannel, startTime, endTime, title, description, seriesNum, episodeNum, genre, originalAirDate, classification, starRating, state, parentalRating, episodeName, episodePart) VALUES (@idChannel, @startTime, @endTime, @title, @description, @seriesNum, @episodeNum, @genre, @originalAirDate, @classification, @starRating, @state, @parentalRating, @episodeName, @episodePart)";
  184. +        "INSERT INTO Program (idChannel, startTime, endTime, title, description, seriesNum, episodeNum, genre, originalAirDate, classification, starRating, state, parentalRating, episodeName, episodePart, icon) VALUES (@idChannel, @startTime, @endTime, @title, @description, @seriesNum, @episodeNum, @genre, @originalAirDate, @classification, @starRating, @state, @parentalRating, @episodeName, @episodePart, @icon)";
  185.  
  186.        sqlCmd.Parameters.Add("idChannel", SqlDbType.Int);
  187.        sqlCmd.Parameters.Add("startTime", SqlDbType.DateTime);
  188. @@ -2808,6 +2811,7 @@ namespace TvDatabase
  189.        sqlCmd.Parameters.Add("parentalRating", SqlDbType.Int);
  190.        sqlCmd.Parameters.Add("episodeName", SqlDbType.VarChar);
  191.        sqlCmd.Parameters.Add("episodePart", SqlDbType.VarChar);
  192. +      sqlCmd.Parameters.Add("icon", SqlDbType.VarChar);
  193.  
  194.        try
  195.        {
  196. @@ -2837,6 +2841,7 @@ namespace TvDatabase
  197.          sqlCmd.Parameters["parentalRating"].Value = prog.ParentalRating;
  198.          sqlCmd.Parameters["episodeName"].Value = prog.EpisodeName;
  199.          sqlCmd.Parameters["episodePart"].Value = prog.EpisodePart;
  200. +        sqlCmd.Parameters["icon"].Value = prog.Icon;
  201.  
  202.          try
  203.          {
  204. diff --git a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVScheduler.cs b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVScheduler.cs
  205. index b6ca596..8a1da91 100644
  206. --- a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVScheduler.cs
  207. +++ b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVScheduler.cs
  208. @@ -1291,6 +1291,7 @@ namespace TvPlugin
  209.        GUIPropertyManager.SetProperty("#TV.Scheduled.Description", String.Empty);
  210.        GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", String.Empty);
  211.        GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", String.Empty);
  212. +      GUIPropertyManager.SetProperty("#TV.Scheduled.Icon", String.Empty);
  213.  
  214.        if (prog != null)
  215.        {
  216. @@ -1307,6 +1308,7 @@ namespace TvPlugin
  217.                                         schedule.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
  218.  
  219.          GUIPropertyManager.SetProperty("#TV.Scheduled.Time", strTime);
  220. +        GUIPropertyManager.SetProperty("#TV.Scheduled.Icon", prog.Icon);
  221.  
  222.          if (schedule.IdChannel < 0)
  223.          {
  224. diff --git a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVSearch.cs b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVSearch.cs
  225. index 6e43cfd..91b6ea3 100644
  226. --- a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVSearch.cs
  227. +++ b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TVSearch.cs
  228. @@ -1290,6 +1290,7 @@ namespace TvPlugin
  229.          GUIPropertyManager.SetProperty("#TV.Search.Description", String.Empty);
  230.          GUIPropertyManager.SetProperty("#TV.Search.thumb", String.Empty);
  231.          GUIPropertyManager.SetProperty("#TV.Search.Channel", String.Empty);
  232. +        GUIPropertyManager.SetProperty("#TV.Search.Icon", String.Empty);
  233.          if (prog == null)
  234.          {
  235.            // see comment at top of method
  236. @@ -1319,6 +1320,7 @@ namespace TvPlugin
  237.        GUIPropertyManager.SetProperty("#TV.Search.Description", prog.Description);
  238.        GUIPropertyManager.SetProperty("#TV.Search.Genre", prog.Genre);
  239.        GUIPropertyManager.SetProperty("#TV.Search.Channel", prog.ReferencedChannel().DisplayName);
  240. +      GUIPropertyManager.SetProperty("#TV.Search.Icon", prog.Icon);
  241.  
  242.        // see comment at top of method
  243.        //lblProgramTitle.Label = TVUtil.GetDisplayTitle(prog);
  244. diff --git a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs
  245. index 971e9a5..96e3a94 100644
  246. --- a/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs
  247. +++ b/TvEngine3/TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs
  248. @@ -1242,6 +1242,7 @@ namespace TvPlugin
  249.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Duration", String.Empty);
  250.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.DurationMins", String.Empty);
  251.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.TimeFromNow", String.Empty);
  252. +        GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Icon", String.Empty);
  253.  
  254.          _currentStartTime = 0;
  255.          _currentEndTime = 0;
  256. @@ -1284,6 +1285,7 @@ namespace TvPlugin
  257.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.TimeFromNow", GetStartTimeFromNow(_currentProgram));
  258.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Episode", _currentProgram.EpisodeNumber);
  259.          GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.SubTitle", _currentProgram.EpisodeName);
  260. +        GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Icon", _currentProgram.Icon);
  261.  
  262.          if (_currentProgram.Classification == "")
  263.          {
  264. diff --git a/mediaportal/Core/guilib/DownloadedImage.cs b/mediaportal/Core/guilib/DownloadedImage.cs
  265. index e29e5a0..acaa310 100644
  266. --- a/mediaportal/Core/guilib/DownloadedImage.cs
  267. +++ b/mediaportal/Core/guilib/DownloadedImage.cs
  268. @@ -22,6 +22,7 @@ using System;
  269.  using System.IO;
  270.  using System.Net;
  271.  using MediaPortal.Configuration;
  272. +using System.Text.RegularExpressions;
  273.  
  274.  namespace MediaPortal.GUI.Library
  275.  {
  276. @@ -34,31 +35,56 @@ namespace MediaPortal.GUI.Library
  277.      private string _url;
  278.      private DateTime _dateDownloaded = DateTime.MinValue;
  279.      private int _cacheMinutes = 60 * 30; //30minutes
  280. +    private bool _shouldSave = false;
  281.  
  282. -    public DownloadedImage(string url)
  283. +    public DownloadedImage(string url, bool shouldsave=false)
  284.      {
  285.        URL = url;
  286.        int pos = url.LastIndexOf("/");
  287. +      
  288. +      if (shouldsave)
  289. +      {
  290. +        _shouldSave = true;
  291. +        _cacheMinutes = 60 * 60 * 24 * 3; // 3 days
  292. +      }
  293.  
  294.        _fileName = GetTempFileName();
  295.      }
  296.  
  297.      private string GetTempFileName()
  298.      {
  299. -      int x = 0;
  300. -      while (true)
  301. +      Regex rgx = new Regex(@"[^\w]+", RegexOptions.IgnoreCase);
  302. +      string tempURL = rgx.Replace(_url, "");
  303. +      if (tempURL.Length > 100)
  304. +      {
  305. +        tempURL = tempURL.Substring(tempURL.Length - 100);
  306. +      }
  307. +      string filePrefix = "MPTemp-";
  308. +      if (_shouldSave)
  309.        {
  310. -        string tempFile = Config.GetFile(Config.Dir.Thumbs, String.Format("MPTemp{0}.gif", x));
  311. -        string tempFile2 = Config.GetFile(Config.Dir.Thumbs, String.Format("MPTemp{0}.jpg", x));
  312. -        string tempFile3 = Config.GetFile(Config.Dir.Thumbs, String.Format("MPTemp{0}.bmp", x));
  313. -        if (!File.Exists(tempFile) &&
  314. -            !File.Exists(tempFile2) &&
  315. -            !File.Exists(tempFile3))
  316. +        filePrefix = @"Web\";
  317. +        string thumbspath = Config.GetSubFolder(Config.Dir.Thumbs, @"Web\");
  318. +        if (!Directory.Exists(thumbspath))
  319.          {
  320. -          return tempFile;
  321. +          Directory.CreateDirectory(Config.GetSubFolder(Config.Dir.Thumbs, @"Web\"));
  322.          }
  323. -        ++x;
  324.        }
  325. +
  326. +      foreach (string ext in new string[] { "gif", "jpg", "png", "bmp" })
  327. +      {
  328. +        string tempFile = Config.GetFile(Config.Dir.Thumbs, String.Format("{0}{1}.{2}", filePrefix, tempURL, ext));
  329. +        if (File.Exists(tempFile))
  330. +        {
  331. +          if (_dateDownloaded == DateTime.MinValue)
  332. +          {
  333. +            _dateDownloaded = DateTime.Now;
  334. +          }
  335. +          System.IO.File.SetLastWriteTimeUtc(tempFile, DateTime.UtcNow);
  336. +          return tempFile;
  337. +        }
  338. +      }
  339. +
  340. +      return Config.GetFile(Config.Dir.Thumbs, String.Format("{0}{1}.gif", filePrefix, tempURL));
  341.      }
  342.  
  343.  
  344. @@ -85,7 +111,7 @@ namespace MediaPortal.GUI.Library
  345.        get
  346.        {
  347.          TimeSpan ts = DateTime.Now - _dateDownloaded;
  348. -        if (ts.TotalSeconds > CacheTime)
  349. +        if (ts.TotalSeconds > CacheTime && (!_shouldSave || _dateDownloaded == DateTime.MinValue))
  350.          {
  351.            return true;
  352.          }
  353. @@ -126,6 +152,10 @@ namespace MediaPortal.GUI.Library
  354.              {
  355.                extension = ".jpg";
  356.              }
  357. +            if (contentType.IndexOf("png") >= 0)
  358. +            {
  359. +              extension = ".png";
  360. +            }
  361.              if (contentType.IndexOf("bmp") >= 0)
  362.              {
  363.                extension = ".bmp";
  364. diff --git a/mediaportal/Core/guilib/GUIImage.cs b/mediaportal/Core/guilib/GUIImage.cs
  365. index 08a252f..2aae4a7 100644
  366. --- a/mediaportal/Core/guilib/GUIImage.cs
  367. +++ b/mediaportal/Core/guilib/GUIImage.cs
  368. @@ -82,7 +82,8 @@ namespace MediaPortal.GUI.Library
  369.      [XMLSkin("texture", "flipY")] protected bool _flipY = false;
  370.      [XMLSkin("texture", "diffuse")] protected string _diffuseFileName = "";
  371.      [XMLSkin("texture", "overlay")] protected string _overlayFileName = "";
  372. -    [XMLSkin("texture", "mask")] protected string _maskFileName = "";
  373. +    [XMLSkin("texture", "mask")] protected string _maskFileName = "";
  374. +    [XMLSkin("texture", "save")] protected bool _websave = false; // Hint from the skin to look/save this image locally if it is downloaded
  375.      [XMLSkinElement("filtered")] protected bool _filterImage = true;
  376.      [XMLSkinElement("align")] protected Alignment _imageAlignment = Alignment.ALIGN_LEFT;
  377.      [XMLSkinElement("valign")] protected VAlignment _imageVAlignment = VAlignment.ALIGN_TOP;
  378. @@ -453,7 +454,24 @@ namespace MediaPortal.GUI.Library
  379.      {
  380.        get { return _imagePath; }
  381.        set { _imagePath = value; }
  382. +    }
  383. +
  384. +    /// <summary>
  385. +    /// Get/Set if the web image should be saved between MP sessions.
  386. +    /// </summary>
  387. +    public bool WebSave
  388. +    {
  389. +      get { return _websave; }
  390. +      set
  391. +      {
  392. +        if (_websave != value)
  393. +        {
  394. +          _websave = value;
  395. +          _reCalculate = true;
  396. +        }
  397. +      }
  398.      }
  399. +  
  400.  
  401.      /// <summary>
  402.      /// Get the transparent color.
  403. @@ -714,7 +732,7 @@ namespace MediaPortal.GUI.Library
  404.          }
  405.          else
  406.          {
  407. -          frameCount = GUITextureManager.Load(fileName, m_dwColorKey, m_iRenderWidth, _textureHeight, _shouldCache);
  408. +          frameCount = GUITextureManager.Load(fileName, m_dwColorKey, m_iRenderWidth, _textureHeight, _shouldCache, _websave);
  409.          }
  410.  
  411.          if (frameCount == 0)
  412. diff --git a/mediaportal/Core/guilib/GUITextureManager.cs b/mediaportal/Core/guilib/GUITextureManager.cs
  413. index 45fdc68..1a81833 100644
  414. --- a/mediaportal/Core/guilib/GUITextureManager.cs
  415. +++ b/mediaportal/Core/guilib/GUITextureManager.cs
  416. @@ -88,6 +88,32 @@ namespace MediaPortal.GUI.Library
  417.              {
  418.              }
  419.            }
  420. +        }
  421. +
  422. +        
  423. +        files = null;
  424. +
  425. +        try
  426. +        {
  427. +          files = Directory.GetFiles(Config.GetFolder(Config.Dir.Thumbs), @"Web\*.*");
  428. +        }
  429. +        catch { }
  430. +
  431. +        if (files != null)
  432. +        {
  433. +          foreach (string file in files)
  434. +          {
  435. +            try
  436. +            {
  437. +              if ((DateTime.Now - File.GetLastWriteTime(file)).TotalDays >= 3) // Delete web cached files untouched for 3 or more days
  438. +              {
  439. +                File.Delete(file);
  440. +              }
  441. +            }
  442. +            catch (Exception)
  443. +            {
  444. +            }
  445. +          }
  446.          }
  447.        }
  448.      }
  449. @@ -147,7 +173,7 @@ namespace MediaPortal.GUI.Library
  450.        return result;
  451.      }
  452.  
  453. -    private static string GetFileName(string fileName)
  454. +    private static string GetFileName(string fileName, bool shouldsave = false)
  455.      {
  456.        if (fileName.Length == 0)
  457.        {
  458. @@ -157,13 +183,13 @@ namespace MediaPortal.GUI.Library
  459.        {
  460.          return "";
  461.        }
  462. -      string lowerFileName = fileName.ToLowerInvariant().Trim();
  463. -      if (lowerFileName.IndexOf(@"http:") >= 0)
  464. +      string lowerFileName = fileName.ToLowerInvariant().Trim();
  465. +      if (lowerFileName.IndexOf(@"http:") >= 0 || lowerFileName.IndexOf(@"https:") >= 0)
  466.        {
  467.          DownloadedImage image;
  468.          if (!_cacheDownload.TryGetValue(lowerFileName, out image))
  469.          {
  470. -          image = new DownloadedImage(fileName);
  471. +          image = new DownloadedImage(fileName, shouldsave);
  472.            _cacheDownload[lowerFileName] = image;
  473.          }
  474.  
  475. @@ -190,9 +216,9 @@ namespace MediaPortal.GUI.Library
  476.        return Load(fileNameOrg, lColorKey, iMaxWidth, iMaxHeight, false);
  477.      }
  478.  
  479. -    public static int Load(string fileNameOrg, long lColorKey, int iMaxWidth, int iMaxHeight, bool persistent)
  480. +    public static int Load(string fileNameOrg, long lColorKey, int iMaxWidth, int iMaxHeight, bool persistent, bool shouldsave=false)
  481.      {
  482. -      string fileName = GetFileName(fileNameOrg);
  483. +      string fileName = GetFileName(fileNameOrg, shouldsave);
  484.        string cacheKey = fileName.ToLowerInvariant();
  485.        if (String.IsNullOrEmpty(fileName))
  486.        {
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top