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

Dave Alden alden at math.ohio-state.edu
Sat Jul 19 23:47:07 EDT 2003


Hi,
  Uncle, Uncle...:-)

  Here's the latest patch.  This strips off the movie extension (whatever
follows the file dot in the filename -- note that this means you MUST have
an extension on your movie).  It then looks for <movie>.<qt image format>
in the same directory as the movie.  Note that ".jpg" is not a qt image
format, but ".jpeg" is.  :-)

  I've also modified mythvideo so that it ignores all files with

.<qt image format>

at the end of the filename.  This way it skips the coverfiles.

...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 02:29:32 -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->fileName().right(fi->fileName().length() - fi->fileName().findRev(".") - 1) + "$" );
+	    r.setCaseSensitive( false );
+	    QStringList result = imageExtensions.grep( r );
+
+	    if (result.isEmpty())
+	      video_files[filename] = kFileSystem;
+        }
     }
 }
-------------- next part --------------
Index: videomanager.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videomanager.cpp,v
retrieving revision 1.7
diff -u -r1.7 videomanager.cpp
--- videomanager.cpp	16 Jun 2003 16:16:19 -0000	1.7
+++ videomanager.cpp	20 Jul 2003 02:29:53 -0000
@@ -282,6 +282,30 @@
 
 QString VideoManager::GetMoviePoster(QString movieNum)
 {
+    QString movieFile = curitem->Filename();
+
+    QStringList images = QImage::inputFormatList();
+
+    movieFile = movieFile.left(movieFile.findRev("."));
+
+    QStringList::Iterator an_image_item = images.begin();
+    QString an_image;
+    QString coverFile;
+    for( ; an_image_item != images.end(); ++an_image_item)
+    {
+      an_image = *an_image_item;
+
+      coverFile = movieFile + "." + an_image.lower();
+
+      QFile checkFile(coverFile);
+
+      if (checkFile.exists())
+      {
+	  return coverFile;
+      }
+    }
+
+
     QString host = "www.imdb.com";
 
     QUrl url("http://" + host + "/Posters?" + movieNum


More information about the mythtv-dev mailing list