[mythtv-users] User Job to rip subtitles from each program
David Crawford
davidcrawford83 at gmail.com
Fri Feb 3 01:15:57 UTC 2012
Ok, so the full script would be this?
#!/usr/bin/env python
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)[1]))
from MythTV import System
ccextractor = System(path="/home/dave/uksub2srt/uksub2srt.py")
ccextractor('-i', os.path.join(sg.dirname, prog.basename),
'-o', '/home/subtitles/{0}.srt'.format(newbase))
import sys
if len(sys.argv) != 3:
chanid, starttime = sys.argv[1:3]
On 3 February 2012 01:07, Raymond Wagner <raymond at wagnerrp.com> wrote:
> On 2/2/2012 19:57, David Crawford wrote:
> > On 3 February 2012 00:53, Raymond Wagner <raymond at wagnerrp.com
> > <mailto:raymond at wagnerrp.com>> wrote:
> >
> > On 2/2/2012 18:15, David Crawford wrote
> >> current command that works is:
> >>
> >> python /home/dave/uksub2srt/uksub2srt.py -i "%DIR%/%FILE%" -o
> >> /home/subtitles/"%FILE%".srt
> >>
> >> 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?
> >
> > from MythTV import System
> > ccextractor = System(path="/home/dave/uksub2srt/uksub2srt.py")
> > ccextractor('-i', os.path.join(sg.dirname, prog.basename),
> > '-o', '/home/subtitles/{0}.srt'.format(newbase))
> >
> >
> > but do i run this as a python script or what? sorry still learning..
>
> It would be inserted into the previous chunk of code, in place of the
> 'for' loop, after you populated the 'sg' variable with the location of
> the file. Use this to grab the chanid and starttime from the command line:
>
> import sys
> if len(sys.argv) != 3:
> chanid, starttime = sys.argv[1:3]
>
> Add this to the top of the file:
>
> #!/usr/bin/env python
>
> And then set your user job to:
>
> /home/dave/bin/whatever.py %CHANID% %STARTTIME%
> _______________________________________________
> 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/20120203/ce798bb0/attachment.html
More information about the mythtv-users
mailing list