Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # # -*- coding: UTF-8 -*-"
- # ----------------------------------------------------------
- # CREATED: Qua 05/Mar/2014 hs 10:24
- # LAST CHANGE: 2014 Mar 05 11:53:20
- # THIS SCRIPT AIM: fix subtitle files
- # AUTHOR: Sergio Luiz Araujo Silva
- # SITE: http://vivaotux.blogspot.com
- # TWITTER: @voyeg3r
- # ----------------------------------------------------------
- # aqui um pequeno guia do pysrt
- # http://tuxbalaji.wordpress.com/2013/10/05/how-to-fix-subtitles-delay-or-ealier-with-your-movies-by-python-code/
- # aqui dois tutorial do argparse
- # http://www.pythonforbeginners.com/argparse/argparse-tutorial
- # http://www.cyberciti.biz/faq/python-command-line-arguments-argv-example/
- # >>> subs.shift(seconds=-2) # Move all subs 2 seconds earlier
- # >>> subs.shift(minutes=1) # Move all subs 1 minutes later
- #subs=open("/home/bala/Pirates of the Caribbean -The Curse of the Black Pearl(2003).srt")
- #subs.shift(minutes=-2) # Move all subs 2 minutes earlier
- #subs.save('/home/bala/new.srt', encoding='utf-8')#saves file with new.srt in your home directory
- import pysrt, argparse
- parser = argparse.ArgumentParser(description='This is a demo script by nixCraft.')
- parser.add_argument('-i','--input', help='Input file name', required=True)
- parser.add_argument('-o','--output', help='Output file name', required=True)
- parser.add_argument('-t','--time', help='time shift', required=True)
- args = parser.parse_args()
- subs=open(args.input)
- subs.shift(seconds=int(args.time)) #nessa linha tinha que converter para inteiro
- subs.save(args.output, encoding='utf-8')
- ## show values ##
- #print ("Input file: %s" % args.input )
- #print ("Output file: %s" % args.output )
- #print ("Time shift: %s" % args.time)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement