Index: mythtv/programs/mythfrontend/playbackbox.cpp
===================================================================
--- mythtv/programs/mythfrontend/playbackbox.cpp	(revision 19769)
+++ mythtv/programs/mythfrontend/playbackbox.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "mythdirs.h"
 #include "mythcontext.h"
 #include "mythdbcon.h"
+#include "mythdb.h"
 #include "mythverbose.h"
 #include "programinfo.h"
 #include "scheduledrecording.h"
@@ -1554,6 +1555,16 @@
     stop(pginfo);
 }
 
+void PlaybackBox::exportMVSelected()
+{
+    ProgramInfo *pginfo = CurrentItem();
+                
+    if (!pginfo)
+        return;  
+                    
+    mvexport(pginfo);
+}
+
 void PlaybackBox::deleteSelected(MythUIButtonListItem *item)
 {
     if (!item)
@@ -1813,6 +1824,163 @@
     RemoteStopRecording(rec);
 }
 
+void PlaybackBox::mvexport(ProgramInfo *rec)
+{
+    // User Rating Adjustment
+    QString exportRating = QString::number((int)((rec->stars * 10.0) + 0.5));
+
+    // Stuff necessary to perform the copy command
+
+    QString copyFrom = rec->GetPlaybackURL(false, true);
+    QString extension;
+
+    QRegExp rx(".*\\.(\\w+)$");
+    int pos = rx.indexIn(copyFrom);
+    if (pos > -1)
+    {
+        extension = rx.cap(1);
+    }
+    else
+    {
+        extension = "";
+    }
+
+    QString baseMVDir = gContext->GetSetting("VideoStartupDir");
+    QString MVDirFormat = gContext->GetSetting("TVExportDirFormat",
+                              "Television/%TITLE%/");
+    if (!MVDirFormat.isEmpty())
+    {
+         MVDirFormat.replace(QRegExp("%FILE%"), rec->GetRecordBasename(true));
+         MVDirFormat.replace(QRegExp("%TITLE%"), rec->title);
+         MVDirFormat.replace(QRegExp("%SUBTITLE%"), rec->subtitle);
+         MVDirFormat.replace(QRegExp("%DESCRIPTION%"), rec->description);
+         MVDirFormat.replace(QRegExp("%HOSTNAME%"), rec->hostname);
+         MVDirFormat.replace(QRegExp("%CATEGORY%"), rec->category);
+         MVDirFormat.replace(QRegExp("%RECGROUP%"), rec->recgroup);
+         MVDirFormat.replace(QRegExp("%PLAYGROUP%"), rec->playgroup);
+         MVDirFormat.replace(QRegExp("%CHANID%"), rec->chanid);
+         MVDirFormat.replace(QRegExp("%STARTTIME%"),
+                         rec->recstartts.toString("yyyyMMddhhmmss"));
+         MVDirFormat.replace(QRegExp("%ENDTIME%"),
+                         rec->recendts.toString("yyyyMMddhhmmss"));
+         MVDirFormat.replace(QRegExp("%STARTTIMEISO%"),
+                         rec->recstartts.toString(Qt::ISODate));
+         MVDirFormat.replace(QRegExp("%ENDTIMEISO%"),
+                         rec->recendts.toString(Qt::ISODate));
+         MVDirFormat.replace(QRegExp("%PROGSTART%"),
+                         rec->startts.toString("yyyyMMddhhmmss"));
+         MVDirFormat.replace(QRegExp("%PROGEND%"),
+                         rec->endts.toString("yyyyMMddhhmmss"));
+         MVDirFormat.replace(QRegExp("%PROGSTARTISO%"),
+                         rec->startts.toString(Qt::ISODate));
+         MVDirFormat.replace(QRegExp("%PROGENDISO%"),
+                         rec->endts.toString(Qt::ISODate));
+
+    }
+
+    QString MVFileFormat = gContext->GetSetting("TVExportFileFormat",
+                              "%TITLE% - %SUBTITLE%");
+    if (!MVFileFormat.isEmpty())
+    {
+         MVFileFormat.replace(QRegExp("%FILE%"), rec->GetRecordBasename(true));
+         MVFileFormat.replace(QRegExp("%TITLE%"), rec->title);
+         MVFileFormat.replace(QRegExp("%SUBTITLE%"), rec->subtitle);
+         MVFileFormat.replace(QRegExp("%DESCRIPTION%"), rec->description);
+         MVFileFormat.replace(QRegExp("%HOSTNAME%"), rec->hostname);
+         MVFileFormat.replace(QRegExp("%CATEGORY%"), rec->category);
+         MVFileFormat.replace(QRegExp("%RECGROUP%"), rec->recgroup);
+         MVFileFormat.replace(QRegExp("%PLAYGROUP%"), rec->playgroup);
+         MVFileFormat.replace(QRegExp("%CHANID%"), rec->chanid);
+         MVFileFormat.replace(QRegExp("%STARTTIME%"),
+                         rec->recstartts.toString("yyyyMMddhhmmss"));
+         MVFileFormat.replace(QRegExp("%ENDTIME%"),
+                         rec->recendts.toString("yyyyMMddhhmmss"));
+         MVFileFormat.replace(QRegExp("%STARTTIMEISO%"),
+                         rec->recstartts.toString(Qt::ISODate));
+         MVFileFormat.replace(QRegExp("%ENDTIMEISO%"),
+                         rec->recendts.toString(Qt::ISODate));
+         MVFileFormat.replace(QRegExp("%PROGSTART%"),
+                         rec->startts.toString("yyyyMMddhhmmss"));
+         MVFileFormat.replace(QRegExp("%PROGEND%"),
+                         rec->endts.toString("yyyyMMddhhmmss"));
+         MVFileFormat.replace(QRegExp("%PROGSTARTISO%"),
+                         rec->startts.toString(Qt::ISODate));
+         MVFileFormat.replace(QRegExp("%PROGENDISO%"),
+                         rec->endts.toString(Qt::ISODate));
+
+    }
+
+    QString copyToDir = QString("%1/%2/").arg(baseMVDir).arg(MVDirFormat);
+    QString copyToFile = QString("%1/%2.%3").arg(copyToDir)
+                             .arg(MVFileFormat).arg(extension);
+
+    // File and Directory Definitions
+
+    QFile fromFile(copyFrom);
+    QDir toDir(copyToDir);
+    QFile toFile(copyToFile);
+
+    if (!toDir.exists())
+    {
+        // Attempt to create path to export point.
+        toDir.mkpath(copyToDir);
+        toDir.mkdir(copyToDir);
+        if (!toDir.exists())
+        {
+            VERBOSE(VB_IMPORTANT, QString("Unable to create directory %1! "
+                                          "Please ensure the preceding path "
+                                          "exists and is writeable.").arg(copyToDir));    
+            return;
+        }
+    }
+
+    VERBOSE(VB_IMPORTANT, QString("Exporting to MythVideo:\n "
+                                   "Title: %1\n "
+                                   "Subtitle: %2\n "
+                                   "Description: %3\n "
+                                   "User Rating: %4\n "
+                                   "Year: %5\n "
+                                   "Length: %6 Minutes\n "
+                                   "Copying From File: %7\n "
+                                   "Copying to File: %8 ").arg(rec->title).arg(rec->subtitle).arg(rec->description).arg(exportRating).arg(rec->year).arg(rec->lenMins).arg(copyFrom).arg(copyToFile));
+
+    long long int bytesCopied = copy(toFile,fromFile);
+
+    if (bytesCopied != -1)
+    {
+        // Prepare the DB Query 
+
+        MSqlQuery query(MSqlQuery::InitCon());
+
+        query.prepare("INSERT INTO videometadata (title,plot,year,"
+                          "userrating,length,filename,showlevel,inetref, "
+                          "browse) VALUES (:TITLE, :PLOT, :YEAR, :USERRATING, "
+                          ":LENGTH, :FILENAME, :SHOWLEVEL, :INETREF, :BROWSE)");
+
+        query.bindValue(":TITLE", MVFileFormat);
+        query.bindValue(":PLOT", rec->description);
+        query.bindValue(":YEAR", rec->year);
+        query.bindValue(":USERRATING", exportRating);
+        query.bindValue(":LENGTH", rec->lenMins);
+        query.bindValue(":FILENAME", copyToFile);
+        query.bindValue(":SHOWLEVEL", 1);
+        query.bindValue(":INETREF", 0);
+        query.bindValue(":BROWSE", 1);
+
+        if (!query.exec() || !query.isActive())
+        {
+            MythDB::DBError("video metadata update", query);
+            return;
+        }
+
+        VERBOSE(VB_IMPORTANT, QString("Copy succeeded, %1 bytes copied.").arg(bytesCopied));
+    }
+    else
+    {
+        VERBOSE(VB_IMPORTANT, QString("Copy unsuccessful, check all permissions."));
+    }
+}
+
 bool PlaybackBox::doRemove(ProgramInfo *rec, bool forgetHistory,
                            bool forceMetadataDelete)
 {
@@ -1867,6 +2035,47 @@
         showActionPopup(pginfo);
 }
 
