GithubHelp home page GithubHelp logo

zerratar / subsync Goto Github PK

View Code? Open in Web Editor NEW
288.0 9.0 26.0 392 KB

Automatically download subtitles for your movies

License: MIT License

C# 100.00% Batchfile 0.01%
subtitle-downloader subsync dotnet-core2 subtitle csharp

subsync's Introduction

SubSync

Automatically download subtitles for your movies

I hope this little tool comes to help you out as much as it did for me. My girlfriend and I both struggled with using the VLC Sub add-on for downloading subtitles, a tool that we previously been using lots! And when that tool stopped working on later days, keep being unresponsive and continuesly crashing VLC, we had to manually look for those darn subtitles on the web and if you have a lot of shows to watch then its a huge pain in the ass.

SubSync is a tool that will keep your movies folder synchronized with subtitles. That means, if you add a video file to the folder or its sub-folders being watched a subtitle will automatically be downloaded for that movie.

It works by using the filename of the movie to determine the name and use that to do a search on subscene.com to find the "first best" subtitle to download. It will then extract the file (if its an archive) and rename it to have the same name as the movie file so it can be quickly recognized as a subtitle using VLC.

SubSync will also prefer a chosen language over the other, so for me I prefer Swedish but if that one does not exist I want English, you can set this as a startup argument.

Note: This tool was created with just a couple of hours so be aware that it may not always work perfectly. I do appreciate any problems you may stumble upon either code-wise or functionality when/or if testing this application out. Don't be afraid to add an issue!

Binaries

You can download the somewhat latest binaries from the release tab thingy https://github.com/zerratar/SubSync/releases

Mirror mirror on the wall http://www.shinobytes.com/files/SubSync-binaries-win32.zip

Building SubSync

Load up Visual Studio 2017, open SubSync.sln and hit CTRL+SHIFT+B like your life depends on it!

Running SubSync

SubSync.exe <input folder> [-lang <languages>] [-vid <video extensions>] [-sub <subtitle extensions>] [-delay <ms>] [-resync] [-resyncall] [-exit]

<input folder>: So this is the folder you want to watch, it will also watch all its subfolders.
                As an example: 'D:\Movies'

-lang
<languages>: A list of languages separated by a semi-colon. Example: swedish;english
             The priority of the languages is from left to right, so in this example if 
             a swedish translation subtitle is available it will take that one rather 
             than the english one.

             The value is just English per default.

-vid
<video extensions>: A list of video extensions to watch seperated by a semi-colon, just add
                    all you can think of. But this is an optional and default value is:
                    *.avi;*.mp4;*.mkv;*.mpeg;*.flv;*.webm

-sub
<subtitle extensions>: A list of recognizable subtitle files, formatted same way as video extensions
                       since I don't know of all possible extensions I've made this an optional parameter
                       to change which subtitles SubSync should recognize. The default value is:
                       *.srt;*.txt;*.sub;*.idx;*.ssa;*.ass

-delay
<ms>: If you want to have a delay between each request by a set of milliseconds you can use this flag. 
      This will then run all request sequential instead of concurrent which will take a lot longer to download
      all subtitles. However by adding a delay you have a greater chance of the server giving you a proper response
      and therefor can make the download more stable. 
      The value is set to 0 as default and therefor disabled.

-resync: Downloads subtitles for all your videos that has not been previously synchronized with SubSync
         regardless of whether they already have a subtitle file or not. 
         Warning: This will overwrite any existing subtitles you may already have.

-resyncall: As -resync, it downloads all subtitles again but this one also downloads all subtitles SubSync
            has previously flagged as synced.
            Warning: This will overwrite any existing subtitles you may already have.

-exit: If you don't want to keep SubSync running, you can have it automatically exit as soon as its done syncing
       your subtitles, remember this will exit even if there are no subtitles to sync.

In most cases you will probably only need to run it like this:

SubSync.exe "D:\My Awesome Movies\"

Or if you want to have your subtitles in another language (if one exists) and you're crazy enough to think you will want Latin before English.

SubSync.exe "D:\My Awesome Movies\" -lang spanish;japanese;latin;english

Now keep it running in the background. Its not going to hog up your cpu. Its pretty friendly, and you can be sure to have subtitles available for you whenever you need it!

Tips and tricks

Exiting Press 'q' at any time to exit SubSync. Or you can supply the argument --exit to automatically close SubSync down when its done downloading subtitles.

Retrying Press 'a' to try and re-sync any previously unsynced subtitles. Yes the subtitle downloads can randomly fail some times when the subtitle providers decides you shouldn't be downloading their subtitles too often.

ignoring videos There is a file called .vidignore, it is a list of 1 entry per row that is being used by SubSync to completely ignore a video and not download any subtitles for that particular video. This can be handy when SubSync keeps failing on some videos and you don't want it to keep trying.

The patterns are similar to .gitignore, but this only support wildcards.

Oh, and be sure to bring popcorns or your favorite snacks when watching your movies!

Known issues / To-dos

The OpenSubtitles provider ignore language priority.

Add support for http://www.yifysubtitles.com/

Changes

