This is the script im trying right now and it just hangs, Trying it with python /home/dave/uksub2srt/renamesrt.py %CHANID% %STARTTIME%<div><br></div><div><div>#!/usr/bin/env python</div><div><br></div><div>import sys</div>
<div>if len(sys.argv) != 3:</div><div>    chanid, starttime = sys.argv[1:3</div><div>import os</div><div>from MythTV import MythBE, findfile</div><div>be = MythBE()</div><div>prog = be.getRecording(&lt;chanid&gt;, &lt;starttime&gt;)</div>
<div>oldbase = prog.basename.rsplit(&#39;.&#39;,1)[0]</div><div>newbase = prog.formatPath(&#39;%m-%d_%H-%i-%s_%cN_%T&#39;).rsplit(&#39;.&#39;,1)[0]</div><div>sg = findfile(prog.basename, prog.storagegroup)</div><div>if sg is None:</div>
<div>    raise Exception(&#39;file not found&#39;)</div><div>from MythTV import System</div><div>ccextractor = System(path=&quot;/home/dave/uksub2srt/uksub2srt.py&quot;)</div><div>ccextractor(&#39;-i&#39;, os.path.join(sg.dirname, prog.basename),</div>
<div>            &#39;-o&#39;, &#39;/home/subtitles/{0}.srt&#39;.format(newbase))</div><div><br></div><div>can anyone tell me what im doing wrong? </div><div><br></div><div>many thanks,</div><div>dave</div><br><div class="gmail_quote">
On 3 February 2012 12:17, David Crawford <span dir="ltr">&lt;<a href="mailto:davidcrawford83@gmail.com">davidcrawford83@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
like this sorry - didnt paste first time<div><br></div><div><div>#!/usr/bin/env python</div><div class="im"><div><br></div><div>from MythTV import System</div><div>ccextractor = System(path=&quot;/home/dave/uksub2srt/uksub2srt.py&quot;)</div>

<div>ccextractor(&#39;-i&#39;, os.path.join(sg.dirname, prog.basename),</div><div>            &#39;-o&#39;, &#39;/home/subtitles/{0}.srt&#39;.format(newbase))</div><div><br></div></div><div class="im"><div>import os</div>
<div>from MythTV import MythBE, findfile</div>
<div>be = MythBE()</div><div>prog = be.getRecording(&lt;chanid&gt;, &lt;starttime&gt;)</div><div><br></div></div><div class="im"><div>import sys</div><div>if len(sys.argv) != 3:</div><div>    chanid, starttime = sys.argv[1:3]</div>
<div><br></div>
</div><div class="im"><div>oldbase = prog.basename.rsplit(&#39;.&#39;,1)[0]</div><div>newbase = prog.formatPath(&#39;...&#39;).rsplit(&#39;.&#39;,1)[0]</div><div>sg = findfile(prog.basename, prog.storagegroup)</div><div>
if sg is None:</div><div>
    raise Exception(&#39;file not found&#39;)</div><div><br></div><div>for f in os.listdir(sg.dirname):</div><div>    if not (f.startswith(oldbase) and f.endswith(&#39;srt&#39;)):</div><div>        continue</div><div>    os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,</div>

<div>newbase+&#39;.&#39;+f.split(&#39;.&#39;,1)[1]))</div><br></div><div><div class="h5"><div class="gmail_quote">On 3 February 2012 03:02, David Crawford <span dir="ltr">&lt;<a href="mailto:davidcrawford83@gmail.com" target="_blank">davidcrawford83@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Should it be  more like this?<div><br></div><div><div>#!/usr/bin/env python</div><div><div><br></div><div>import os</div>

<div>from MythTV import MythBE, findfile</div><div>be = MythBE()</div><div>prog = be.getRecording(&lt;chanid&gt;, &lt;starttime&gt;)</div>
<div><br></div></div><div><div>oldbase = prog.basename.rsplit(&#39;.&#39;,1)[0]</div><div>newbase = prog.formatPath(&#39;...&#39;).rsplit(&#39;.&#39;,1)[0]</div><div>sg = findfile(prog.basename, prog.storagegroup)</div>
<div>if sg is None:</div>
<div>    raise Exception(&#39;file not found&#39;)</div><div><br></div></div><div><div>import sys</div><div>if len(sys.argv) != 3:</div><div>    chanid, starttime = sys.argv[1:3]</div><div><br></div></div><div>
<div>from MythTV import System</div>
<div>ccextractor = System(path=&quot;/home/dave/uksub2srt/uksub2srt.py&quot;)</div><div>ccextractor(&#39;-i&#39;, os.path.join(sg.dirname, prog.basename),</div><div>            &#39;-o&#39;, &#39;/home/subtitles/{0}.srt&#39;.format(newbase))</div>


<div><br></div></div><div><div>for f in os.listdir(sg.dirname):</div><div>    if not (f.startswith(oldbase) and f.endswith(&#39;srt&#39;)):</div><div>        continue</div><div>    os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,</div>


<div>newbase+&#39;.&#39;+f.split(&#39;.&#39;,1)[1]))</div><br></div><div class="gmail_quote"><div>On 3 February 2012 01:49, Raymond Wagner <span dir="ltr">&lt;<a href="mailto:raymond@wagnerrp.com" target="_blank">raymond@wagnerrp.com</a>&gt;</span> wrote:<br>


</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And... a bit of python jumble...<br>
<br>
<br>
&gt; #!/usr/bin/env python<br>
<br>
This needs to go at the top of the file... good.<br>
<div><br>
&gt; import os<br>
&gt; from MythTV import MythBE, findfile<br>
&gt; be = MythBE()<br>
&gt; prog = be.getRecording(&lt;chanid&gt;, &lt;starttime&gt;)<br>
<br>
</div>When you look up the command line arguments for an application, usually<br>
required options are seen in diamond braces (&lt;&gt;).  I was going for the<br>
same thing here.  You need to give the getRecording() method the chanid<br>
and starttime of the recording you want it to find.<br>
<div><br>
&gt; oldbase = prog.basename.rsplit(&#39;.&#39;,1)[0]<br>
&gt; newbase = prog.formatPath(&#39;...&#39;).rsplit(&#39;.&#39;,1)[0]<br>
&gt; sg = findfile(prog.basename, prog.storagegroup)<br>
&gt; if sg is None:<br>
&gt;     raise Exception(&#39;file not found&#39;)<br>
<br>
<br>
&gt; for f in os.listdir(sg.dirname):<br>
&gt;     if not (f.startswith(oldbase) and f.endswith(&#39;srt&#39;)):<br>
&gt;         continue<br>
&gt;     os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,<br>
&gt; newbase+&#39;.&#39;+f.split(&#39;.&#39;,1)[1]))<br>
<br>
</div>This was supposed to rename the potential several resultant files coming<br>
out of `mythccextractor`.  Since you&#39;re not using `mythccextractor`,<br>
<div><br>
&gt; from MythTV import System<br>
&gt; ccextractor = System(path=&quot;/home/dave/uksub2srt/uksub2srt.py&quot;)<br>
&gt; ccextractor(&#39;-i&#39;, os.path.join(sg.dirname, prog.basename),<br>
&gt;             &#39;-o&#39;, &#39;/home/subtitles/{0}.srt&#39;.format(newbase))<br>
<br>
</div>this down here was supposed to replace it.  Additionally, unless you&#39;re<br>
trying to limit certain modules to certain scopes, either to keep the<br>
namespace clean or because that scope may never be entered and there not<br>
be any need to import it, it&#39;s better to do your imports at the top of<br>
the file just so you know where to look for them.<br>
<div><br>
&gt; import sys<br>
&gt; if len(sys.argv) != 3:<br>
&gt;     chanid, starttime = sys.argv[1:3]<br>
<br>
</div>You can&#39;t do anything until you get your recording from the backend, and<br>
you can&#39;t do that until you know what chanid and starttime you want the<br>
information for.  Pulling that information out of your command line<br>
variables at the end of the script isn&#39;t going to do you any good.<br>
<div><div>_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org" target="_blank">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></div></div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>