Skip to content

Commit

Permalink
Merge pull request #24 from mdaubie/master
Browse files Browse the repository at this point in the history
Release after v0.1.1
  • Loading branch information
Matthieu Daubié committed May 4, 2023
2 parents 48b3a55 + e079e33 commit 2b284eb
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish

on:
workflow_dispatch: # Trigger manually
push:
branches:
- publish

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
cache: 'maven'
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish to the Maven Central Repository
id: publish-to-central
run: mvn --batch-mode deploy -P release
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run all tests
name: Checks

on:
workflow_dispatch: # Trigger manually
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# Subtitles Parser

[![version](https://img.shields.io/github/v/release/mdaubie/subtitles-parser?display_name=tag)](https://github.com/mdaubie/subtitles-parser/releases/latest)
[![release status](https://github.com/mdaubie/subtitles-parser/actions/workflows/release.yml/badge.svg)](https://github.com/mdaubie/subtitles-parser/actions/workflows/release.yml)
[![checks status](https://github.com/mdaubie/subtitles-parser/actions/workflows/test-all.yml/badge.svg)](https://github.com/mdaubie/subtitles-parser/actions/workflows/test-all.yml)
[![publish status](https://github.com/mdaubie/subtitles-parser/actions/workflows/publish.yml/badge.svg)](https://github.com/mdaubie/subtitles-parser/actions/workflows/publish.yml)
[![license](https://img.shields.io/github/license/mdaubie/subtitles-parser)](https://github.com/mdaubie/subtitles-parser/blob/master/LICENSE)

Library for parsing subtitles files using regexes

Includes a toolbox to perform classic subtitles operations
### Handled formats

- Currently: SubRip
- Upcoming: MicroDVD, WebVTT, SSA, ASS

### Related projects

I am working on a web app project to handle my collection of downloaded movies and series, you can find it
here: [The Movie Shelf](https://github.com/mdaubie/movie-shelf)

This is a personal project for my needs, so it probably won't be interesting for you (I might actually keep it private),
but I need to develop some libraries for this main project which might be useful to you:

- [MKV Toolbox](https://github.com/mdaubie/mkv-toolbox)
- [Torrent Name Parser](https://github.com/mdaubie/torrent-name-parser)
- [Color of Film](https://github.com/mdaubie/color-of-film)
98 changes: 98 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@
<version>0.1.1</version>
<name>Subtitles Parser</name>

<description>Library for parsing subtitles files using regexes</description>
<url>https://github.com/mdaubie/subtitles-parser</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/mdaubie/subtitles-parser.git</connection>
<developerConnection>scm:git:ssh://github.com:mdaubie/subtitles-parser.git</developerConnection>
<url>https://github.com/mdaubie/subtitles-parser/tree/master</url>
</scm>
<developers>
<developer>
<name>Matthieu Daubié</name>
<email>matthieu.daubie@eleve.isep.fr</email>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -24,14 +44,92 @@
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.mdaubie.subtitlesparser.constants;

import io.github.mdaubie.subtitlesparser.model.Format;
import io.github.mdaubie.subtitlesparser.model.SubRipFile;

public final class SUB_FILE_FORMATS {
public static final Format<SubRipFile> SUB_RIP_FORMAT = new Format<>("SubRip", "srt", SubRipFile.class, TIMESTAMP_FORMATS.ISO_8601_COMA.value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.mdaubie.subtitlesparser.constants;

import java.time.format.DateTimeFormatter;

public enum TIMESTAMP_FORMATS {
ISO_8601_COMA(DateTimeFormatter.ofPattern("HH:mm:ss,SSS")),
ISO_8601_DOT(DateTimeFormatter.ofPattern("HH:mm:ss.SSS")),
;

public final DateTimeFormatter value;

TIMESTAMP_FORMATS(DateTimeFormatter value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package io.github.mdaubie.subtitlesparser.model;

import io.github.mdaubie.subtitlesparser.constants.TIMESTAMP_FORMATS;

import java.time.format.DateTimeFormatter;

public record Format<SF extends SubtitlesFile>(String name, String extension,
Class<SF> baseClass,
DateTimeFormatter timestampsFormat) {

public Format(String name, String extension, Class<SF> baseClass, TIMESTAMP_FORMATS timestampsFormat) {
this(name, extension, baseClass, timestampsFormat.value);
}

@Override
public String toString() {
return String.format("Format %s (.%s)", name, extension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import org.junit.jupiter.params.provider.MethodSource;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.stream.Stream;

import static io.github.mdaubie.subtitlesparser.constants.SUB_FILE_FORMATS.*;


class ParserTest {
@ParameterizedTest
Expand Down Expand Up @@ -47,9 +48,8 @@ public static Stream<Arguments> parse() {
LocalTime.of(0, 0, 58, 266 * 1000000),
"(FOOTSTEPS THUDDING)"));
}};
Format<SubRipFile> subRipFormat = new Format<>("SubRip", ".srt", SubRipFile.class, DateTimeFormatter.ofPattern("HH:mm:ss,SSS"));
return Stream.of(
Arguments.of(fileContent, subRipFormat, sf)
Arguments.of(fileContent, SUB_RIP_FORMAT, sf)
);
}

Expand Down

0 comments on commit 2b284eb

Please sign in to comment.