v0.1.6.2

Reworked the startup arguments and added an --exit flag that can be used to force quit SubSync after first sync.

v0.1.4

Add support for OpenSubtitles.org and is also now the default subtitle provider for SubSync. subscene.com will still be used but only if no subtitles were found on opensubtitles.org. Improved subtitle search algorithm, but only for OpenSubtitles.org right now. The subscene provider will be updated in a future version.

The opensubtitles.org provider has not been properly tested though, so there may still be some bugs that needs to be squished. But initial tests returned great results!

v0.1.3

Use Unicode encoding in the console to properly display all texts.

v0.1.2

Update the usage of all FileInfo and DirectoryInfo instances to use the ZetaLongPaths available from here https://github.com/UweKeim/ZetaLongPaths to fix the bug caused by too long paths.

v0.1.1

This version didn't like anyone.

v0.1.0

Initial release on GitHub, you know the magical first version

subsync's People

Contributors

lechuckthepirate avatar palerdot avatar zerratar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

subsync's Issues

any possibility to release this functionality for other platforms?

Either web, desktop using Electron so it's cross-platform, or compiled binary for Mac? Currently it seems this only works on Windows.. leaving a lot of us users out.. would love to have a standalone alternative to VLSub which also stopped working correctly for me

You can help to make SubSync better! Read me!

You might have noticed that some subtitles fails and gives you an error saying it failed to download after 3 tries.

This is most likely caused by the fact that it couldnt find anything but it can also be an error code returned from the server that is not properly handled or just an out right bug in SubSync.

Since I've got a limited time I can work on this project, I need your help! The moment you see the error message, could any of you guys post the video filenames so I can try and reproduce the issue? The more, the better! Let's get SubSync to work more reliably!

For anyone that posts to this issue, I thank you! You just helped to make SubSync even better!

Syncing a root drive fails

I have an external HDD I use for storing movies on, where the root is F: (on my PC), and it simply contains folders containing movies. The problem is trying to get subs recursively. There are obviously some hidden system folders like F:\$RECYCLE.BIN which will crash the program when it attempts to access them.

I had a previous issue myself on minor personal project before, and found it could be easily solved while enumerating directories with something akin to this:

var info = new DirectoryInfo(path);
var root = info.Root.FullName == info.FullName;
if (!root && info.Attributes.HasFlag(FileAttributes.System))
	continue;

Cannot create a file when that file already exists

First time running with the new --resync option:

PS D:\SubSync> dotnet run --project .\src\SubSync\SubSync.csproj \\c3p0\storage\media -resync  -exit
...
 Synchronizing Mary Poppins (1964) [720] [tt0058331].avi
 [DBG] get-async: 'Mary Poppins (1964) [720] [tt0058331].avi'
 [DBG] OpenSubtitles login successefull
 [DBG] Searching for 'Mary Poppins (1964) [720] [tt0058331].avi'...
 [DBG] Searching with query 'Mary Poppins (1964) [720] [tt0058331].avi'...
 Synchronization of Mary Poppins (1964) [720] [tt0058331].avi failed with: Cannot create a file when that file already exists

They don't all fail, but a significant percentage do.

Overwrite Existing

I have a large number of subtitles that are out of sync with their attached video. It would be nice if I could specify a flag to overwrite them (--overwrite?) so that I can get the latest/greatest versions.

OpenSubtitles API-limit reached

Just upgraded from 1.4 to 1.6.2 and ran the script for my movies and series and it worked great.
The problem is that for all my series it seems like I have reached the limit for how many subtitles it can download. If I play a clip the subtitle says In order to continue you have to login for the whole movie..

I created an account at OpenSubtitles and entered the info in Opensubtitles.auth-file but I got the same "error". Did some research and it seems like there is a limit on 100 Subtitles per 24 hours and 1000 if you pay for VIP.

I'm wondering if its possible to see if the API-returns that you have reached the limit and not download the file. Right now it downloaded 100's of 1kb .srt-files that said that I have to login.

If anyone else had the same problem here is a batch script that will remove all .srt-files that are smaller than 200kb in this folder and all subfolders.

@echo off
setlocal
for /f  "usebackq delims=;" %%A in (`dir /s /b *.srt`) do If %%~zA LSS 200 del "%%A"
pause

Missing dependency in Binary release

Running the include binary or the binary from the release package causes the following error on my Win10 system:

Error:
An assembly specified in the application dependencies manifest (SubSync.deps.json) was not found:
package: 'SharpCompress', version: '0.20.0'
path: 'lib/netstandard2.0/SharpCompress.dll'

Exit after running

Rather than leaving SubSync running I would like it to exit when finished. Maybe --exit on the command line or similar?

This would allow me to schedule it to run instead of tying up a console window.

Help please

Forgive me, I am new at this. I already opened the SubSync file and pressed Ctrl+Alt+B. My question is where do I put the SubSync.exe "D:\My Awesome Movies"?

Configuraable Request Interval

After a few hundred (thousand?) requests all requests start failing. I think it is likely my IP Address has reached a limit and SubScene is now hard blocking me. The logging doesn't indicate the reason it failed but when it goes from only the odd requests here and there failing to every request failing I think thats probably a good indicator.

