Skip to content

Commit 3534f14

Browse files
committed
initial commit
0 parents  commit 3534f14

21 files changed

+9621
-0
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MEDIA_PATH=/path/to/your/media
2+
TZ=America/New_York # Adjust timezone as needed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "18"
23+
cache: "npm"
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build application
29+
run: npm run build
30+
31+
- name: Docker meta
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: mrorbitman/subsyncarr
36+
tags: |
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=semver,pattern={{major}}
40+
type=raw,value=latest,enable=${{ github.ref == format('refs/tags/{0}', github.event.repository.default_branch) }}
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v3
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
48+
- name: Login to Docker Hub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
54+
- name: Build and push
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
push: true
59+
platforms: linux/amd64,linux/arm64
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
64+
- name: Create GitHub Release
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
name: Release ${{ github.ref_name }}
68+
body: |
69+
## Docker Images
70+
71+
Pull the image using:
72+
```bash
73+
docker pull mrorbitman/subsyncarr:${{ github.ref_name }}
74+
# or
75+
docker pull mrorbitman/subsyncarr:latest
76+
```
77+
78+
Example docker-compose.yaml:
79+
80+
```
81+
version: "3.8"
82+
83+
services:
84+
subsyncarr:
85+
image: mrorbitman/subsyncarr:latest
86+
container_name: subsyncarr
87+
volumes:
88+
- ${MEDIA_PATH:-/path/to/your/media}:/scan_dir
89+
restart: unless-stopped
90+
environment:
91+
- TZ=${TZ:-UTC}
92+
```
93+
94+
Docker Hub URL: https://hub.docker.com/r/mrorbitman/subsyncarr/tags
95+
draft: false
96+
prerelease: false
97+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/build
3+
/dist
4+
/coverage
5+
.eslintcache
6+
.env

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
node_modules
5+
dist
6+
.gitignore
7+
.prettierignore
8+
.husky
9+
Dockerfile

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 2,
7+
};

Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Use Node.js LTS (Long Term Support) as base image
2+
FROM node:20-bullseye
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Install system dependencies including ffmpeg, Python, and cron
8+
RUN apt-get update && apt-get install -y \
9+
ffmpeg \
10+
python3 \
11+
python3-pip \
12+
python3-venv \
13+
cron \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Install pipx
17+
RUN python3 -m pip install --user pipx \
18+
&& python3 -m pipx ensurepath
19+
20+
# Add pipx to PATH
21+
ENV PATH="/root/.local/bin:$PATH"
22+
23+
# Install ffsubsync and autosubsync using pipx
24+
RUN pipx install ffsubsync \
25+
&& pipx install autosubsync
26+
27+
# Copy package.json and package-lock.json (if available)
28+
COPY package*.json ./
29+
30+
# Install Node.js dependencies while skipping husky installation
31+
ENV HUSKY=0
32+
RUN npm install --ignore-scripts
33+
34+
# Copy the rest of your application
35+
COPY . .
36+
37+
# Build TypeScript
38+
RUN npm run build
39+
40+
# Create startup script
41+
RUN echo '#!/bin/bash\n\
42+
# Add cron job\n\
43+
echo "0 0 * * * cd /app && /usr/local/bin/node /app/dist/index.js >> /var/log/cron.log 2>&1" > /etc/cron.d/subtitle-sync\n\
44+
chmod 0644 /etc/cron.d/subtitle-sync\n\
45+
crontab /etc/cron.d/subtitle-sync\n\
46+
\n\
47+
# Start cron\n\
48+
service cron start\n\
49+
\n\
50+
# Run the initial instance of the app\n\
51+
node dist/index.js\n\
52+
\n\
53+
# Keep container running\n\
54+
tail -f /var/log/cron.log' > /app/startup.sh
55+
56+
# Make startup script executable
57+
RUN chmod +x /app/startup.sh
58+
59+
# Create log file
60+
RUN touch /var/log/cron.log
61+
62+
# Use startup script as entrypoint
63+
CMD ["/app/startup.sh"]

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Subsyncarr
2+
3+
An automated subtitle synchronization tool that runs as a Docker container. It watches a directory for video files with matching subtitles and automatically synchronizes them using both ffsubsync and autosubsync.
4+
5+
## Features
6+
7+
- Automatically scans directory for video files and their corresponding subtitles
8+
- Uses both ffsubsync and autosubsync for maximum compatibility
9+
- Runs on a schedule (daily at midnight) and on container startup
10+
- Supports common video formats (mkv, mp4, avi, mov)
11+
- Docker-based for easy deployment
12+
- Generates synchronized subtitle files with `.ffsubsync.srt` and `.autosubsync.srt` extensions
13+
14+
## Quick Start
15+
16+
### Using Docker Compose (Recommended)
17+
18+
#### 1. Create a new directory for your project:
19+
20+
```bash
21+
mkdir subsyncarr && cd subsyncarr
22+
```
23+
24+
#### 2. Download the docker-compose.yml and .env.example files:
25+
26+
```bash
27+
curl -O https://raw.githubusercontent.com/johnpc/subsyncarr/main/docker-compose.yml
28+
curl -O https://raw.githubusercontent.com/johnpc/subsyncarr/main/.env.example
29+
```
30+
31+
#### 3. Create your .env file:
32+
33+
```bash
34+
cp .env.example .env
35+
```
36+
37+
#### 4. Edit the .env file with your settings:
38+
39+
```bash
40+
MEDIA_PATH=/path/to/your/media
41+
TZ=America/New_York # Adjust to your timezone
42+
```
43+
44+
#### 5. Start the container:
45+
46+
```bash
47+
docker-compose up -d
48+
```
49+
50+
## Configuration
51+
52+
The container is configured to:
53+
54+
- Scan for subtitle files in the mounted directory
55+
- Run synchronization at container startup
56+
- Run daily at midnight (configurable via cron)
57+
- Generate synchronized subtitle versions using different tools (currently ffsubsync and autosubsync)
58+
59+
### Directory Structure
60+
61+
Your media directory should be organized as follows:
62+
63+
/media
64+
├── movie1.mkv
65+
├── movie1.srt
66+
├── movie2.mp4
67+
└── movie2.srt
68+
69+
It should follow the naming conventions expected by other services like Bazarr and Jellyfin.
70+
71+
## Logs
72+
73+
View container logs:
74+
75+
```bash
76+
docker logs -f subsyncarr
77+
```

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
3+
};

docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.8'
2+
3+
services:
4+
subsyncarr:
5+
image: mrorbitman/subsyncarr:latest
6+
container_name: subsyncarr
7+
volumes:
8+
- ${MEDIA_PATH:-/path/to/your/media}:/scan_dir
9+
restart: unless-stopped
10+
environment:
11+
- TZ=${TZ:-UTC}

0 commit comments

Comments
 (0)