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

David Crawford davidcrawford83 at gmail.com
Sat Feb 4 16:33:12 UTC 2012


On 4 February 2012 16:21, David Crawford <davidcrawford83 at gmail.com> wrote:

>
>
> On 3 February 2012 23:35, Jeremy Jones <jeremy.dwain.jones at gmail.com>wrote:
>
>> On Fri, Feb 3, 2012 at 4:33 PM, David Crawford
>> <davidcrawford83 at gmail.com> wrote:
>> >
>> >
>> > On 3 February 2012 22:19, David Crawford <davidcrawford83 at gmail.com>
>> wrote:
>> >>
>> >>
>> >>
>> >> On 3 February 2012 22:17, Raymond Wagner <raymond at wagnerrp.com> wrote:
>> >>>
>> >>> On 2/3/2012 17:12, David Crawford wrote:
>> >>> >  bash: syntax error near unexpected token '1010'
>> >>>
>>
>> Did you have the < character in front of the 1010?  It would probably
>> help if you were to actually post your entire command line instead of
>> descriptions of what you did.
>>
>>
>> >>> If you are getting anything "bash", it means that your "hashbang" is
>> not
>> >>> configured properly, and your system is instead trying to run the
>> script
>> >>> directly in whatever shell you are currently running (which seems to
>> be
>> >>> Bash).
>>
>> Maybe.  You know better than I do, but what if the bash error is in
>> his command line and it never gets to the python script
>>
>> I did this in a bash shell just to test:
>> jeremy at mythbox2011-03-25:~$ find_orphans.py <1010>
>> bash: syntax error near unexpected token `1010'
>>
>> Just to further drive home the point of the <brackets>:
>>
>> Those are indicators to you that the word or input that goes there is
>> something you should fill in, and *****does not***** include the
>> actual beginning "<" or the ending ">".
>>
>>
>> >>> http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Examples
>> >>>
>> >>> In the case of the jobqueue, it currently passes everything through
>> the
>> >>> Bourne shell (/bin/sh), but the end result would be the same.
>> >>> _______________________________________________
>> >>> mythtv-users mailing list
>> >>> mythtv-users at mythtv.org
>> >>> http://www.mythtv.org/mailman/listinfo/mythtv-users
>> >>
>> >>
>> >> Wouldnt that prevent the other script from not working also?
>> >
>> > When running with " " for "<Chanid>"and "<starttime>"
>> >
>> > I instead get
>> >
>> > chanid, starttime = sys.arg[1:3]
>> > ValueError: need more than 1 value to unpack
>> >
>> >
>> This is good, it means the python interpreter is running the code
>> here, but you only passed one value and it needed three.  The first
>> value was the python script name which was passed to python as:
>> sys.argv[0]
>>
>> the second:
>> sys.argv[1]
>> which is stored in the variable: chanid
>>
>> the third is:
>> sys.argv[2]
>> which is stored in the variable: starttime
>>
>>
>>
>> Jeremy
>> _______________________________________________
>> mythtv-users mailing list
>> mythtv-users at mythtv.org
>> http://www.mythtv.org/mailman/listinfo/mythtv-users
>>
>
> Hi,
>
> This is the command ive tried + with "<" also and without ".py". You can
> see the error below.
>
> dave at dave-virtual-machine:~/uksub2srt$ /home/dave/uksub2srt/renamesrt.py
> 1010 20120202234800
> Traceback (most recent call last):
>   File "/home/dave/uksub2srt/rename.py", line 7, in <module>
>     raise Exception('Invalid argument count')
> Exception: Invalid argument count
>
> Also, here is the script:
>
> #!/usr/bin/python
>
> import sys
> import os
>
> if len(sys.argv) != 2:
>     raise Exception('Invalid argument count')
> chanid, starttime = sys.argv[1:3]
>
> from MythTV import MythBE, findfile
> be = MythBE()
> prog = be.getRecording(1001, 20111209212231)
> oldbase = prog.basename.rsplit('.',1)[0]
> newbase = prog.formatPath('%m-%d_%H-%i-%cN_%T').rsplit('.',1)[0]
> sg = findfile(prog.basename, prog.storagegroup)
> if sg is None:
>     raise Exception('file not found')
>
> from MythTV import System
> ccextractor = System(path="/home/dave/uksub2srt/uksub2srt.py")
> ccextractor('-i', os.path.join(sg.dirname, prog.basename),
>              '-o',
> '/home/dave/Downloads/subtitles/{0}.srt'.format(newbase))
>
>
Ok - so that error was down to having "if len(sys.argv) != 2:" and not !=3:
- forgot to change it back :S

The script goes a bit further now and gives me this error (dont know if the
syntax is right or anything like that, or need to configure anything?)

dave at dave-virtual-machine:~/uksub2srt$ ~dave/uksub2srt/rename.py 1010
20120202234800
Traceback (most recent call last):
  File "/home/dave/uksub2srt/rename.py", line 13, in <module>
    oldbase = prog.basename.rsplit('.',1)[0]
  File "/usr/lib/pymodules/python2.7/MythTV/altdict.py", line 27, in
__getattr__
    raise AttributeError(str(name))
AttributeError: basename
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20120204/623112ae/attachment.html 


More information about the mythtv-users mailing list