Hi,
I've been having a problem with MythVideo and the way it stores filenames in the Database.
I have 1 machine that acts as a nfs server and another frontend that mounts the Video directory from that nfs server. On the nfs server I occasionally run a frontend that accesses the disk 'direct' (and via a different path)
Although MythVideo allows you to specify a VideoStartupDir, the filenames stored in videometadata are absolute, so if I do a video scan on one machine I can't browse them on the other.
The attached patch makes VideoScan store the paths relative to VideoStartupDir. It also tweaks the playVideo methods to prepend VideoStartupDir before invoking the player.
The existing code seems to have some support for multiple VideoStartupDirs, separated by ':', I've removed this, since it would then mean each frontend would need to search for the appropriate VideoStartupDir, which seemed odd to me.
I guess this change will break any existing data in the videometadata, but it would be straightforward to tweak that data to fix it.
Anyone have any thoughts on this?
Neale.
PS: My C++ is rusty and Qt non-existent, so feel free to shoot holes in the patch.
diff -uwr mythvideo/mythvideo/videodlg.cpp mythvideo.patched/mythvideo/videodlg.cpp
--- mythvideo/mythvideo/videodlg.cpp 2005-03-16 16:04:43.910367491 +0000
+++ mythvideo.patched/mythvideo/videodlg.cpp 2005-03-16 16:04:54.932511531 +0000
@@ -301,10 +304,13 @@
if (!someItem)
return "";
+ QString startdir = gContext->GetSetting("VideoStartupDir",
+ "/share/Movies/dvd");
+
QString filename = someItem->Filename();
QString handler = getHandler(someItem);
QString arg;
- arg.sprintf("\"%s\"",
+ arg.sprintf("\"%s/%s\"", startdir.utf8().data(),
filename.replace(QRegExp("\""), "\\\"").utf8().data());
QString command = "";
diff -uwr mythvideo/mythvideo/videoscan.cpp mythvideo.patched/mythvideo/videoscan.cpp
--- mythvideo/mythvideo/videoscan.cpp 2005-03-16 16:04:43.926364798 +0000
+++ mythvideo.patched/mythvideo/videoscan.cpp 2005-03-16 16:04:54.942509847 +0000
@@ -18,25 +18,16 @@
m_ListUnknown = gContext->GetNumSetting("VideoListUnknownFileTypes", 1);
}
-void VideoScanner::doScan(const QString& videoDirs)
+void VideoScanner::doScan(const QString& videoDir)
{
QStringList imageExtensions = QImage::inputFormatList();
- int counter = 0;
-
-
- QStringList dirs = QStringList::split(":", videoDirs);
- QStringList::iterator iter;
- MythProgressDialog progressDlg(QObject::tr("Searching for video files"),
- dirs.size());
+ // make sure the path is consistent, with and without trailing /
+ QFileInfo fi(videoDir);
+ QString startDir = fi.absFilePath() + '/';
- for (iter = dirs.begin(); iter != dirs.end(); iter++)
- {
- buildFileList( *iter, imageExtensions );
- progressDlg.setProgress(++counter);
- }
+ buildFileList( startDir, startDir, imageExtensions );
- progressDlg.close();
verifyFiles();
updateDB();
}
@@ -153,7 +144,8 @@
-void VideoScanner::buildFileList(const QString &directory,
+void VideoScanner::buildFileList(const QString &prefix,
+ const QString &directory,
const QStringList &imageExtensions)
{
QDir d(directory);
@@ -191,7 +183,7 @@
QString filename = fi->absFilePath();
if (fi->isDir())
- buildFileList(filename, imageExtensions);
+ buildFileList(prefix, filename, imageExtensions);
else
{
r.setPattern("^" + fi->extension() + "$");
@@ -199,6 +191,7 @@
QStringList result = imageExtensions.grep(r);
if (result.isEmpty())
+ filename.remove(0, prefix.length());
m_VideoFiles[filename] = kFileSystem;
}
}
diff -uwr mythvideo/mythvideo/videoscan.h mythvideo.patched/mythvideo/videoscan.h
--- mythvideo/mythvideo/videoscan.h 2005-03-16 16:04:43.928364461 +0000
+++ mythvideo.patched/mythvideo/videoscan.h 2005-03-16 16:04:54.942509847 +0000
@@ -30,7 +30,8 @@
bool ignoreExtension(const QString& extension) const;
void verifyFiles();
void updateDB();
- void buildFileList(const QString &directory,
+ void buildFileList(const QString &prefix,
+ const QString &directory,
const QStringList &imageExtensions);
};
diff -uwr mythvideo/mythvideo/videotree.cpp mythvideo.patched/mythvideo/videotree.cpp
--- mythvideo/mythvideo/videotree.cpp 2005-03-16 16:04:43.910367491 +0000
+++ mythvideo.patched/mythvideo/videotree.cpp 2005-03-16 16:04:54.932511531 +0000
@@ -454,11 +454,6 @@
}
else if (query.size() > 0)
{
- QString prefix = gContext->GetSetting("VideoStartupDir");
- if(prefix.length() < 1)
- {
- cerr << "videotree.o: Seems unlikely that this is going to work" << endl;
- }
while (query.next())
{
unsigned int idnum = query.value(0).toUInt();
@@ -474,7 +469,6 @@
{
QString file_string = myData->Filename();
- file_string.remove(0, prefix.length());
QStringList list(QStringList::split("/", file_string));
GenericTree *where_to_add;
@@ -1025,10 +1019,14 @@
if (!someItem)
return "";
+ QString startdir = gContext->GetSetting("VideoStartupDir",
+ "/share/Movies/dvd");
+
QString filename = someItem->Filename();
QString handler = getHandler(someItem);
QString arg;
- arg.sprintf("\"%s\"",
+
+ arg.sprintf("\"%s/%s\"", startdir.utf8().data(),
filename.replace(QRegExp("\""), "\\\"").utf8().data());
QString command = "";
_______________________________________________ mythtv-dev mailing list [email protected] http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