+void PlaybackBox::showExportPopup(ProgramInfo *program)
+{
+    if (m_popupMenu)
+        return;
+
+    QString label = tr("Are you sure you want to export:");
+
+    m_expItem = CurrentItem();
+    popupString(m_expItem, label);
+
+    m_popupMenu = new MythDialogBox(label, m_popupStack, "pbbmainmenupopup");
+
+    connect(m_popupMenu, SIGNAL(Exiting()), SLOT(popupClosed()));
+
+    if (m_popupMenu->Create())
+        m_popupStack->AddScreen(m_popupMenu);
+    else
+    {
+        delete m_popupMenu;
+        m_popupMenu = NULL;
+    }
+
+    m_popupMenu->SetReturnEvent(this, "slotmenu");
+
+    m_freeSpaceNeedsUpdate = true;
+    QString tmpmessage;
+    const char *tmpslot = NULL;
+
+    if (program->IsSameProgram(*program))
+        {
+        tmpmessage = tr("Yes, Export to MythVideo");
+        tmpslot = SLOT(doMVExport());
+        m_popupMenu->AddButton(tmpmessage, tmpslot);
+
+        tmpmessage = tr("No, I don't want to Export");
+        tmpslot = SLOT(noExport());
+        m_popupMenu->AddButton(tmpmessage, tmpslot);
+        }
+}
+
+
 void PlaybackBox::showDeletePopup(ProgramInfo *program, deletePopupType types)
 {
     if (m_popupMenu)
@@ -2512,6 +2721,10 @@
                            true);
     m_popupMenu->AddButton(tr("Job Options"), SLOT(showJobPopup()), true);
 