If the there was a configurable delay between requests this could help mitigate outright blocking.

Out of the box doesnt work

Running subsync.exe with the most basic command like no parameters at all or just specific the downloads folder returns this error for every movie file found "Object reference not set to an instance of an object"

Weird ExtractAllEntries error

PS D:\SubSync> dotnet run --project .\src\SubSync\SubSync.csproj \\c3p0\storage\media -exit
...
Synchronizing Will & Grace - S07E16 - Dance Cards and Greeting Cards DVD.avi
[DBG] get-async: 'Will & Grace - S07E16 - Dance Cards and Greeting Cards DVD.avi'
[DBG] Searching for 'Will & Grace - S07E16 - Dance Cards and Greeting Cards DVD.avi'...
[DBG] Searching with query 'Will & Grace - S07E16 - Dance Cards and Greeting Cards DVD.avi'...
Synchronization of Will & Grace - S07E16 - Dance Cards and Greeting Cards DVD.avi failed with: Use ExtractAllEntries to extract SOLID archives.

I found a .rar file in the S07 directory with the following properties (not sure it's related, but it is solid):

image

Corrupted characters in Turkish subtitle.

Turkish language contains "ı","ü","ö" etc, so the subtitles couldn't show it correctly.I try to fix them via sub editor apps,but coudn't fix it. İs it possible to fix that?
Adsız

Improve Multi-language support?

When specifying the language, does it not follow the normal naming conventions? e.g. -lang French,English should result in <title> (<year>).fr.srt or <title> (<year>).en.srt.

I'd like to be able to have it download multiple languages as we often have students from other countries staying with us (mostly Japan) and it's a treat for them to watch a movie with us in English but have the subtitles in their language. The rest of the time we like subtitles in English (mostly cause volume is low when kids are in bed). I don't mind running it multiple times, once per language, I just don't want subsequent runs overwriting English with German, etc.

Crashes with too long paths

If being run and it finds files in sub directories it crashes with the PathTooLongException and you have to run it again. Would be nice if it didn't crash and instead just ignores it. Potentially make a log of ignored files / output to console.

Unhandled Exception: System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
at System.IO.FileInfo..ctor(String fileName)
at SubSync.Processors.SubSyncMediaWatcher.IsSynchronized(String filePath)
at SubSync.Processors.SubSyncMediaWatcher.Sync(String fullFilePath)
at SubSync.Extensions.EnumerableExtensions.ForEach[T](IEnumerable1 enumerable, Action1 body)
at SubSync.Processors.SubSyncMediaWatcher.SyncAll()
at SubSync.Processors.SubSyncMediaWatcher.Start()
at SubSync.Program.Main(String[] args)

Trailing \ on UNC paths crashes

Launching with:

PS D:\SubSync\> dotnet run --project .\src\SubSync\SubSync.csproj '\\C3P0\Storage\media\TV\Bull (2016)\'
...
   Following folder and its subfolders being watched
     \\C3P0\Storage\media\TV\Bull (2016)"
...
Unhandled Exception: System.ArgumentException: The directory name \\C3P0\Storage\media\TV\Bull (2016)" is invalid.
Parameter name: path
   at System.IO.FileSystemWatcher..ctor(String path, String filter)
   at SubSyncLib.Logic.SubtitleSynchronizer.Start() in D:\Source\3rdParty\SubSync\src\SubSyncLib\Logic\SubtitleSynchronizer.cs:line 53
   at SubSyncLib.Program.Main(String[] args) in D:\Source\3rdParty\SubSync\src\SubSyncLib\Program.cs:line 66
   at SubSync.Program.Main(String[] args) in D:\Source\3rdParty\SubSync\src\SubSync\Program.cs:line 10

The same path without the trailing \ runs fine.

Just help and questions

sorry to post here, but i dont now how to get it to work, should i put all the files in my movies folder?

edit:
i now it now but it gives some error:
Excepção não processada: System.ArgumentException: O nome de directório D:\Torrents" é inválido.
em System.IO.FileSystemWatcher..ctor(String path, String filter)
em SubSync.SubtitleSynchronizer.Start() em E:\git\SubSync\src\SubSync\Logic\SubtitleSynchronizer.cs:line 50
em SubSync.Program.Main(String[] args) em E:\git\SubSync\src\SubSync\Program.cs:line 60

i put it:
SubSync.exe "D:\Torrents"

does it go for subfolders also?

Doesn't work when ran in .bat

"C:\Users\USERNAME\Desktop\Tools-SubsDL\SubSync\SubSync.exe" "D:--DOWNLOADS FOR NAS" -lang dutch;english

Is my .bat file yet it doesn't do anything, just runs Subsync but nothing gets ever downloaded.

When I remove the -lang arguement it starts working but of course only downloads the English subtitles which are fun but not perfect.

-lang Is Not working

Apparently this parameter stopped working since last update as the commando :
SubSync.exe "D:\Media" -lang spanish
Is not listing any movie file... but when I run it without the -lang parameter, it start scrapping all movie files.

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.