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><div><br></div><div>Sorry just a bit of a noob and would be really grateful for any help.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Dave<br><br><div class="gmail_quote">On 31 January 2012 01:27, Raymond Wagner <span dir="ltr"><<a href="mailto:raymond@wagnerrp.com">raymond@wagnerrp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 1/30/2012 20:03, Michael T. Dean wrote:<br>
> fixed top-posting<br>
><br>
> On 01/30/2012 07:09 PM, David Crawford wrote:<br>
>> On 30 January 2012 23:33, Jeremy Jones wrote:<br>
>>> On Mon, Jan 30, 2012 at 1:34 PM, David Crawford wrote:<br>
>>>> I managed to get the script to work as a userjob in the end (whay hey!)<br>
>>>><br>
>>>> only thing is the file names system of the recordings. I use an app to<br>
>>>> search through the subtitles and its designed to work with files with a<br>
>>>> particular format (basicially the one used in DVBVIewer).<br>
>>>><br>
>>>> Is there a way that I can maybe add a script that can change the<br>
>>>> filenames of the ripped subtitle files to read like:<br>
>>>> %date%-%time%-%channel%-%programme% ?<br>
>>> Take a look at <a href="http://mythlink.pl" target="_blank">mythlink.pl</a>. It is designed to create symbolic links<br>
>>> of your recordings with *pretty* names like you described above, but<br>
>>> with some string substitutions, I bet you can piece something together<br>
>>> to work for your user created subtitle files. (If I understand what<br>
>>> you are doing in your userjob correctly)<br>
>> Yeah, I actually took a look at that. The thing is I want to actually<br>
>> re-name the subtitle files only in this "pretty" format otherwise the<br>
>> application I have wont be able to read them properly. Just not sure how to<br>
>> piece together what i need..<br>
> I was thinking your script is in Python, in which case you probably want<br>
> to use the Python bindings' support for creating pretty names. It works<br>
> with the same formatting specifiers as the Perl bindings'/<a href="http://mythlink.pl" target="_blank">mythlink.pl</a> ones.<br>
<br>
</div></div>Specifically<br>
<a href="http://www.mythtv.org/wiki/0.24_Python_bindings/Data_Handlers#formatPath" target="_blank">http://www.mythtv.org/wiki/0.24_Python_bindings/Data_Handlers#formatPath</a><br>
<br>
You could do something like...<br>
<br>
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]))<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a><br>
<a href="http://www.mythtv.org/mailman/listinfo/mythtv-users" target="_blank">http://www.mythtv.org/mailman/listinfo/mythtv-users</a><br>
</div></div></blockquote></div><br></div>