+    QString MVlocation = FindPluginName("mythvideo");
+    if (QFile(MVlocation).exists())
+        m_popupMenu->AddButton(tr("Export to MythVideo"), SLOT(askMVExport()));
+
     if (!(m_player && m_player->IsSameProgram(0, pginfo)))
     {
         if (pginfo->recgroup == "Deleted")
@@ -2608,6 +2821,12 @@
     stop(pginfo);
 }
 
+void PlaybackBox::doMVExport(void)
+{
+    ProgramInfo *pginfo = CurrentItem();
+    mvexport(pginfo);
+}
+
 void PlaybackBox::showProgramDetails()
 {
    ProgramInfo *pginfo = CurrentItem();
@@ -2746,6 +2965,13 @@
     }
 }
 
+void PlaybackBox::askMVExport(ProgramInfo *pginfo)
+{
+    if (!pginfo)
+        pginfo = CurrentItem();
+    showExportPopup(pginfo);
+}
+
 void PlaybackBox::askDelete(ProgramInfo *pginfo)
 {
     if (!pginfo)
Index: mythtv/programs/mythfrontend/playbackbox.h
===================================================================
--- mythtv/programs/mythfrontend/playbackbox.h	(revision 19769)
+++ mythtv/programs/mythfrontend/playbackbox.h	(working copy)
@@ -137,6 +137,7 @@
     void upcoming();
     void details();
     void stopSelected();
+    void exportMVSelected();
     void showMenu();
     void showActionsSelected();
     void showRecGroupChanger();
@@ -170,6 +171,8 @@
 
     void askStop();
     void doStop();
+    void askMVExport(ProgramInfo *pginfo = NULL);
+    void doMVExport();
 
     void doEditScheduled();
     void doAllowRerecord();
@@ -260,6 +263,7 @@
 
     bool play(ProgramInfo *rec, bool inPlaylist = false);
     void stop(ProgramInfo *);
+    void mvexport(ProgramInfo *);
     void remove(ProgramInfo *);
     void showActions(ProgramInfo *);
     ProgramInfo *CurrentItem(void);
@@ -279,6 +283,7 @@
 
     bool doRemove(ProgramInfo *, bool forgetHistory, bool forceMetadataDelete);
     void showDeletePopup(ProgramInfo *, deletePopupType);
+    void showExportPopup(ProgramInfo *);
     void showActionPopup(ProgramInfo *program);
     void showFileNotFoundActionPopup(ProgramInfo *program);
     void popupString(ProgramInfo *program, QString &message);
@@ -376,6 +381,8 @@
     // Other state
     /// Program currently selected for deletion
     ProgramInfo *m_delItem;
+    /// Program currently selected for export
+    ProgramInfo *m_expItem;
     /// Program currently selected during an update
     ProgramInfo *m_currentItem;
     /// Group currently selected
Index: mythplugins/mythvideo/mythvideo/globalsettings.cpp
===================================================================
--- mythplugins/mythvideo/mythvideo/globalsettings.cpp	(revision 19769)
+++ mythplugins/mythvideo/mythvideo/globalsettings.cpp	(working copy)
@@ -236,6 +236,28 @@
     return gc;
 }
 
