Plugin: RARFileSource (A rar filter) (1 Viewer)

GSteele

Portal Pro
April 6, 2006
74
0
Hi,
Same issue here with v 1.3 final.

Is it related to it being an mpei and something like if the 0.5 version isn't flagged as compatible with 1.3 in the package then I think MP disables the plug in.
Has anyone tried modifying the package? I'm not sure how but I'm guessing its do-able as most mp config runs off xml files.
 

1stdead

Portal Pro
February 1, 2008
1,089
139
Copenhagen
Home Country
Denmark Denmark
Ok, trying once again.. You won't get this to work with 1.3 as there might have been some changes in MP - at least that was my findings when testing it. So if any developer could look through this code, we might get it to work again.


I updated it to work properly and added support for mp4, BUT there's currently a bug in the code adding/removing the rar extensions from mediaportal.xml.. I couldn't locate that. Perhaps someone could help?

Code:
//css_reference "MpeCore.dll";
//css_reference "Utils.dll";
 
using MpeCore.Classes;
using MpeCore;
using System.Diagnostics;
using System;
using MediaPortal.Profile;
 
	public class Script
	{
		public static void Main(PackageClass packageClass, ActionItem actionItem)
		{
					ProcessStartInfo psi = new ProcessStartInfo();
			psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System);
					psi.FileName = "cmd.exe";
			psi.Arguments = "/c regsvr32 /s \"" + MpeInstaller.TransformInRealPath(@"%Base%\RARFileSource.ax") + "\"";		psi.Verb = "runas";
			psi.CreateNoWindow = true;
			psi.WindowStyle = ProcessWindowStyle.Hidden;
			psi.ErrorDialog = false;
			try
			{
				Process p = System.Diagnostics.Process.Start(psi);
				p.WaitForExit(10000);
				addVideoExtension(".rar");
			}
			catch
			{
 
			}
		}
 
		// add the extension
		static bool addVideoExtension(string extension)
		{
				using (MediaPortal.Profile.Settings xmlwriter = new MPSettings())
				{
					  string currValue = xmlwriter.GetValue("movies", "extensions");
					  if(!currValue.ToLower().Contains(extension))
					  {
							  xmlwriter.SetValue("movies", "extensions", currValue + "," + extension);
							  MediaPortal.Profile.Settings.SaveCache();
							  return true;
					  }
				}
			  return false;
		}
	}

Code:
//css_reference "Utils.dll";
 
using MpeCore.Classes;
using MpeCore;
using System.Diagnostics;
using System;
using System.IO;
using MediaPortal.Profile;
using System.Windows.Forms;
 
	public class Script
	{
		public static void Main(PackageClass packageClass, UnInstallItem actionItem)
		{
			string rarfilter = MpeInstaller.TransformInRealPath(@"%Base%\RARFileSource.ax");
			ProcessStartInfo psi = new ProcessStartInfo();
			psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System);
			psi.FileName = "cmd.exe";
			psi.Arguments = "/c regsvr32 /s /u \"" + rarfilter + "\"";
			psi.Verb = "runas";
			psi.CreateNoWindow = true;
			psi.WindowStyle = ProcessWindowStyle.Hidden;
			psi.ErrorDialog = false;
			try
			{
				Process p = System.Diagnostics.Process.Start(psi);
				p.WaitForExit(10000);
				if (File.Exists(rarfilter))
				  File.Delete(rarfilter );
				  removeVideoExtension(".rar");
			}
			catch
			{
			}
		}
 
		// remove the extension
		static bool removeVideoExtension(string extension)
		{
				using (MediaPortal.Profile.Settings xmlwriter = new MPSettings())
				{
					  string currValue = xmlwriter.GetValue("movies", "extensions");
					  if(currValue.ToLower().Contains(extension))
					  {
				  if (MessageBox.Show("Would you like to remove the .rar Extension as a Video Extension?", "Remove Extension", MessageBoxButtons.YesNo)
						== DialogResult.Yes)
				{
						xmlwriter.SetValue("movies", "extensions", currValue.Replace("," + extension, ""));
									  MediaPortal.Profile.Settings.SaveCache();
									  return true;
					  }
 
					  }
				}
			  return false;
		}

The code is above. Please someone help, so that i can push a fix out.
 

Users who are viewing this thread

Top Bottom