Wednesday, May 30, 2012

MythTV 0.25 Released

MythTV 0.25 has been released and contains a much awaited array of patches, features and code consolidations.
I haven't had much time to play with all the new features yet, but I have had time to re-work my previous patch ( http://vt-100.blogspot.com.au/2012/01/mythtv-lastwatched.html ) to add the 'last watched' feature to this release.


Here it is:


--- /home/ash/src/mythtv-0.25/libs/libmyth/programinfo.cpp      2012-04-10 15:29:22.000000000 +1000
+++ libs/libmyth/programinfo.cpp        2012-05-29 07:35:50.000000000 +1000
@@ -2601,14 +2601,11 @@ void ProgramInfo::SaveWatched(bool watch
         MSqlQuery query(MSqlQuery::InitCon());
         query.prepare("UPDATE videometadata"
-                    " SET watched = :WATCHEDFLAG"
-                    " WHERE title = :TITLE"
-                    " AND subtitle = :SUBTITLE"
-                    " AND filename = :FILENAME ;");
-        query.bindValue(":TITLE", title);
-        query.bindValue(":SUBTITLE", subtitle);
-        query.bindValue(":FILENAME", url);
+                    " SET watched = :WATCHEDFLAG,"
+                   " lastwatched = NOW()"
+                    " WHERE filename = :FILENAME ;");
         query.bindValue(":WATCHEDFLAG", watched);
+        query.bindValue(":FILENAME", url);
         if (!query.exec())
             MythDB::DBError("Set watched flag", query);
--- /home/ash/src/mythtv-0.25/libs/libmythmetadata/metadatacommon.cpp   2012-04-10 15:29:22.000000000 +1000
+++ libs/libmythmetadata/metadatacommon.cpp     2012-05-29 08:24:51.000000000 +1000
@@ -68,6 +68,7 @@ MetadataLookup::MetadataLookup(void) :
     m_collectionref(),
     m_tmsref(),
     m_imdb(),
+    m_lastwatched(),
     m_people(),
     m_studios(),
     m_homepage(),
