pysrt


Namepysrt JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/byroot/pysrt
SummarySubRip (.srt) subtitle parser and writer
upload_time2020-01-20 15:22:28
maintainer
docs_urlNone
authorJean Boussier
requires_python
licenseGPLv3
keywords subrip srt subtitle
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            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://img.shields.io/pypi/v/pysrt.svg
  :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')
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/byroot/pysrt",
    "name": "pysrt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "SubRip srt subtitle",
    "author": "Jean Boussier",
    "author_email": "jean.boussier@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/31/1a/0d858da1c6622dcf16011235a2639b0a01a49cecf812f8ab03308ab4de37/pysrt-1.1.2.tar.gz",
    "platform": "Independent",
    "description": "pysrt\n=============\n\npysrt is a Python library used to edit or create SubRip files.\n\n.. image:: https://secure.travis-ci.org/byroot/pysrt.png?branch=master\n  :target: http://travis-ci.org/byroot/pysrt\n.. image:: https://coveralls.io/repos/byroot/pysrt/badge.png?branch=master\n  :target: https://coveralls.io/r/byroot/pysrt?branch=master\n.. image:: https://img.shields.io/pypi/v/pysrt.svg\n  :target: https://crate.io/packages/pysrt/\n\nForeword\n====================\n\npysrt is mainly designed as a library, but if you are experiencing troubles\nwith bad subtitles you can first try to use `ruby-osdb <https://github.com/byroot/ruby-osdb>`_\nwhich will try to find the best subtitle for your movie. If you are still unlucky\npysrt also provide an ``srt`` command useful for either shift, split, or rescale a\n*.srt* file.\n\nCommand Usage\n=====================\n\nShifting: ::\n  \n    $ srt -i shift 2s500ms movie.srt\n\nSpliting: ::\n\n    $ srt split 58m26s movie.srt\n\nRescaling: ::\n\n    $ srt -i rate 23.9 25 movie.srt\n\nInstallation\n=================\n\npysrt is available on pypi. To intall it you can use either\n\npip: ::\n    \n    $ sudo pip install pysrt\n    \nor distutils: ::\n\n    $ sudo easy_install pysrt\n\n\nIt is compatible with python >= 2.6 and 3.\n\n\nLibrary Usage\n=============\n\nImport: ::\n\n    >>> import pysrt\n    \nParsing: ::\n\n    >>> subs = pysrt.open('some/file.srt')\n    # If you get a UnicodeDecodeError try to specify the encoding\n    >>> subs = pysrt.open('some/file.srt', encoding='iso-8859-1')\n    \nSubRipFile are list-like objects of SubRipItem instances: ::\n    \n    >>> len(subs)\n    >>> first_sub = subs[0]\n    \nSubRipItem instances are editable just like pure Python objects: ::\n    \n    >>> first_sub.text = \"Hello World !\"\n    >>> first_sub.start.seconds = 20\n    >>> first_sub.end.minutes = 5\n    \nShifting: ::\n\n    >>> subs.shift(seconds=-2) # Move all subs 2 seconds earlier\n    >>> subs.shift(minutes=1)  # Move all subs 1 minutes later\n    >>> subs.shift(ratio=25/23.9) # convert a 23.9 fps subtitle in 25 fps\n    >>> first_sub.shift(seconds=1) # Move the first sub 1 second later\n    >>> first_sub.start += {'seconds': -1} # Make the first sub start 1 second earlier\n    \nRemoving: ::\n    \n    >>> del subs[12]\n    \nSlicing: ::\n    \n    >>> part = subs.slice(starts_after={'minutes': 2, 'seconds': 30}, ends_before={'minutes': 3, 'seconds': 40})\n    >>> part.shift(seconds=-2)\n    \nSaving changes: ::\n    \n    >>> subs.save('other/path.srt', encoding='utf-8')",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "SubRip (.srt) subtitle parser and writer",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/byroot/pysrt"
    },
    "split_keywords": [
        "subrip",
        "srt",
        "subtitle"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "311a0d858da1c6622dcf16011235a2639b0a01a49cecf812f8ab03308ab4de37",
                "md5": "df8da2dcf345810899bf92396e22bb68",
                "sha256": "b4f844ba33e4e7743e9db746492f3a193dc0bc112b153914698e7c1cdeb9b0b9"
            },
            "downloads": -1,
            "filename": "pysrt-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "df8da2dcf345810899bf92396e22bb68",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 104371,
            "upload_time": "2020-01-20T15:22:28",
            "upload_time_iso_8601": "2020-01-20T15:22:28.291026Z",
            "url": "https://files.pythonhosted.org/packages/31/1a/0d858da1c6622dcf16011235a2639b0a01a49cecf812f8ab03308ab4de37/pysrt-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-01-20 15:22:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "byroot",
    "github_project": "pysrt",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": false,
    "tox": true,
    "lcname": "pysrt"
}
        
Elapsed time: 0.10028s