Skip to content
Parser of SRT files
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
JPSRTParser
.gitignore
LICENSE
README.md

README.md

JPSRTParser

Parser of SRT files

Usage

  • Clone the repository:
$ git clone https://github.com/Juanpe/JPSRTParser.git
  • Drag the JPSRTParserTool folder into your project.
  • Include the header file:
#import "JPSRTParser.h"
  • Create a JPSRTParser with SRT file or SRT URL and execute parse method. Example:
    JPSRTParser* parser = [[JPSRTParser alloc] initWithContentOfSRTFile:[[NSBundle mainBundle] pathForResource:@"tst" ofType:@"srt"]];
    NSArray* subtitles 	= [parser parse];
    NSLog(@"Subtitles %@",subtitles);

Or, with blocks

    JPSRTParser* parser = [[JPSRTParser alloc] initWithContentOfSRTFile:[[NSBundle mainBundle] pathForResource:@"tst" ofType:@"srt"]];
    [parser parseCompletion:^(JPSRTParsingState status, NSArray* subtitles){
    
        if (status == JPSRTParsingStateCompleted) {
            NSLog(@"-----------------------------------------------------");
            [subtitles enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) {
                
                NSLog(@"Subtitle %d",index);
                NSLog(@"Text => %@", [(JPSRTParserNode *) object nodeText]);
                NSLog(@"Time => %f : %f", [(JPSRTParserNode *) object beginTime], [(JPSRTParserNode *) object endTime]);
                NSLog(@"-----------------------------------------------------");
            }];
        }else{
            NSLog(@"Error to parse");
        }
    }];
You can’t perform that action at this time.