Seitenhierarchie

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.36
            Releasenews | Download
 MediaPortal 2.5
            Releasenews | Download



Show message box

//css_reference "MpeCore.dll";

using MpeCore.Classes;
using MpeCore;
using System.Windows.Forms;

public class Script
{
  public static void Main(PackageClass packageClass, ActionItem actionItem)
  {
    if (!packageClass.Silent)
    {
      MessageBox.Show("Message");
    }

    return;
  }
}

Deleting a File

//css_reference "MpeCore.dll";

using MpeCore.Classes;
using MpeCore;
using System.IO;

public class Script
{
  public static void Main(PackageClass packageClass, ActionItem actionItem)
  {
    string setupExe = Path.Combine(
      MpeInstaller.TransformInRealPath("%Base%"), "aMPedSetup.exe");

    try
    {
      if (File.Exists(setupExe))
        File.Delete(setupExe);
    }
    catch {}

    return;
  }
}

Set default Skin

//css_reference "MpeCore.dll";
//css_reference "Utils.dll";

using MpeCore.Classes;
using MpeCore;
using MediaPortal.Profile;

public class Script
{
  public static void Main(PackageClass packageClass, ActionItem actionItem)
  {
    using (MediaPortal.Profile.Settings xmlwriter = new MPSettings())
    {
      xmlwriter.SetValue("skin", "name", "BleazleWide");
    }

    MediaPortal.Profile.Settings.SaveCache();

    return;
  }
}

Install MovingPictures Scraper Script

This example uses a plugins API and illustrates how you can reference and load externals libraries.

//css_reference "MpeCore.dll";
//css_reference "Plugins\\Windows\\Cornerstone.dll";
//css_reference "Plugins\\Windows\\MovingPictures.dll";

using MediaPortal.Plugins.MovingPictures;
using MediaPortal.Plugins.MovingPictures.Database;
using MediaPortal.Plugins.MovingPictures.DataProviders;
using MpeCore.Classes;
using MpeCore;
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

public class Script
{
  public static void Main(PackageClass packageClass, ActionItem actionItem)
  {
    try
    {
      // Load Assemblies
      Assembly.LoadFrom(Path.Combine(MpeInstaller.TransformInRealPath("%Plugins%"), @"Windows\MovingPictures.dll"));

      // Instal Scraper Script
      string xmlFile = Path.Combine(MpeInstaller.TransformInRealPath("%Config%"), @"IMDb+\IMDb+.Scraper.SVN.xml");

      // Check if already installed.
      if (!IsScraperInstalled())
      {
        if (ScraperScriptInstallation(xmlFile))
        {
          // Make script first priority
          SetScriptPositioning();
        }
      }
      File.Delete(xmlFile);      
    }
    catch {}
    
    return;
  }

  static bool ScraperScriptInstallation(string xmlFile)
  {
    // Grab the contents of the scraper script file
    StreamReader reader = new StreamReader(xmlFile);
    string script = reader.ReadToEnd();
    reader.Close();

    // Add it to the scraper script manager
    DataProviderManager.AddSourceResult addResult = MovingPicturesCore.DataProviderManager.AddSource(typeof(ScriptableProvider), script, true);

    if (addResult == DataProviderManager.AddSourceResult.SUCCESS_REPLACED)
    {    
      return true;
    }
    else if (addResult == DataProviderManager.AddSourceResult.SUCCESS)
    {
      // Scraper script has been added successfully    
      return true;
    }
    else
    {
      // Scraper installation failed
      return false;
    }
  }
 
  static void SetScriptPositioning()
  {    
    DBSourceInfo source = DBSourceInfo.GetFromScriptID(314159265);    
    if (source == null) return;

    // shift all enabled 'movie detail' sources down by one
    foreach (DBSourceInfo enabledSource in DBSourceInfo.GetAll())
    {
      if (enabledSource.DetailsPriority > -1)
      {
        enabledSource.DetailsPriority++;
        enabledSource.Commit();
      }
    }

    // now set highest priority to the IMDb+ source
    source.SetPriority(DataType.DETAILS, 0);
    source.Commit();

    // set IMDb+ cover source higher than default IMDb source
    DBSourceInfo IMDbSource = DBSourceInfo.GetFromScriptID(874902);
    if (IMDbSource != null && IMDbSource.CoverPriority != null)
    {
      int coverPriority = (int)IMDbSource.CoverPriority;
      // shift down the rest, leave anything else in place
      foreach (DBSourceInfo enabledSource in DBSourceInfo.GetAll())
      {
        if (enabledSource.CoverPriority >= coverPriority)
        {
          enabledSource.CoverPriority++;
          enabledSource.Commit();
        }
      }

      // now replace IMDb cover priority with IMDb+ source
      source.SetPriority(DataType.COVERS, coverPriority);
      source.Commit();
    }
  }
 
  static bool IsScraperInstalled()
  {
    return DBSourceInfo.GetFromScriptID(314159265) != null;
  }
}

   

 

This page has no comments.