XMMImporter Plugin/General MediaModule -- Help Needed (1 Viewer)

Hesse

Portal Pro
August 8, 2006
110
0
I've decided to take the plunge and try to learn some C# so that I can help write some plugins and maybe even one day help with MediaPortal core. In my first attempt at writing a plugin, I thought I'd start with something that would be useful to me, an XMMImporter plugin that does everything I need.

GOAL:
Recreate most (if not all) of the functionality of the XMM Database Importer plugin that exists for Meedio (http://www.meedio.com/forum/about17774.html&highlight=xmm).

FEATURES:

Short Term:
1) Baseline target is to import necessary information from XMM into the Video library of MP for general purpose movie viewing.

Longer Term
2) Import all information into a general purpose database. Ability to import multiple files into different databases so that multiple general purpose databases can exist. I have this functionality in Meedio currently. I have a movie database and a homemovie database, each with their own views, etc. I'm missing this currently in MP, but hopefully I can address that with my plugin.

3) Ability to create standard views of data based on any of the information in the generic database. This would be very powerful if I could do that. Ability for different sorting methods and display methods (such as sorting all items by index for quick viewing alphabetically)

3) General purpose MediaModule which can access the databases and display the data based on the views setup.

4) Write back information into the XMM database (watchedstatus, personalrating, etc).

MOTIVATION
I am aware of the MyDVDs plugin that attempts to import data from XMM, but I didn't have much luck with it (crashes, not flexible, etc). It requires you to export to a CSV to import. I'd rather just have an option which can directly read/write to the XMM database. Also, I have a collection of homemovies that do not fit the generic movie mold and having custom views is important for that. Maybe some of this is planned for the MP core, but I didn't see a whole lot except for one thread about databases.

So, I don't know C# or any other programming language for that matter except for MATLAB :). So it is going to be a learning curve for sure. I've got the plugin skeleton running and compiling so that it displays in the MP plugin list (but as a process plugin for some reason). I can also access the XMM MS Access database and retrieve all of the information into class array.

I thought that would be the hard part, but I'm actually stuck right now on accessing the SQLlite MP databases. I'm getting some errors that I will put in the next post so that I can keep this post for future updates.

The bottom line is I'm probably over my head right now and I'll definately need some help when it comes time to creating the XML screen/template files, etc. So I'll be asking for help. I'd appreciate it if some of you gurus would stop by this thread every once in a while in case I run into some issues.
 

Hesse

Portal Pro
August 8, 2006
110
0
SQLite Problems

I'm having some issues with SQLite and my class. Here is a portion of a class that I wrote called VIDEO_DB which is supposed to be the class which can access the SQLite DB. I have a separate test block of code which attempts to create an instance of this class and open the database as shown.

However, when I run the code, I get an exception that I can't understand why its occurring. When I run in debug mode and step through, it bombs on the line

m_db = new SQLiteClient("VideoDatabaseV5.db3");

with the exception

{"Object reference not set to an instance of an object."}

I thought that I was setting the instance there?? Can anyone help me out?

Regards,

Jesse



---- VIDEO_DB class -----
namespace GUIXMM
{
/// <summary>
/// Class VIDEO_DB description
/// </summary>
public class VIDEO_DB
{
public bool op_update = false;
public bool op_copy = false;
public bool op_image = false;
public bool op_format = true;
public bool op_actorInfo = false;
public int op_actorNum = 1;
public bool stopRebuild = false;
public ProgressBar progressBar = null;
public Label label1 = null;
public Label label2 = null;

//private static SQLiteClient m_db = null;
public SQLiteClient m_db = null;
//SQLiteClient m_db;
//IDbConnection dbcon = null;
//private static string m_db = null;

private bool dbExists;

//------------------------------------------------------------------------------
// Open DB and initialize tables
//------------------------------------------------------------------------------
public void Open()
{
//SQLiteClient m_db;
//SQLiteResultSet results;
//SQLiteClient m_db = null;

try
{
// Open database
MessageBox.Show("Open DB");
//System.IO.Directory.CreateDirectory("database");
//dbExists = System.IO.File.Exists(@"database\VideoDatabaseV5.db3");

string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\";
string database = fullpath + "database\\VideoDatabaseV5.db3";
dbExists = System.IO.File.Exists(database);

Console.WriteLine("dBExists: " + dbExists.ToString());

//m_db = new SQLiteClient("test.db");
m_db = new SQLiteClient("VideoDatabaseV5.db3");
//m_db = new SQLiteClient(@"database\VideoDatabaseV5.db3");
//m_db = new SQLiteClient(database);


ArrayList tables = m_db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'");
foreach (string tableName in tables)
{
Console.WriteLine("\t" + tableName);
}



if (!dbExists)
{
Console.WriteLine("DB does not exist, creating tables.");
CreateTables();
}
}
catch (SQLiteException ex)
{
Console.WriteLine("Fatal error: {0}", ex.Message);
Log.Write("XMMdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
}
}


--- Test Function to create instance of VIDEO_DB class and open DB ----
private void button_debug_VIDEO_DB_Click(object sender, EventArgs e)
{
string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\";

string database = fullpath + "database\\VideoDatabaseV5.db3";
//MessageBox.Show(database);

if (File.Exists(database))
{
MessageBox.Show("File: " + database + " exists");
}
else
{
MessageBox.Show("File: " + database + "was not found.");
}

VIDEO_DB myVIDEO_DB = new VIDEO_DB();
myVIDEO_DB.Open();

}
 

Users who are viewing this thread

Top Bottom