pysrt | Python parser for SubRip files | Parser library

 by   byroot Python Version: 1.1.2 License: GPL-3.0

kandi X-RAY | pysrt Summary

kandi X-RAY | pysrt Summary

pysrt is a Python library typically used in Utilities, Parser applications. pysrt has no vulnerabilities, it has build file available, it has a Strong Copyleft License and it has low support. However pysrt has 2 bugs. You can install using 'pip install pysrt' or download it from GitHub, PyPI.

Python parser for SubRip (srt) files
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pysrt has a low active ecosystem.
              It has 359 star(s) with 66 fork(s). There are 16 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 18 open issues and 42 have been closed. On average issues are closed in 71 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pysrt is 1.1.2

            kandi-Quality Quality

              OutlinedDot
              pysrt has 2 bugs (2 blocker, 0 critical, 0 major, 0 minor) and 20 code smells.

            kandi-Security Security

              pysrt has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pysrt code analysis shows 0 unresolved vulnerabilities.
              There are 1 security hotspots that need review.

            kandi-License License

              pysrt is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              pysrt releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              It has 1143 lines of code, 177 functions and 16 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pysrt and discovered the below as its top functions. This is intended to give you an instant insight into pysrt implemented functionality, and help decide if they suit your requirements.
            • Read source code from source_file
            • Generates a generator of SubRipItem from a source file
            • Guess the eol
            • Get the first line of the given iterable
            • Create a Time instance from a string
            • Splits the input file
            • Sorts the list of indexes
            • Save to file
            • Parse command line arguments
            • Create the backup file
            • Parse arguments
            • Build argument parser
            • Create a file from a file
            • Detect the encoding of a bigger file
            • Open a Unicode file
            • Read content from source_file
            • Return the source file
            • Read file from source string
            • Break lines into output_file
            • Rate the input file
            Get all kandi verified functions for this library.

            pysrt Key Features

            No Key Features are available at this moment for pysrt.

            pysrt Examples and Code Snippets

            No Code Snippets are available at this moment for pysrt.

            Community Discussions

            QUESTION

            Im trying to make a GUI app using tkinter and pysrt
            Asked 2021-May-23 at 20:20
            from tkinter import filedialog, font
            from  tkinter import *
            from tkinter import ttk
            root = Tk()
            root.geometry("300x100")
            root.title("SRT")
            root.resizable(False, False)
            frame = Frame(root)
            frame.grid(column=1, row =0)
            def open():
                b.destroy()
                filename1 =  filedialog.askopenfilename(filetypes=[("SRT files(*.srt)", "*.srt")],initialdir = "/", title = "Select file")
                root.geometry("775x300")
                k=Label(frame,text="SELECTED SUBTITLE",font=("Times New Roman", 15)).grid(column=3, row =0)
                y=Label(frame,text=filename1,font=("Times New Roman", 12)).grid(column=3, row =1)
                seconds=Label(root, font=("Times New Roman", 15),text="Seconds").grid(column=2,row=2)
                minutes=Label(root, font=("Times New Roman", 15),text="Minutes").grid(column=0,row=2,ipadx=20)
                minuteselect = StringVar()
                minutes = ttk.Combobox(root, textvariable=minuteselect)
                minutes['values']=tuple([i for i in range(1,61)])
                minutes['state'] = 'readonly' 
                minutes.grid(column=0,row=4,padx=10)
                secondselect = StringVar()
                seconds = ttk.Combobox(root, textvariable=secondselect)
                seconds['values']=tuple([i for i in range(1,61)])
                seconds['state'] = 'readonly' 
                seconds.grid(column=2,row=4)
                plus =Button(root,text="DECREASE", width='10', height='1').place(x=400,y=150)
                minus =Button(root,text="INCREASE", width='10', height='1').place(x=280,y=150)
            b =Button(frame,text="Select The Subtitle", width='30', height='1',command=open)
            b.grid(row=1, column=1,padx=41,pady=30)
            b.rowconfigure(1, weight=1)
            b.columnconfigure(1, weight=1)
            root.mainloop()
            
            ...

            ANSWER

            Answered 2021-May-23 at 20:20

            First thing I would do is restructure the code you have. You are doing everything inside the open function you have, which complicates your life. Also, you remove the possibility for the user to change the .srt file used for the conversion.

            I would use 1 form to contain all the controls.

            1. Button to select .srt file
            2. Combobox for the minutes
            3. Combobox for the seconds
            4. Save button

            Then put the actual magic on the event that triggers when the Save button I suggested is pressed. Here you just get the values from the 2 comboboxes and use this to offset the subtitles based on these values.

            Now, this doesn't actually properly answer your question, it's how I handled the exact same app long time ago. Sub timings can really s*ck donkeyballs :-|

            To actually answer your question, if you want to use buttons and comboboxes, the required logic changes a bit. You will need to create global variables to hold the minutes and seconds, and take into account that if the seconds are set to 59 and the user presses the INCREASE button for seconds, the seconds should be reset to 0 and minutes should be increased by 1. Of course the inverse goes for the DECREASE. (1m0s --> 0m59s).

            The logic for the buttons should go to separate functions, just as you did for the open button & function. Bind them just as you did for the open fucntion using the command keyword when instantiating them. Put logic in there to update the global minute & second variables, and use combobox.set(value) (docs) to update the combobox values.

            You might also want to bind events to the comboboxes themselves being changed. See the pydocs and this excellent answer from nbro

            Finally, you still need a Save button to actually update the values in the .srt file.

            Some side-notes:

            • The range you use for the minutes & seconds seems incorrect to me. I would use range(0,60) as you need the option for 0 and you do not need the option for 60 (as this would become 1 hour or 1 minute respectively. Considering you wanna fix timings for subtitles, using hours seems preposturous. Using milliseconds would seem usefull though.
            • You should be able to handle negative values. Subtitles are either early or late, and with the current logic, you can only handle the situation where the subtitles are early.

            Source https://stackoverflow.com/questions/67663191

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pysrt

            You can install using 'pip install pysrt' or download it from GitHub, PyPI.
            You can use pysrt like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pysrt

          • CLONE
          • HTTPS

            https://github.com/byroot/pysrt.git

          • CLI

            gh repo clone byroot/pysrt

          • sshUrl

            git@github.com:byroot/pysrt.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link