From 271efacb485f105f67d830ad6d6e950ea197f78f Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 20 Nov 2014 16:30:25 +0000
Subject: LinHES-system: mythvidexport.py: update to v0.7.6

---
 abs/core/LinHES-system/PKGBUILD         |   4 +-
 abs/core/LinHES-system/mythvidexport.py | 100 ++++++++++++++++----------------
 2 files changed, 51 insertions(+), 53 deletions(-)

diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index a8bc443..1d596b1 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=8.2
-pkgrel=4
+pkgrel=5
 arch=('i686' 'x86_64')
 install=system.install
 pkgdesc="Everything that makes LinHES an automated system"
@@ -102,7 +102,7 @@ md5sums=('a10cb96850951ae835c46f41f92463b2'
          '84c0ea62550b0bf9d84ab48eddc08276'
          '3e60b17892e5b8214d47dcfddf5215a4'
          '57ec994cc3964a10c00580e89ebcae35'
-         '7ba5e774bfebc3ec2469c9fe9a76e2ce'
+         '1da933fd2f4436c1ecaf3d6d0c7c0d68'
          '0c3509b48f11af0dc1bf989721fe9ca7'
          'ac61cc460d9e97ba1f5ef69e92cdfbe5'
          'f3502bb7c665750da0ecdf6918f7c838'
diff --git a/abs/core/LinHES-system/mythvidexport.py b/abs/core/LinHES-system/mythvidexport.py
index 5fdfb6d..9160f1d 100755
--- a/abs/core/LinHES-system/mythvidexport.py
+++ b/abs/core/LinHES-system/mythvidexport.py
@@ -5,14 +5,12 @@
 # Python Script
 # Author: Raymond Wagner
 # Purpose
-#   This python script is intended to function as a user job, run through
-#   mythjobqueue, capable of exporting recordings into MythVideo.
-# https://github.com/wagnerrp/mythtv-scripts/blob/master/python/mythvidexport.py
-# http://www.mythtv.org/wiki/Mythvidexport.py
+# This python script is intended to function as a user job, run through
+# mythjobqueue, capable of exporting recordings into MythVideo.
 #---------------------------
-__title__  = "MythVidExport"
+__title__ = "MythVidExport"
 __author__ = "Raymond Wagner"
-__version__= "v0.7.5"
+__version__= "v0.7.6"
 
 from MythTV import MythDB, Job, Recorded, Video, VideoGrabber,\
                    MythLog, MythError, static, MythBE
@@ -58,8 +56,10 @@ class VIDEO:
 
         # prep objects
         self.rec = Recorded((self.chanid,self.starttime), db=self.db)
+        if "_" in self.rec.inetref:
+                self.rec.inetref = self.rec.inetref.split("_")[1]
         self.log(MythLog.GENERAL, MythLog.INFO, 'Using recording',
-                        '%s - %s' % (self.rec.title.encode('utf-8'), 
+                        '%s - %s' % (self.rec.title.encode('utf-8'),
                                      self.rec.subtitle.encode('utf-8')))
         self.vid = Video(db=self.db).create({'title':'', 'filename':'',
                                              'host':gethostname()})
@@ -151,7 +151,7 @@ class VIDEO:
                         'Attempting TV export.')
                 grab = VideoGrabber(self.type)
                 match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
-            else:                   # assume movie
+            else: # assume movie
                 self.type = 'MOVIE'
                 self.log(self.log.GENERAL, self.log.INFO,
                         'Attempting Movie export.')
@@ -189,10 +189,10 @@ class VIDEO:
         # replace fields from viddata
         #print self.vid.data
         ext = '.'+self.rec.basename.rsplit('.',1)[1]
-        rep = ( ('%TITLE%','title','%s'),   ('%SUBTITLE%','subtitle','%s'),
-            ('%SEASON%','season','%d'),     ('%SEASONPAD%','season','%02d'),
-            ('%EPISODE%','episode','%d'),   ('%EPISODEPAD%','episode','%02d'),
-            ('%YEAR%','year','%s'),         ('%DIRECTOR%','director','%s'))
+        rep = ( ('%TITLE%','title','%s'), ('%SUBTITLE%','subtitle','%s'),
+            ('%SEASON%','season','%d'), ('%SEASONPAD%','season','%02d'),
+            ('%EPISODE%','episode','%d'), ('%EPISODEPAD%','episode','%02d'),
+            ('%YEAR%','year','%s'), ('%DIRECTOR%','director','%s'))
         for tag, data, format in rep:
             if self.vid[data]:
                 fmt = fmt.replace(tag,format % self.vid[data])
@@ -200,27 +200,27 @@ class VIDEO:
                 fmt = fmt.replace(tag,'')
 
         # replace fields from program data
-        rep = ( ('%HOSTNAME%',    'hostname',    '%s'),
+        rep = ( ('%HOSTNAME%', 'hostname', '%s'),
                 ('%STORAGEGROUP%','storagegroup','%s'))
         for tag, data, format in rep:
             data = getattr(self.rec, data)
             fmt = fmt.replace(tag,format % data)
 
-#       fmt = fmt.replace('%CARDID%',self.rec.cardid)
-#       fmt = fmt.replace('%CARDNAME%',self.rec.cardid)
-#       fmt = fmt.replace('%SOURCEID%',self.rec.cardid)
-#       fmt = fmt.replace('%SOURCENAME%',self.rec.cardid)
-#       fmt = fmt.replace('%CHANNUM%',self.rec.channum)
-#       fmt = fmt.replace('%CHANNAME%',self.rec.cardid)
+# fmt = fmt.replace('%CARDID%',self.rec.cardid)
+# fmt = fmt.replace('%CARDNAME%',self.rec.cardid)
+# fmt = fmt.replace('%SOURCEID%',self.rec.cardid)
+# fmt = fmt.replace('%SOURCENAME%',self.rec.cardid)
+# fmt = fmt.replace('%CHANNUM%',self.rec.channum)
+# fmt = fmt.replace('%CHANNAME%',self.rec.cardid)
 
         if len(self.vid.genre):
             fmt = fmt.replace('%GENRE%',self.vid.genre[0].genre)
         else:
             fmt = fmt.replace('%GENRE%','')
-#       if len(self.country):
-#           fmt = fmt.replace('%COUNTRY%',self.country[0])
-#       else:
-#           fmt = fmt.replace('%COUNTRY%','')
+# if len(self.country):
+# fmt = fmt.replace('%COUNTRY%',self.country[0])
+# else:
+# fmt = fmt.replace('%COUNTRY%','')
         return fmt+ext
 
     def copy(self):
@@ -235,7 +235,6 @@ class VIDEO:
         srcfp = self.rec.open('r')
         dstfp = self.vid.open('w', nooverwrite=True)
 
-
         if self.job:
             self.job.setStatus(Job.RUNNING)
         tsize = 2**24
@@ -261,7 +260,7 @@ class VIDEO:
                 self.job.setComment("Checking file hashes")
             self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Checking file hashes.")
             srchash = hashfile(self.rec.open('r'))
-            dsthash = hashfile(self.vid.open('r'))
+            dsthash = hashfile(self.rec.open('r'))
             if srchash != dsthash:
                 raise MythError('Source hash (%s) does not match destination hash (%s)' \
                             % (srchash, dsthash))
@@ -294,30 +293,30 @@ class VIDEO:
 
 def usage_format():
     usagestr = """The default strings are:
-    Television: Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%
-    Movie:      Movies/%TITLE%
-    Generic:    Videos/%TITLE%
+Television: Television/%TITLE%/Season %SEASON%/%TITLE% - S%SEASON%E%EPISODEPAD% - %SUBTITLE%
+Movie: Movies/%TITLE%
+Generic: Videos/%TITLE%
 
 Available strings:
-    %TITLE%:         series title
-    %SUBTITLE%:      episode title
-    %SEASON%:        season number
-    %SEASONPAD%:     season number, padded to 2 digits
-    %EPISODE%:       episode number
-    %EPISODEPAD%:    episode number, padded to 2 digits
-    %YEAR%:          year
-    %DIRECTOR%:      director
-    %HOSTNAME%:      backend used to record show
-    %STORAGEGROUP%:  storage group containing recorded show
-    %GENRE%:         first genre listed for recording
+%TITLE%: series title
+%SUBTITLE%: episode title
+%SEASON%: season number
+%SEASONPAD%: season number, padded to 2 digits
+%EPISODE%: episode number
+%EPISODEPAD%: episode number, padded to 2 digits
+%YEAR%: year
+%DIRECTOR%: director
+%HOSTNAME%: backend used to record show
+%STORAGEGROUP%: storage group containing recorded show
+%GENRE%: first genre listed for recording
 """
-#    %CARDID%:        ID of tuner card used to record show
-#    %CARDNAME%:      name of tuner card used to record show
-#    %SOURCEID%:      ID of video source used to record show
-#    %SOURCENAME%:    name of video source used to record show
-#    %CHANNUM%:       ID of channel used to record show
-#    %CHANNAME%:      name of channel used to record show
-#    %COUNTRY%:       first country listed for recording
+# %CARDID%: ID of tuner card used to record show
+# %CARDNAME%: name of tuner card used to record show
+# %SOURCEID%: ID of video source used to record show
+# %SOURCENAME%: name of video source used to record show
+# %CHANNUM%: ID of channel used to record show
+# %CHANNAME%: name of channel used to record show
+# %COUNTRY%: first country listed for recording
     print usagestr
 
 def print_format():
@@ -333,9 +332,9 @@ def print_format():
     if not gfmt:
         gfmt = 'Videos/%TITLE%'
     print "Current output formats:"
-    print "    TV:      "+tfmt
-    print "    Movies:  "+mfmt
-    print "    Generic: "+gfmt
+    print " TV: "+tfmt
+    print " Movies: "+mfmt
+    print " Generic: "+gfmt
 
 def main():
     parser = OptionParser(usage="usage: %prog [options] [jobid]")
@@ -361,7 +360,7 @@ def main():
                     "in place of the job id.")
     sourcegroup.add_option("--chanid", action="store", type="int", dest="chanid",
             help="Use chanid for manual operation")
-    sourcegroup.add_option("--starttime", action="store", type="string", dest="starttime",
+    sourcegroup.add_option("--starttime", action="store", type="int", dest="starttime",
             help="Use starttime for manual operation")
     parser.add_option_group(sourcegroup)
 
@@ -436,4 +435,3 @@ def main():
 
 if __name__ == "__main__":
     main()
-
-- 
cgit v0.12

