Git Product home page Git Product logo

subsyncstarter's Introduction

SubSyncStarter

Simple post-processing script for Bazarr to start SubSync.

Description and warnings

This script is written in Python and requires Python 3.6 or greater. It runs after subtitle download and starts SubSync with configured parameters for downloaded subs. If sync fails script will add subtitles to Bazarr blacklist automatically. It can work alongside build-in Bazarr synchronization which is using diffrent synchronizer (worse for foreign subtitles from my expirence).

Installation

Tested on Ubuntu 18.04.03 LTS with Python 3.6.9.

  • Install GIT with apt-get install git-core python3-pip
  • Upgrade Python to version 3.6 or greater.
  • Install requests: pip install requests
  • Install Bazarr: https://github.com/morpheus65535/bazarr
  • Install SubSync: https://github.com/sc0ty/subsync
  • Make folder sudo mkdir /opt/SubSyncStarter
  • Change ownership to your user (must have access to sub files) sudo chown -R user:user /opt/SubSyncStarter
  • Go to folder cd /opt
  • Clone repository git clone https://github.com/drikqlis/SubSyncStarter.git

Configuration

Create config.ini file based on config.ini.sample:

General

  • LoggingLevel - Logging level of the script, can be DEBUG, INFO, WARNING, ERROR.
  • Logfile - Where to save log file of the script. Default if installed to /opt/SubSyncStarter
  • BazarrApiKey - API key for Bazarr for blacklisting wrong subtitles.
  • BazarrUrl - URL to your Bazarr instance with protocol and port and without slash at the end (e.g. http://192.168.1.10:6767).

SubSync

  • Location - Where SubSync is installed. Default should work.
  • LoggingLevel - Logging level of SubSync.
  • Logfile - Where to save log file of the SubSync subprocess. Default if installed to /opt/SubSyncStarter
  • Effort - How hard to try, between 0.0 and 1.0.
  • WindowSize - Maximum correction (in seconds).
  • MaxPointDistance - Maximum acceptable synchronization error (in seconds).

Adding to Bazarr

  • Go to Bazarr -> Settings -> General
  • Find Post-processing and turn on option "Use post processing".
  • In post-processing command input:
    python3 /opt/SubSyncStarter/SubSyncStarter.py "{{episode}}" "{{subtitles}}" "{{subtitles_language_code2}}" "{{subtitles_language_code3}}" "{{episode_language_code3}}" "{{subtitle_id}}" "{{provider}}" "{{series_id}}" "{{episode_id}}" 0
    
  • Save settings and restart Bazarr.
  • Now after downloading subtitles you should see entry in Bazarr logs about post-processing script and its result (Sync successful/failed). If sync fails script will add subtitles to Bazarr blacklist automatically.

subsyncstarter's People

Contributors

drikqlis avatar

Stargazers

 avatar Łukasz avatar ElYoM avatar  avatar Li Xin avatar Terrence Hung avatar  avatar  avatar

Watchers

 avatar  avatar

subsyncstarter's Issues

IndexError: out of range

Hi, im having this error while running post processing script in bazarr:

2020-02-24 17:07:14,248 - DEBUG: Error: None
2020-02-24 17:07:14,248 - DEBUG: Exit code: 126
2020-02-24 17:07:14,248 - ERROR: Sync failed - exception
Traceback (most recent call last):
File "/path/to/my/SubSyncStarter.py", line 51, in
if "[+] done" in output_list[-1]:
IndexError: list index out of range

Why is this happening?

subsync.log not found but it's there

Hi, is this still under development? Im trying it out again and it's working pretty good but im getting one error i can't fix. After subs are synced im getting an error about subsync.log missing, but it's created in correct folder (as per readme) and i can manually write and read the file, but bazarr throws this error:

11/03/2023 00:03:27|ERROR   |root                            |BAZARR Post-processing result for file /home/lukasz/data/merger/sonarr/Lucifer/Season 3/Lucifer (2016) - S03E07 - Off the Record [Bluray-1080p]-YAWNiX.mkv : 
00:01:34.782:   MainThread:    ERROR:                       root: invalid log file path '/opt/SubSyncStarter/subsync.log', ignoring Traceback (most recent call last):   File "/snap/subsync/11/lib/python3.5/site-packages/subsync/loggercfg.py", line 43, in init     logging.basicConfig(**config, filename=path)   File "/snap/subsync/11/usr/lib/python3.5/logging/__init__.py", line 1744, in basicConfig     h = FileHandler(filename, mode)   File "/snap/subsync/11/usr/lib/python3.5/logging/__init__.py", line 1008, in __init__     StreamHandler.__init__(self, self._open())   File "/snap/subsync/11/usr/lib/python3.5/logging/__init__.py", line 1037, in _open     return open(self.baseFilename, self.mode, encoding=self.encoding) FileNotFoundError: [Errno 2] No such file or directory: '/opt/SubSyncStarter/subsync.log'

Here's my config:

[General]
# DEBUG, INFO, WARNING, ERROR
LoggingLevel = DEBUG
Logfile = /opt/SubSyncStarter/SubSyncStarter.log
BazarrApiKey = *****
BazarrUrl = http://*****:6767/
[SubSync]
Location = /snap/bin/subsync
LoggingLevel = 1
Logfile = /opt/SubSyncStarter/subsync.log
Effort = 1
WindowSize = 300
MaxPointDistance = 1

Also, is it possible to run it besides dockerized bazarr? When i tried to use it with bazarr in docker i got "ModuleNotFoundError No module named 'requests'" error. For now it only works for me when bazarr is installed locally

Problem with audio without "definition"

Sometimes, the track audio from a file, don't have any "definition" I mean is not coded in any way that is English or other language.
When this happens, a new parameter have to be used
subsync --cli --verbose 3 --window-size 300 --max-point-dist 1 sync --sub file.eng.srt --ref file.mkv **--ref-lang eng** --out aaa.srt --effort 1
So --ref-lang eng make the difference

Do you know if there's a way to take the language file from radarr/sonarr and pass this argument to subsync?
Or maybe you know another way to do this

J

Failed sync no longer blacklisted

Hi

First of all, thanks for your work on this. It works so much better that the sync feature build into Bazarr.

On the latest beta versions of v0.9.4, failed syncs are no longer blacklisted. Perhaps it is due to changes to API or similar. Unfortunately I don't have the skills to fix it. I hope you can help with this, I will be much appreciated :)

Update:
The failed sync does get noted in the Bazarr log:
BAZARR Post-processing result for file XXXXXX.mkv : Sync failed - wrong subs. Lang: en, Provider: supersubtitles, Sub id: XXXXXX

From SubSyncStarter.log:
2021-03-28 08:35:28,464 - DEBUG: Output: [-] couldn't synchronize!
2021-03-28 08:35:28,464 - DEBUG: Output:
2021-03-28 08:35:28,464 - DEBUG: Error: None
2021-03-28 08:35:28,464 - DEBUG: Exit code: 2
2021-03-28 08:35:28,582 - DEBUG: Starting new HTTP connection (1): XXX.XXX.XXX.XXX:6767
2021-03-28 08:35:28,586 - DEBUG: http://XXX.XXX.XXX.XXX:6767 "POST /api/blacklist_episode_subtitles_add HTTP/1.1" 405 178
2021-03-28 08:35:28,586 - WARNING: Sync failed - wrong subs. Lang: en, Provider: supersubtitles, Sub id: XXXXXX

windows version

is possible made version for windows?
and add merge subs and video with mkvmerge and output mkv

Double quote escape

Hi, I think that this line:
command = "/snap/bin/subsync --cli --verbose " + loglevel_subsync + " --logfile '" + logfile_subsync + "' --window-size " + window_size + " --max-point-dist " + max_point_dist + " sync --sub '" + sub_file + "' --ref '" + reference_file + "' --out '" + sub_file + "' --effort " + effort +" --overwrite"
Have to be like this:
command = location_subsync + ' --cli --verbose ' + loglevel_subsync + ' --logfile ' + '"' + logfile_subsync + '"' + ' --window-size ' + window_size + ' --max-point-dist ' + max_point_dist + ' sync --sub ' + '"' + sub_file + '"' + ' --ref ' + '"' + reference_file + '"' + ' --out ' + '"' + sub_file + '"' + ' --effort ' + effort + ' --overwrite'
Just to escape a possible problem with film or movie with ' on path

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.