+HostLineEdit *TVExportDirectoryFormat()
+{
+    HostLineEdit *gc = new HostLineEdit("TVExportDirFormat");
+    gc->setLabel(QObject::tr("TV Export Directory Format"));
+    gc->setValue(DEFAULT_TVEXPORTDIRFORMAT);
+    gc->setHelpText(QObject::tr("Directory format for Recording export "
+                    "to MythVideo, using User Job Style Variables. EX: "
+                    "Television/%CATEGORY%/%TITLE%"));
+    return gc;
+}
+
+HostLineEdit *TVExportFileFormat()
+{
+    HostLineEdit *gc = new HostLineEdit("TVExportFileFormat");
+    gc->setLabel(QObject::tr("TV Export File Format"));
+    gc->setValue(DEFAULT_TVEXPORTFILEFORMAT);
+    gc->setHelpText(QObject::tr("File Format for Recording export "
+                    "to MythVideo, using User Job Style Variables. EX: "
+                    "%TITLE% - %SUBTITLE% (%STARTTIMEISO%)"));
+    return gc;
+}
+
 HostLineEdit *VideoArtworkDirectory()
 {
     HostLineEdit *gc = new HostLineEdit("VideoArtworkDir");
@@ -683,6 +704,8 @@
     page1->addChild(VideoStartupDirectory());
     page1->addChild(VideoArtworkDirectory());
     page1->addChild(VideoDefaultView());
+    page1->addChild(TVExportDirectoryFormat());
+    page1->addChild(TVExportFileFormat());
 
     VConfigPage page2(pages, false);
     page2->addChild(VideoListUnknownFiletypes());
Index: mythplugins/mythvideo/mythvideo/globals.cpp
===================================================================
--- mythplugins/mythvideo/mythvideo/globals.cpp	(revision 19769)
+++ mythplugins/mythvideo/mythvideo/globals.cpp	(working copy)
@@ -28,6 +28,10 @@
 
 #ifdef Q_WS_MACX
 const QString DEFAULT_VIDEOSTARTUP_DIR = QDir::homePath() + "/Movies";
+const QString DEFAULT_TVEXPORTDIRFORMAT = "Television/%TITLE%";
+const QString DEFAULT_TVEXPORTFILEFORMAT = "%TITLE% - %SUBTITLE%";
 #else
 const QString DEFAULT_VIDEOSTARTUP_DIR = "/share/Movies/dvd";
+const QString DEFAULT_TVEXPORTDIRFORMAT = "Television/%TITLE%";
+const QString DEFAULT_TVEXPORTFILEFORMAT = "%TITLE% - %SUBTITLE%";
 #endif
Index: mythplugins/mythvideo/mythvideo/globals.h
===================================================================
--- mythplugins/mythvideo/mythvideo/globals.h	(revision 19769)
+++ mythplugins/mythvideo/mythvideo/globals.h	(working copy)
@@ -25,5 +25,7 @@
 extern const QString JUMP_VIDEO_DEFAULT;
 
 extern const QString DEFAULT_VIDEOSTARTUP_DIR;
+extern const QString DEFAULT_TVEXPORTDIRFORMAT;
+extern const QString DEFAULT_TVEXPORTFILEFORMAT;
 
 #endif // GLOBALS_H_
