From 9567c7d747cd41b035eef2367836f8d41803d550 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 1 Oct 2013 13:08:08 -0500
Subject: mythtv: tmdb3_db_update.py: use systemconfig method do update db
 depending on system type.

remove old tmdb.py
---
 abs/core/mythtv/stable-0.25/mythtv/PKGBUILD        | 17 +++++-----
 abs/core/mythtv/stable-0.25/mythtv/mythtv.install  |  2 +-
 .../mythtv/stable-0.25/mythtv/tmdb3_db_update.py   | 37 ++++++++++++++++++++--
 3 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD b/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
index 873eb92..72957a9 100644
--- a/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
+++ b/abs/core/mythtv/stable-0.25/mythtv/PKGBUILD
@@ -6,7 +6,7 @@
 
 pkgname=mythtv
 pkgver=0.25
-pkgrel=29
+pkgrel=32
 commit_hash=`cat ../git_src/git_hash`
 pkgdesc="A Homebrew PVR project $commit_hash"
 arch=('i686' 'x86_64')
@@ -45,9 +45,9 @@ depends=('mysql-clients'
          'glew'
          'openssl'
          'libxml2'
-	 'lsdvd'
-	 'dvdbackup'
-	 'x264')
+         'lsdvd'
+         'dvdbackup'
+         'x264')
 
 #glew for gpu commerical flagging
 #openssl for roap
@@ -109,8 +109,9 @@ build() {
     #Fix Python DepreciationWarning
     sed -i 's/return super(Artwork, cls).__new__(cls, attr, parent, imagetype)/return super(Artwork, cls).__new__(cls)/' ${srcdir}/mythtv/bindings/python/MythTV/dataheap.py
 
-    #Update tmdb3.py to v3.6 & add tmdb3_db_update.py script
+    #Update tmdb3.py to v3.6 & add tmdb3_db_update.py script & rm tmdb.py
     cp $srcdir/tmdb3*.py $srcdir/mythtv/programs/scripts/metadata/Movie/
+    rm -f $srcdir/mythtv/programs/scripts/metadata/Movie/tmdb.py
 
   ARCH=${CARCH/_/-}
   ./configure --prefix=/usr --cpu=${ARCH} \
@@ -122,8 +123,8 @@ build() {
               --enable-vdpau \
               --enable-crystalhd \
               --dvb-path=/usr/include \
-	      --enable-libmp3lame \
-	      --enable-libx264 \
+              --enable-libmp3lame \
+              --enable-libx264 \
               --with-bindings=perl,python --python=python2 || return 1
 
   make all || return 1
@@ -168,4 +169,4 @@ md5sums=('7ef6de58240e7aad389a0b13d91b1cf6'
          'f407d6af23e74a49540755420f84fa58'
          '5469d9921b726db750b991c87d226158'
          '187be42b1ffca6badfa539260ffef65e'
-         '561bc8552c9d1f146d02a6febea5e700')
+         'fbe0fc68707b0c9564a4e00dfa3c4916')
diff --git a/abs/core/mythtv/stable-0.25/mythtv/mythtv.install b/abs/core/mythtv/stable-0.25/mythtv/mythtv.install
index cc60916..5d4614d 100644
--- a/abs/core/mythtv/stable-0.25/mythtv/mythtv.install
+++ b/abs/core/mythtv/stable-0.25/mythtv/mythtv.install
@@ -2,7 +2,6 @@
 post_install() {
         gen_is_xml.py
         gen_lib_xml.py
-        /usr/share/mythtv/metadata/Movie/tmdb3_db_update.py
 }
 
 pre_upgrade() {
@@ -11,6 +10,7 @@ pre_upgrade() {
 
 post_upgrade() {
         post_install
+        /usr/share/mythtv/metadata/Movie/tmdb3_db_update.py
 }
 
 
diff --git a/abs/core/mythtv/stable-0.25/mythtv/tmdb3_db_update.py b/abs/core/mythtv/stable-0.25/mythtv/tmdb3_db_update.py
index 35f1b29..4f31364 100755
--- a/abs/core/mythtv/stable-0.25/mythtv/tmdb3_db_update.py
+++ b/abs/core/mythtv/stable-0.25/mythtv/tmdb3_db_update.py
@@ -1,8 +1,41 @@
 #!/usr/bin/env python2
 
-# This script will update the myth db to use tmdb3.py.
+# This script will configure the myth db to use tmdb3.py
 
+from socket import gethostname
 from MythTV import MythDB
 mythdb = MythDB()
+localhostname = gethostname()
+import sys
 
-mythdb.settings.NULL.MovieGrabber = u'metadata/Movie/tmdb3.py'
+# Function to set db setting.  This setting is set in mythtv-setup.
+def dbSettingChange():
+    if mythdb.settings.NULL.MovieGrabber == u'metadata/Movie/tmdb3.py':
+        print 'The MythTV database setting MovieGrabber is already set to tmdb3.py.'
+    else:
+        mythdb.settings.NULL.MovieGrabber = u'metadata/Movie/tmdb3.py'
+        print 'The MythTV database setting MovieGrabber has been updated to tmdb3.py'
+    return
+
+#taken from systemconfig.py
+#this is how you populate the dict
+systemconfig = {}
+file_name = "/etc/systemconfig"
+try:
+    config_file = open(file_name)
+except:
+    print file_name + ' could not be opened'
+    sys.exit(1)
+
+for line in config_file:
+    line = line.strip()
+    if line and line[0] is not "#" and line[-1] is not "=":
+        var, val = line.rsplit("=", 1)
+        val = val.strip('"')
+        systemconfig[var.strip()] = val.strip()
+
+#this is how you reference a value from mv_hostype.py
+if (systemconfig.get("SystemType") == "Standalone"):
+    dbSettingChange()
+elif systemconfig.get("SystemType") == "Master_backend":
+    dbSettingChange()
-- 
cgit v0.12

