[mythtv] (NEW) patch for mythVideo to use already scanned coverfile

Dave Alden alden at math.ohio-state.edu
Sun Jul 20 11:12:43 EDT 2003


Hi,

On Sat, Jul 19, 2003 at 11:36:42PM -0400, Isaac Richards wrote:
> You could use fi->baseName() and fi->extension(), i think, instead of doing 
> the search for last . or whatnot..  If you don't mind changing to use that, 
> or I'll just do it when I go to apply the patch (tomorrow sometime, most 
> likely).

I replaced the r.setPattern line in main.cpp with:

  r.setPattern( "^" + fi->extension() + "$" );

which is much cleaner - thanks.  But fi->baseName won't help in
videomanager.cpp because we want more than the basename, we also
want the "basename" of the file.  :-)  I've included 2 patch files
for main.cpp -- one with just this fix and one that has this fix
and adds skipping of the file "Thumbs.db" (which is added by windows
when you view the directory through samba).  I thought about adding
a check for all possible mplayer extensions to eliminate "non movies",
but then I remembered that you can use anything for the player (not
just mplayer).

...dave
-------------- next part --------------
Index: main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/main.cpp,v
retrieving revision 1.16
diff -u -r1.16 main.cpp
--- main.cpp	28 Jun 2003 06:46:15 -0000	1.16
+++ main.cpp	20 Jul 2003 14:04:09 -0000
@@ -45,7 +45,7 @@
 void runMenu(QString, const QString &, QSqlDatabase *, QString);
 void VideoCallback(void *, QString &);
 void SearchDir(QSqlDatabase *, QString &);
-void BuildFileList(QString &, VideoLoadedMap &);
+void BuildFileList(QString &, VideoLoadedMap &, QStringList &);
 
 extern "C" {
 int mythplugin_init(const char *libversion);
@@ -183,7 +183,9 @@
     VideoLoadedMap video_files;
     VideoLoadedMap::Iterator iter;
 
-    BuildFileList(directory, video_files);
+    QStringList imageExtensions = QImage::inputFormatList();
+
+    BuildFileList(directory, video_files, imageExtensions);
 
     QSqlQuery query("SELECT filename FROM videometadata;", db);
 
@@ -253,7 +255,7 @@
     delete file_checking;
 }
 
-void BuildFileList(QString &directory, VideoLoadedMap &video_files)
+void BuildFileList(QString &directory, VideoLoadedMap &video_files, QStringList &imageExtensions)
 {
     QDir d(directory);
 
@@ -266,6 +268,7 @@
 
     QFileInfoListIterator it(*list);
     QFileInfo *fi;
+    QRegExp r;
 
     while ((fi = it.current()) != 0)
     {
@@ -274,8 +277,15 @@
             continue;
         QString filename = fi->absFilePath();
         if (fi->isDir())
-            BuildFileList(filename, video_files);
+            BuildFileList(filename, video_files, imageExtensions);
         else
-            video_files[filename] = kFileSystem;
+	{
+	    r.setPattern( "^" + fi->extension() + "$" );
+	    r.setCaseSensitive( false );
+	    QStringList result = imageExtensions.grep( r );
+
+	    if (result.isEmpty())
+	      video_files[filename] = kFileSystem;
+        }
     }
 }
-------------- next part --------------
Index: main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/main.cpp,v
retrieving revision 1.16
diff -u -r1.16 main.cpp
--- main.cpp	28 Jun 2003 06:46:15 -0000	1.16
+++ main.cpp	20 Jul 2003 14:05:44 -0000
@@ -45,7 +45,7 @@
 void runMenu(QString, const QString &, QSqlDatabase *, QString);
 void VideoCallback(void *, QString &);
 void SearchDir(QSqlDatabase *, QString &);
-void BuildFileList(QString &, VideoLoadedMap &);
+void BuildFileList(QString &, VideoLoadedMap &, QStringList &);
 
 extern "C" {
 int mythplugin_init(const char *libversion);
@@ -183,7 +183,9 @@
     VideoLoadedMap video_files;
     VideoLoadedMap::Iterator iter;
 
-    BuildFileList(directory, video_files);
+    QStringList imageExtensions = QImage::inputFormatList();
+
+    BuildFileList(directory, video_files, imageExtensions);
 
     QSqlQuery query("SELECT filename FROM videometadata;", db);
 
@@ -253,7 +255,7 @@
     delete file_checking;
 }
 
-void BuildFileList(QString &directory, VideoLoadedMap &video_files)
+void BuildFileList(QString &directory, VideoLoadedMap &video_files, QStringList &imageExtensions)
 {
     QDir d(directory);
 
@@ -266,16 +268,24 @@
 
     QFileInfoListIterator it(*list);
     QFileInfo *fi;
+    QRegExp r;
 
     while ((fi = it.current()) != 0)
     {
         ++it;
-        if (fi->fileName() == "." || fi->fileName() == "..")
+        if (fi->fileName() == "." || fi->fileName() == ".." || fi->fileName == "Thumbs.db")
             continue;
         QString filename = fi->absFilePath();
         if (fi->isDir())
-            BuildFileList(filename, video_files);
+            BuildFileList(filename, video_files, imageExtensions);
         else
-            video_files[filename] = kFileSystem;
+	{
+	    r.setPattern( "^" + fi->extension() + "$" );
+	    r.setCaseSensitive( false );
+	    QStringList result = imageExtensions.grep( r );
+
+	    if (result.isEmpty())
+	      video_files[filename] = kFileSystem;
+        }
     }
 }


More information about the mythtv-dev mailing list