[mythtv] [PATCH] MythVideo Alternate Movie Poster Site

DanM dan at milkcarton.com
Sun Jun 22 15:52:09 EDT 2003


Attached is patch for mythvideo to allow it to grab movie posters from 
alternate sites.  As an example, the movie "Bruce Almighty" shows up as 
"Posters on other sites  
http://www.impawards.com/2003/bruce_almighty.html 
<http://www.impawards.com/2003/what_a_girl_wants.html>" blah blah blah.  
This patch allows mythvideo to follow the link and download the movie 
poster.

I've tried to make this patch somewhat flexible to allow various 
third-party sites (if more get added by imdb) to be added.

If any changes need to be made to get this commited, let me know

-dan
-------------- next part --------------
Index: mythvideo/videomanager.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videomanager.cpp,v
retrieving revision 1.7
diff -u -d -r1.7 videomanager.cpp
--- mythvideo/videomanager.cpp	16 Jun 2003 16:16:19 -0000	1.7
+++ mythvideo/videomanager.cpp	22 Jun 2003 22:23:42 -0000
@@ -283,6 +283,7 @@
 QString VideoManager::GetMoviePoster(QString movieNum)
 {
     QString host = "www.imdb.com";
+    QString path = "";

     QUrl url("http://" + host + "/Posters?" + movieNum
            + " HTTP/1.1\nHost: " + host + "\nUser-Agent: Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en)"
@@ -314,8 +315,52 @@
     filename = parseData(res, beg, end);
     if (filename == "<NULL>")
     {
-        cout << "MyhVideo: Error parsing poster filename.\n";
-        return filename;
+        //see if the poster is on an alternate site
+        QString temp = parseData(res, "Posters on other sites", "</");
+        if (temp == "<NULL>")
+        {
+            cout << "MyhVideo: Error parsing poster filename.\n";
+            return filename;
+        }
+
+        //Currently, the only other site I've seen is impawards.com
+        beg = "Posters on other sites</h2></p>\n<ul>\n<li><a href=\"";
+        end = "\">http://www.impawards.com";
+        QString othersite = parseData(res, beg, end);
+
+        if (InetGrabber)
+        {
+            InetGrabber->stop();
+            delete InetGrabber;
+        }
+
+        url = QUrl(othersite);
+        InetGrabber = new INETComms(url);
+
+        while (!InetGrabber->isDone())
+        {
+            qApp->processEvents();
+        }
+
+        res = InetGrabber->getData();
+        beg = "<img SRC=\"posters/";
+        end = "\"><br>";
+        filename = parseData(res, beg, end);
+        if (filename == "<NULL>")
+        {
+            cout << "MyhVideo: Error parsing poster filename.\n";
+            return filename;
+        }
+
+        host = parseData(othersite, "//", "/");
+
+        temp = othersite.replace("http://" + host, "");
+        path = temp.left(othersite.findRev("/") + 1) + "posters/";
+    }
+    else
+    {
+        host = "poster.imdb.com";
+        path = "/posters/";
     }

     char *home = getenv("HOME");
@@ -331,11 +376,9 @@
     if (!dir.exists())
         dir.mkdir(fileprefix);

-    host = "posters.imdb.com";
-
     //cout << "Copying (" << filename << ")...";
     QUrlOperator *op = new QUrlOperator();
-    op->copy(QString("http://" + host + "/posters/" + filename),
+    op->copy(QString("http://" + host + path + filename),
              "file:" + fileprefix);
     //cout << "Done.\n";


More information about the mythtv-dev mailing list