Update mythvidexport.py to new logging interface.
This commit is contained in:
parent
2af15d5d12
commit
dbf1490c6f
@ -91,7 +91,7 @@ class VIDEO:
|
|||||||
|
|
||||||
# prep objects
|
# prep objects
|
||||||
self.rec = Recorded((self.chanid,self.starttime), db=self.db)
|
self.rec = Recorded((self.chanid,self.starttime), db=self.db)
|
||||||
self.log(MythLog.IMPORTANT, 'Using recording',
|
self.log(MythLog.GENERAL, MythLog.INFO, 'Using recording',
|
||||||
'%s - %s' % (self.rec.title, self.rec.subtitle))
|
'%s - %s' % (self.rec.title, self.rec.subtitle))
|
||||||
self.vid = Video(db=self.db).create({'title':'', 'filename':'', 'host':gethostname()})
|
self.vid = Video(db=self.db).create({'title':'', 'filename':'', 'host':gethostname()})
|
||||||
|
|
||||||
@ -146,18 +146,18 @@ class VIDEO:
|
|||||||
self.vid.hostname = self.db.gethostname()
|
self.vid.hostname = self.db.gethostname()
|
||||||
if self.rec.subtitle: # subtitle exists, assume tv show
|
if self.rec.subtitle: # subtitle exists, assume tv show
|
||||||
self.type = 'TV'
|
self.type = 'TV'
|
||||||
self.log(self.log.IMPORTANT, 'Attempting TV export.')
|
self.log(self.log.GENERAL, self.log.INFO, 'Attempting TV export.')
|
||||||
grab = VideoGrabber(self.type)
|
grab = VideoGrabber(self.type)
|
||||||
match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
|
match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
|
||||||
else: # assume movie
|
else: # assume movie
|
||||||
self.type = 'MOVIE'
|
self.type = 'MOVIE'
|
||||||
self.log(self.log.IMPORTANT, 'Attempting Movie export.')
|
self.log(self.log.GENERAL, self.log.INFO, 'Attempting Movie export.')
|
||||||
grab = VideoGrabber(self.type)
|
grab = VideoGrabber(self.type)
|
||||||
match = grab.sortedSearch(self.rec.title)
|
match = grab.sortedSearch(self.rec.title)
|
||||||
|
|
||||||
if len(match) == 0:
|
if len(match) == 0:
|
||||||
# no match found
|
# no match found
|
||||||
self.log(self.log.IMPORTANT, 'Falling back to generic export.')
|
self.log(self.log.GENERAL, self.log.INFO, 'Falling back to generic export.')
|
||||||
self.get_generic()
|
self.get_generic()
|
||||||
elif (len(match) > 1) & (match[0].levenshtein > 0):
|
elif (len(match) > 1) & (match[0].levenshtein > 0):
|
||||||
# multiple matches found, and closest is not exact
|
# multiple matches found, and closest is not exact
|
||||||
@ -165,9 +165,9 @@ class VIDEO:
|
|||||||
raise MythError('Multiple metadata matches found: '\
|
raise MythError('Multiple metadata matches found: '\
|
||||||
+self.rec.title)
|
+self.rec.title)
|
||||||
else:
|
else:
|
||||||
self.log(self.log.IMPORTANT, 'Importing content from', match[0].inetref)
|
self.log(self.log.GENERAL, self.log.INFO, 'Importing content from', match[0].inetref)
|
||||||
self.vid.importMetadata(grab.grabInetref(match[0]))
|
self.vid.importMetadata(grab.grabInetref(match[0]))
|
||||||
self.log(self.log.IMPORTANT, 'Import complete')
|
self.log(self.log.GENERAL, self.log.INFO, 'Import complete')
|
||||||
|
|
||||||
def get_generic(self):
|
def get_generic(self):
|
||||||
self.vid.title = self.rec.title
|
self.vid.title = self.rec.title
|
||||||
@ -237,7 +237,7 @@ class VIDEO:
|
|||||||
srcsize = self.rec.filesize
|
srcsize = self.rec.filesize
|
||||||
htime = [stime,stime,stime,stime]
|
htime = [stime,stime,stime,stime]
|
||||||
|
|
||||||
self.log.log(MythLog.IMPORTANT|MythLog.FILE, "Copying myth://%s@%s/%s"\
|
self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Copying myth://%s@%s/%s"\
|
||||||
% (self.rec.storagegroup, self.rec.hostname, self.rec.basename)\
|
% (self.rec.storagegroup, self.rec.hostname, self.rec.basename)\
|
||||||
+" to myth://Videos@%s/%s"\
|
+" to myth://Videos@%s/%s"\
|
||||||
% (self.vid.host, self.vid.filename))
|
% (self.vid.host, self.vid.filename))
|
||||||
@ -261,20 +261,20 @@ class VIDEO:
|
|||||||
|
|
||||||
self.vid.hash = self.vid.getHash()
|
self.vid.hash = self.vid.getHash()
|
||||||
|
|
||||||
self.log(MythLog.IMPORTANT|MythLog.FILE, "Transfer Complete",
|
self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Transfer Complete",
|
||||||
"%d seconds elapsed" % int(time.time()-stime))
|
"%d seconds elapsed" % int(time.time()-stime))
|
||||||
|
|
||||||
if self.opts.reallysafe:
|
if self.opts.reallysafe:
|
||||||
if self.job:
|
if self.job:
|
||||||
self.job.setComment("Checking file hashes")
|
self.job.setComment("Checking file hashes")
|
||||||
self.log(MythLog.IMPORTANT|MythLog.FILE, "Checking file hashes.")
|
self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Checking file hashes.")
|
||||||
srchash = hashfile(self.rec.open('r'))
|
srchash = hashfile(self.rec.open('r'))
|
||||||
dsthash = hashfile(self.rec.open('r'))
|
dsthash = hashfile(self.rec.open('r'))
|
||||||
if srchash != dsthash:
|
if srchash != dsthash:
|
||||||
raise MythError('Source hash (%s) does not match destination hash (%s)' \
|
raise MythError('Source hash (%s) does not match destination hash (%s)' \
|
||||||
% (srchash, dsthash))
|
% (srchash, dsthash))
|
||||||
elif self.opts.safe:
|
elif self.opts.safe:
|
||||||
self.log(MythLog.IMPORANT|MythLog.FILE, "Checking file sizes.")
|
self.log(MythLog.GENERAL|MythLog.FILE, MythLog.INFO, "Checking file sizes.")
|
||||||
be = MythBE(db=self.vid._db)
|
be = MythBE(db=self.vid._db)
|
||||||
try:
|
try:
|
||||||
srcsize = be.getSGFile(self.rec.hostname, self.rec.storagegroup, \
|
srcsize = be.getSGFile(self.rec.hostname, self.rec.storagegroup, \
|
||||||
@ -376,8 +376,8 @@ def main():
|
|||||||
help='Perform slow sanity check of exported file using SHA1 hash.')
|
help='Perform slow sanity check of exported file using SHA1 hash.')
|
||||||
parser.add_option("--delete", action="store_true", default=False,
|
parser.add_option("--delete", action="store_true", default=False,
|
||||||
help="Delete source recording after successful export. Enforces use of --safe.")
|
help="Delete source recording after successful export. Enforces use of --safe.")
|
||||||
parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose',
|
|
||||||
help='Verbosity level')
|
MythLog.loadOptParse(parser)
|
||||||
|
|
||||||
opts, args = parser.parse_args()
|
opts, args = parser.parse_args()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user