1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
Metadata-Version: 1.0
Name: pysrt
Version: 1.0.1
Summary: SubRip (.srt) subtitle parser and writer
Home-page: https://github.com/byroot/pysrt
Author: Jean Boussier
Author-email: jean.boussier@gmail.com
License: GPLv3
Description: pysrt
=============
pysrt is a Python library used to edit or create SubRip files.
.. image:: https://secure.travis-ci.org/byroot/pysrt.png?branch=master
:target: http://travis-ci.org/byroot/pysrt
.. image:: https://coveralls.io/repos/byroot/pysrt/badge.png?branch=master
:target: https://coveralls.io/r/byroot/pysrt?branch=master
.. image:: https://pypip.in/v/pysrt/badge.png
:target: https://crate.io/packages/pysrt/
.. image:: https://pypip.in/d/pysrt/badge.png
:target: https://crate.io/packages/pysrt/
Foreword
====================
pysrt is mainly designed as a library, but if you are experiencing troubles
with bad subtitles you can first try to use `ruby-osdb <https://github.com/byroot/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 Usage
=====================
Shifting: ::
$ srt -i shift 2s500ms movie.srt
Spliting: ::
$ srt split 58m26s movie.srt
Rescaling: ::
$ srt -i rate 23.9 25 movie.srt
Installation
=================
pysrt is available on pypi. To intall it you can use either
pip: ::
$ sudo pip install pysrt
or distutils: ::
$ sudo easy_install pysrt
It is compatible with python >= 2.6 and 3.
Library Usage
=============
Import: ::
>>> import pysrt
Parsing: ::
>>> subs = pysrt.open('some/file.srt')
# If you get a UnicodeDecodeError try to specify the encoding
>>> subs = pysrt.open('some/file.srt', encoding='iso-8859-1')
SubRipFile are list-like objects of SubRipItem instances: ::
>>> len(subs)
>>> first_sub = subs[0]
SubRipItem instances are editable just like pure Python objects: ::
>>> first_sub.text = "Hello World !"
>>> first_sub.start.seconds = 20
>>> first_sub.end.minutes = 5
Shifting: ::
>>> 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 earlier
Removing: ::
>>> del subs[12]
Slicing: ::
>>> 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')
Keywords: SubRip srt subtitle
Platform: Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing :: Markup
|