VLC auto download subtitles

Get help with using AutoHotkey and its commands and hotkeys
Thouldre
Posts: 42
Joined: 25 May 2017, 14:29

VLC auto download subtitles

03 Jun 2017, 07:02

Hi,

this might be called "luxury" but it would save me a lot of nerve especially because I always watch media with subtitles. I asked the plugin authors to add a hotkey for this but there are no plans to implement it in the near future.

A script that automatically searches for subtitles by hash and downloads the first match (or better all, just in case the first is not the right one) and then activates VLC full screen.
...and maybe you could specify a path to download subtitles only for video files that are located there so that you could create a scheduled task that automatically executes the script.
1.png
1.png (22.2 KiB) Viewed 1134 times
2.png
2.png (24.65 KiB) Viewed 1134 times
Last edited by Thouldre on 03 Jun 2017, 08:37, edited 1 time in total.
BoBo
Posts: 3756
Joined: 13 May 2014, 17:15

Re: VLC auto download subtitles

03 Jun 2017, 08:28

The screenshots won't be resized if you click on them. Kinda useless.
Have you already checked out if you can download the subtitles via VLC's command line?
Thouldre
Posts: 42
Joined: 25 May 2017, 14:29

Re: VLC auto download subtitles

03 Jun 2017, 08:45

BoBo wrote:The screenshots won't be resized if you click on them. Kinda useless.
I edited the original post: 2 out of 4 steps.
Here is the rest:
3.png
3.png (42.66 KiB) Viewed 1133 times
4.png
4.png (41.56 KiB) Viewed 1133 times
BoBo wrote:Have you already checked out if you can download the subtitles via VLC's command line?
It seems that there is no documentation about commands referring to VLsub.
BoBo
Posts: 3756
Joined: 13 May 2014, 17:15

Re: VLC auto download subtitles

03 Jun 2017, 09:00

Someone (else) in here might get interested in building a plain AHK solution based on the opensubtitle.org-API [here]

Erm, obviously, half of the task has already been done - how to create the hash (with an AHK script) to identify the file to download ...

Code: Select all

#NoEnv
SetBatchLines, -1
; http://www.opensubti.../breakdance.avi
; OpenSubtitles Hash = 8E245D9679D31E12
FilePath := "Breakdance.avi"
MsgBox, 0, OpenSubtitlesHash, % Filepath . ":`r`n" . GetOpenSubtitlesHash(FilePath)
ExitApp


; ==================================================================================================
GetOpenSubtitlesHash(FilePath) {
   ; http://trac.opensubt...HashSourceCodes
   Static X := { 0: "0",  1: "1",  2: "2",  3: "3",  4: "4",  5: "5",  6: "6",  7: "7"
              ,  8: "8",  9: "9", 10: "A", 11: "B", 12: "C", 13: "D", 14: "E", 15: "F"}
   ; Check the file size ---------------------------------------------------------------------------
   ; 9000000000 > $moviebytesize >= 131072 bytes (changed > to  >= for the lower limit)
   FileGetSize, FileSize, %FilePath%
   If (FileSize < 131072) || (FileSize >= 9000000000)
      Return ""
   ; Read the first and last 64 KB -----------------------------------------------------------------
   VarSetCapacity(FileParts, 131072)         ; allocate sufficient memory
   File := FileOpen(FilePath, "r")           ; open the file
   File.Seek(0, 0)                           ; set the file pointer (just for balance)
   File.RawRead(FileParts, 65536)            ; read the first 64 KB
   File.Seek(-65536, 2)                      ; set the file pointer for the last 64 KB
   File.RawRead(&FileParts + 65536, 65536)   ; read the last 64 KB
   File.Close()                              ; got all we need, so the file can be closed
   ; Now calculate the hash using two UINTs for the low- and high-order parts of an UINT64 ---------
   LoUINT := FileSize & 0xFFFFFFFF           ; store low-order UINT of file size
   HiUINT := FileSize >> 32                  ; store high-order UINT of file size
   Offset := -4                              ; to allow adding 4 on first iteration
   Loop, 16384 {                             ; 131072 / 8
      LoUINT += NumGet(FileParts, Offset += 4, "UInt") ; add first UINT value to low-order UINT
      HiUINT += NumGet(FileParts, Offset += 4, "UInt") ; add second UINT value to high-order UINT
   }
   ; Adjust the probable overflow of the low-order UINT
   HiUINT += LoUINT >> 32                    ; add the overflow to the high-order UINT
   LoUINT &= 0xFFFFFFFF                      ; remove the overflow from the low-order UINT
   ; Now get the hex string, i.e. the hash ---------------------------------------------------------
   Hash := ""
   VarSetCapacity(UINT64, 8, 0)
   NumPut((HiUINT << 32) | LoUINT, UINT64, 0, "UInt64")
   Loop, 8
      Hash .= X[(Byte := NumGet(UINT64, 8 - A_Index, "UChar")) >> 4] . X[Byte & 0x0F]
   Return Hash
}
; ==================================================================================================
... taken from here: http://trac.opensubtitles.org/projects/ ... ourceCodes
..., provided by nordan, and discussed here: https://autohotkey.com/board/topic/8931 ... titlesorg/
... with a direct link to his/her [OSDL] (the OpenSubtitleDownloader) 8-)
Thouldre
Posts: 42
Joined: 25 May 2017, 14:29

Re: VLC auto download subtitles

04 Jun 2017, 03:07

I appreciate your help! As I said this might be "luxury" but I am determined to get this done! Unfortunately I only have very little experience in automating tasks so I don't really understand wether this is a big or a small one?
Thouldre
Posts: 42
Joined: 25 May 2017, 14:29

Re: VLC auto download subtitles

04 Jun 2017, 09:10

I found a program named FileBot which is apparently able to download subtitles via CMD. So I'm gonna try that out which means there is probably no need for an AHK solution anymore. But thanks for trying! :thumbup:

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], mrdev, TAC109 and 39 guests