[mythtv-users] User Job to rip subtitles from each program

David Crawford davidcrawford83 at gmail.com
Thu Feb 2 23:15:20 UTC 2012

Ok thanks,

The extractor script I'm using works fine right now though so I'm thinking
of just adding the rename script.

Just to check, to get this to work can i copy the script you wrote in there
and make python script with it? where would the format script go?
and say if i ran as a user job could i run it after the extractor script?

current command that works is:

python /home/dave/uksub2srt/uksub2srt.py -i "%DIR%/%FILE%" -o

is there anyway i can include the script to rename the subtitle file in
that command, or would it be better just to run a separate script after?


On 2 February 2012 22:00, Raymond Wagner <raymond at wagnerrp.com> wrote:

>  On 2/2/2012 15:48, David Crawford wrote:
> On 31 January 2012 01:27, Raymond Wagner <raymond at wagnerrp.com> wrote:
>> import os
>> from MythTV import MythBE, findfile
>> be = MythBE()
>> prog = be.getRecording(<chanid>, <starttime>)
>> oldbase = prog.basename.rsplit('.',1)[0]
>> newbase = prog.formatPath('...').rsplit('.',1)[0]
>> sg = findfile(prog.basename, prog.storagegroup)
>> if sg is None:
>>     raise Exception('file not found')
>> for f in os.listdir(sg.dirname):
>>     if not (f.startswith(oldbase) and f.endswith('srt')):
>>         continue
>>     os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,
>> newbase+'.'+f.split('.')[1]))
>  Still havent figured quite how to make this script yet.... any pointers?
> i just want the .srt subtitle file to be renamed and read:
> mm-dd_hh-mm-ss_Channel(BBC)_Program(BBC News).srt
> 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 ...
> %m-%d_%H-%i-%s_%cN_%T
> 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...
> from MythTV import System
> from MythTV.static import INSTALL_PREFIX
> ccextractor = System(path=os.path.join(INSTALL_PREFIX,'mythccextractor'))
> ccextractor('--infile', os.path.join(sg.dirname, prog.basename))
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20120202/70900fa1/attachment-0001.html 

More information about the mythtv-users mailing list