@@ -137,6 +138,7 @@ MetadataLookup::MetadataLookup(
     const QString &collectionref,
     const QString &tmsref,
     const QString &imdb,
+    const QDateTime lastwatched,
     const PeopleMap people,
     const QStringList &studios,
     const QString &homepage,
@@ -202,6 +204,7 @@ MetadataLookup::MetadataLookup(
     m_collectionref(collectionref),
     m_tmsref(tmsref),
     m_imdb(imdb),
+    m_lastwatched(lastwatched),
     m_people(people),
     m_studios(studios),
     m_homepage(homepage),
@@ -383,6 +386,8 @@ ArtworkList MetadataLookup::GetArtwork(V
 void MetadataLookup::toMap(MetadataMap &metadataMap)
 {
+
+    QString dateformat = gCoreContext->GetSetting("DateFormat", "yyyy-MM-dd hh:mm");
     metadataMap["filename"] = m_filename;
     metadataMap["title"] = m_title;
     metadataMap["network"] = m_network;
@@ -422,6 +427,7 @@ void MetadataLookup::toMap(MetadataMap &
     metadataMap["releasedate"] = MythDateToString(m_releasedate, kDateFull);
     metadataMap["lastupdated"] = MythDateTimeToString(m_lastupdated, kDateFull);
+    metadataMap["lastwatched"] = m_lastwatched.toString(dateformat);
     metadataMap["runtime"] = QObject::tr("%n minute(s)", "", m_runtime);
     metadataMap["runtimesecs"] = QObject::tr("%n second(s)", "", m_runtimesecs);
@@ -941,7 +947,7 @@ MetadataLookup* ParseMetadataItem(const
     QStringList categories, countries, studios;
     float userrating = 0;
     QDate releasedate;
-    QDateTime lastupdated, startts, endts, recstartts, recendts;
+    QDateTime lastupdated, lastwatched, startts, endts, recstartts, recendts;
     PeopleMap people;
     ArtworkMap artwork;
@@ -991,6 +997,8 @@ MetadataLookup* ParseMetadataItem(const
     lastupdated = RFC822TimeToQDateTime(item.
                       firstChildElement("lastupdated").text());
+    lastwatched = RFC822TimeToQDateTime(item.firstChildElement("lastwatched").text());
+
     userrating = item.firstChildElement("userrating").text().toFloat();
     ratingcount = item.firstChildElement("ratingcount").text().toUInt();
     tracknum = item.firstChildElement("tracknum").text().toUInt();
@@ -1136,7 +1144,7 @@ MetadataLookup* ParseMetadataItem(const
         audioproperties, videoproperties, subtitletype, certification,
         countries, popularity, budget, revenue, album, tracknum, system, year,
         releasedate, lastupdated, runtime, runtimesecs, inetref, collectionref,
-        tmsref, imdb, people, studios, homepage, trailerURL, artwork, DownloadMap());
+        tmsref, imdb, lastwatched, people, studios, homepage, trailerURL, artwork, DownloadMap());
 }
 MetadataLookup* ParseMetadataMovieNFO(const QDomElement& item,
--- /home/ash/src/mythtv-0.25/libs/libmythmetadata/videometadatalistmanager.cpp 2012-04-10 15:29:22.000000000 +1000
+++ libs/libmythmetadata/videometadatalistmanager.cpp   2012-05-29 17:44:33.000000000 +1000
@@ -130,7 +130,7 @@ void VideoMetadataListManager::loadAllFr
         "userrating, length, playcount, filename, hash, showlevel, "
         "coverfile, inetref, collectionref, homepage, childid, browse, watched, "
         "playcommand, category, intid, trailer, screenshot, banner, fanart, "
-        "subtitle, tagline, season, episode, host, insertdate, processed, "
+        "subtitle, tagline, season, episode, host, insertdate, processed, lastwatched, "
         "contenttype FROM videometadata ");
     if (!sql.isEmpty())
--- /home/ash/src/mythtv-0.25/libs/libmythmetadata/videometadata.h      2012-04-10 15:29:22.000000000 +1000
+++ libs/libmythmetadata/videometadata.h        2012-05-29 07:43:15.000000000 +1000
@@ -83,6 +83,7 @@ class META_PUBLIC VideoMetadata
              int season = 0,
              int episode = 0,
              const QDate &insertdate = QDate(),
+            const QDateTime &lastwatched = QDateTime(),
              int id = 0,
              ParentalLevel::Level showlevel = ParentalLevel::plLowest,
              int categoryID = 0,
@@ -180,6 +181,8 @@ class META_PUBLIC VideoMetadata
     bool GetProcessed() const;
     void SetProcessed(bool processed);
+    QDateTime GetLastwatched() const;
+
     VideoContentType GetContentType() const;
     void SetContentType(VideoContentType contenttype);
--- /home/ash/src/mythtv-0.25/libs/libmythmetadata/metadatacommon.h     2012-04-10 15:29:22.000000000 +1000
+++ libs/libmythmetadata/metadatacommon.h       2012-05-29 07:52:42.000000000 +1000
@@ -144,6 +144,7 @@ class META_PUBLIC MetadataLookup : publi
         const QString &collectionref,
         const QString &tmsref,
         const QString &imdb,
+       const QDateTime lastwatched,
         const PeopleMap people,
         const QStringList &studios,
         const QString &homepage,
@@ -430,6 +431,8 @@ class META_PUBLIC MetadataLookup : publi
     QString m_tmsref;
     QString m_imdb;
+    const QDateTime m_lastwatched;
+
     // People - Video
     const PeopleMap m_people;
     const QStringList m_studios;
--- /home/ash/src/mythtv-0.25/libs/libmythmetadata/videometadata.cpp    2012-04-10 15:29:22.000000000 +1000
+++ libs/libmythmetadata/videometadata.cpp      2012-05-29 17:47:26.000000000 +1000
@@ -103,6 +103,7 @@ class VideoMetadataImp
              const QString &plot, float userrating,
              const QString &rating, int length, int playcount,
              int season, int episode, const QDate &insertdate,
+            const QDateTime &lastwatched,
              int id, ParentalLevel::Level showlevel, int categoryID,
              int childID, bool browse, bool watched,
              const QString &playcommand, const QString &category,
@@ -121,7 +122,7 @@ class VideoMetadataImp
         m_screenshot(screenshot), m_banner(banner), m_fanart(fanart),
         m_host(host), m_categoryID(categoryID), m_childID(childID),
         m_year(year), m_releasedate(releasedate), m_length(length), m_playcount(playcount),
-        m_season(season), m_episode(episode), m_insertdate(insertdate), m_showlevel(showlevel),
+        m_season(season), m_episode(episode), m_insertdate(insertdate), m_lastwatched(lastwatched),m_showlevel(showlevel),
         m_browse(browse), m_watched(watched), m_id(id),
         m_userrating(userrating), m_processed(processed),
         m_contenttype(contenttype)
@@ -182,6 +183,7 @@ class VideoMetadataImp
             m_userrating = rhs.m_userrating;
             m_host = rhs.m_host;
             m_processed = rhs.m_processed;
+           m_lastwatched = rhs.m_lastwatched;
             m_contenttype = rhs.m_contenttype;
             // No DB vars
@@ -334,6 +336,8 @@ class VideoMetadataImp
     bool GetProcessed() const { return m_processed; }
     void SetProcessed(bool processed) { m_processed = processed; }
+    QDateTime GetLastwatched() const { return m_lastwatched; }
+
     VideoContentType GetContentType() const { return m_contenttype; }
     void SetContentType(VideoContentType contenttype) { m_contenttype = contenttype; }
@@ -394,6 +398,7 @@ class VideoMetadataImp
     int m_season;
     int m_episode;
     QDate m_insertdate;
+    QDateTime m_lastwatched;
     ParentalLevel::Level m_showlevel;
     bool m_browse;
     bool m_watched;
@@ -484,7 +489,7 @@ void VideoMetadataImp::Reset()
                     QString(), VIDEO_PLOT_DEFAULT, 0.0,
                     VIDEO_RATING_DEFAULT, 0, 0,
                     VideoMetadata::FilenameToMeta(m_filename, 2).toInt(),
-                    VideoMetadata::FilenameToMeta(m_filename, 3).toInt(), QDate(), m_id,
+                    VideoMetadata::FilenameToMeta(m_filename, 3).toInt(), QDate(),QDateTime(), m_id,
                     ParentalLevel::plLowest, 0, -1, true, false, "", "",
                     VideoMetadata::genre_list(), VideoMetadata::country_list(),
                     VideoMetadata::cast_list(), m_host, false);
@@ -596,8 +601,9 @@ void VideoMetadataImp::fromDBRow(MSqlQue
     m_host = query.value(31).toString();
     m_insertdate = query.value(32).toDate();
     m_processed = query.value(33).toBool();
+    m_lastwatched = query.value(34).toDateTime();
-    m_contenttype = ContentTypeFromString(query.value(34).toString());
+    m_contenttype = ContentTypeFromString(query.value(35).toString());
     VideoCategory::GetCategory().get(m_categoryID, m_category);
@@ -1110,7 +1116,7 @@ VideoMetadata::VideoMetadata(const QStri
              int year, const QDate &releasedate, const QString &inetref, int collectionref,
              const QString &homepage, const QString &director, const QString &studio,
              const QString &plot, float userrating, const QString &rating,
-             int length, int playcount, int season, int episode, const QDate &insertdate,
+             int length, int playcount, int season, int episode, const QDate &insertdate,  const QDateTime &lastwatched,
              int id, ParentalLevel::Level showlevel, int categoryID,
              int childID, bool browse, bool watched,
              const QString &playcommand, const QString &category,
@@ -1123,7 +1129,7 @@ VideoMetadata::VideoMetadata(const QStri
     m_imp = new VideoMetadataImp(filename, hash, trailer, coverfile, screenshot, banner,
                             fanart, title, subtitle, tagline, year, releasedate, inetref,
                             collectionref, homepage, director, studio, plot, userrating, rating,
-                            length, playcount, season, episode, insertdate, id, showlevel, categoryID,
+                            length, playcount, season, episode, insertdate, lastwatched, id, showlevel, categoryID,
                             childID, browse, watched, playcommand, category, genres, countries,
                             cast, host, processed, contenttype);
 }
@@ -1207,6 +1213,7 @@ void VideoMetadata::toMap(MetadataMap &m
     metadataMap["browseable"] = GetDisplayBrowse(GetBrowse());
     metadataMap["watched"] = GetDisplayWatched(GetWatched());
     metadataMap["processed"] = GetDisplayProcessed(GetProcessed());
+    metadataMap["lastwatched"] = GetLastwatched().toString(gCoreContext->GetSetting("DateFormat"));
     metadataMap["category"] = GetCategory();
 }
@@ -1328,6 +1335,7 @@ void ClearMap(MetadataMap &metadataMap)
     metadataMap["watched"] = "";
     metadataMap["category"] = "";
     metadataMap["processed"] = "";
+    metadataMap["lastwatched"] = "";
 }
 bool VideoMetadata::HasSortKey() const
@@ -1335,6 +1343,12 @@ bool VideoMetadata::HasSortKey() const
     return m_imp->HasSortKey();
 }
+QDateTime VideoMetadata::GetLastwatched() const
+{
+    return m_imp->GetLastwatched();
+}
+
+
 const VideoMetadata::SortKey &VideoMetadata::GetSortKey() const
 {
     return m_imp->GetSortKey();


No comments: