pysrt3

SubRip (.srt) subtitle parser and writer
Download

pysrt3 Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL v3
  • Price:
  • FREE
  • Publisher Name:
  • Jean Boussier

pysrt3 Tags


pysrt3 Description

pysrt is a Python library used to edit or create SubRip files.Forewordpysrt is mainly designed as a library, but if you are experiencing troubles with bad subtitles you can first try to use ruby-osdb which will try to find the best subtitle for your movie. If you are still unlucky pysrt also provide an srt command useful for either shift, split, or rescale a .srt file.Command UsageShifting: srt -i shift 2s500ms movie.srtSpliting: srt split 58m26s movie.srtRescaling: srt -i rate 23.9 25 movie.srtInstallationpysrt is available on pypi. To intall it you can use eitherpip: sudo pip install pysrt3or distutils: sudo easy_install pysrt3Note: The package name that runs on python 3 is pysrt3. The pysrt package is compatible with python 2.x.Library UsageImport:>>> from pysrt import SubRipFileParsing:>>> subs = SubRipFile.open('some/file.srt')# If you get a UnicodeDecodeError try to specify the encoding>>> subs = SubRipFile.open('some/file.srt', encoding='iso-8859-1')SubRipFile are list-like objects of SubRipItem instances:>>> len(first_sub)>>> first_sub = subsSubRipItem instances are editable just like pure Python objects:>>> first_sub.text = "Hello World !">>> first_sub.start.seconds = 20>>> first_sub.end.minutes = 5Shifting:>>> subs.shift(seconds=-2) # Move all subs 2 seconds earlier>>> subs.shift(minutes=1) # Move all subs 1 minutes later>>> subs.shift(ratio=25/23.9) # convert a 23.9 fps subtitle in 25 fps>>> first_sub.shift(seconds=1) # Move the first sub 1 second later>>> first_sub.start += {'seconds': -1} # Make the first sub start 1 second earlierRemoving:>>> del subsSlicing:>>> part = subs.slice(starts_after={'minutes': 2, seconds': 30}, ends_before={'minutes': 3, 'seconds': 40})>>> part.shift(seconds=-2)Saving changes:>>> subs.save('other/path.srt', encoding='utf-8')Product's homepage


pysrt3 Related Software