From 158b6e5cabe26f7fc8001f210976e72c8c5bd514 Mon Sep 17 00:00:00 2001 From: Robert McNamara Date: Sat, 16 Jul 2011 20:22:12 -0700 Subject: [PATCH] Metadata: Add some more convenience methods to create Metadata XML simply. Creating exportable .mxml content is now as simple as (after including metadatacommon.h): QDomDocument doc = CreateMetadataXML(pginfo); You can do what you like with the result, but the metadata download classes search for a file in the same dir as the file being worked on (as defined in lookup->Set/GetFilename) with the same filename and a suffix of .mxml. So, still missing: * Decide where/when to create .mxml files for recordings (at which point it would work to drop the result in your video dir the mythvideo scanner will pick up the file + mxml and parse the metadata) * Add some code to dynamically reimport files from offline/portable storage groups into recordings (Chris P'm has mentioned he's written such code) * Add a MetadataFactory to the theoretical recording import class and tell it to do a lookup on the newly imported file (easy peasy: MetadataFactory *factory(this); factory->AddLookup(pginfo);) and listen for the result event that provides you the fully looked up info which you can assign to your programinfo as you see fit. --- mythtv/libs/libmythbase/mythversion.h | 2 +- .../libs/libmythmetadata/metadatacommon.cpp | 23 +++++++++++++++++++ mythtv/libs/libmythmetadata/metadatacommon.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index 5bb39b0add0..dd53342f3f4 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in API changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods used by plug-ins. -#define MYTH_BINARY_VERSION "0.25.20110715-1" +#define MYTH_BINARY_VERSION "0.25.20110716-1" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythmetadata/metadatacommon.cpp b/mythtv/libs/libmythmetadata/metadatacommon.cpp index 9b657092e06..40bf2205f2d 100644 --- a/mythtv/libs/libmythmetadata/metadatacommon.cpp +++ b/mythtv/libs/libmythmetadata/metadatacommon.cpp @@ -460,6 +460,29 @@ QDomDocument CreateMetadataXML(MetadataLookupList list) return doc; } +QDomDocument CreateMetadataXML(MetadataLookup *lookup) +{ + QDomDocument doc("MythMetadataXML"); + + QDomElement root = doc.createElement("metadata"); + doc.appendChild(root); + + CreateMetadataXMLItem(lookup, root, doc); + + return doc; +} + +QDomDocument CreateMetadataXML(ProgramInfo *pginfo) +{ + QDomDocument doc("MythMetadataXML"); + + MetadataLookup *lookup = LookupFromProgramInfo(pginfo); + if (lookup) + doc = CreateMetadataXML(lookup); + + return doc; +} + void CreateMetadataXMLItem(MetadataLookup *lookup, QDomElement placetoadd, QDomDocument docroot) diff --git a/mythtv/libs/libmythmetadata/metadatacommon.h b/mythtv/libs/libmythmetadata/metadatacommon.h index 344bfb9eca8..24e6093b7fb 100644 --- a/mythtv/libs/libmythmetadata/metadatacommon.h +++ b/mythtv/libs/libmythmetadata/metadatacommon.h @@ -439,6 +439,8 @@ Q_DECLARE_METATYPE(MetadataLookup*) typedef QList MetadataLookupList; META_PUBLIC QDomDocument CreateMetadataXML(MetadataLookupList list); +META_PUBLIC QDomDocument CreateMetadataXML(MetadataLookup *lookup); +META_PUBLIC QDomDocument CreateMetadataXML(ProgramInfo *pginfo); META_PUBLIC void CreateMetadataXMLItem(MetadataLookup *lookup, QDomElement placetoadd,