<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 2/2/2012 15:48, David Crawford wrote:
<blockquote
cite="mid:CAFiR-D91YSLcX8jDAALw8_0-Trism+SsCL-ef+FUJy9jso+86Q@mail.gmail.com"
type="cite"><br>
<div>On 31 January 2012 01:27, Raymond Wagner <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:raymond@wagnerrp.com">raymond@wagnerrp.com</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">import os<br>
from MythTV import MythBE, findfile<br>
be = MythBE()<br>
prog = be.getRecording(<chanid>, <starttime>)<br>
oldbase = prog.basename.rsplit('.',1)[0]<br>
newbase = prog.formatPath('...').rsplit('.',1)[0]<br>
sg = findfile(prog.basename, prog.storagegroup)<br>
if sg is None:<br>
raise Exception('file not found')<br>
for f in os.listdir(sg.dirname):<br>
if not (f.startswith(oldbase) and f.endswith('srt')):<br>
continue<br>
os.rename(os.path.join(sg.dirname, f),
os.path.join(sg.dirname,<br>
newbase+'.'+f.split('.')[1]))</blockquote>
</div>
<br>
</div>
Still havent figured quite how to make this script yet.... any
pointers? i just want the .srt subtitle file to be renamed and
read:
<div>mm-dd_hh-mm-ss_Channel(BBC)_Program(BBC News).srt</div>
</blockquote>
<br>
The above script is crude, but it should work. There may be some
minor syntax issues because I never actually tested it. That last
argument in the last line should actually read "f.split('.',1)[1]".
For the name you have listed, you would want the format string to be
...<br>
<br>
%m-%d_%H-%i-%s_%cN_%T<br>
<br>
The chanid and starttime used to reference the recording would be
supplied by the jobqueue on the command line, or you could use the
jobid itself and pull the chanid and starttime out of the database.
You would need to do command line parsing to get either of those,
but there are examples on the wiki of how to do that. As for
running the extractor itself, try...<br>
<br>
from MythTV import System<br>
from MythTV.static import INSTALL_PREFIX<br>
ccextractor =
System(path=os.path.join(INSTALL_PREFIX,'mythccextractor'))<br>
ccextractor('--infile', os.path.join(sg.dirname, prog.basename))<br>
</body>
</html>