Skip to content

Latest commit

 

History

History
125 lines (84 loc) · 2.9 KB

README.md

File metadata and controls

125 lines (84 loc) · 2.9 KB

moviehash

The package of one hash function to match subtitle files against movie files. For a deeper understanding of the algorithm, feel free to explore the OpenSubtitles API documentation.

Package

moviehash is available as a package.

Requirements

The package works with Go version 1.17 and newer.

Installation

Use the get command to install the package:

go get github.com/opensubtitlescli/moviehash@latest

... and then import it into your project:

import "github.com/opensubtitlescli/moviehash"

Usage

Imagine you have an AVI file from OpenSubtitles and you want to calculate its hash:

package main

import (
	"fmt"
	"os"
	"github.com/opensubtitlescli/moviehash"
)

func main() {
	f, _ := os.Open("./breakdance.avi")
	h, _ := moviehash.Sum(f)
	fmt.Println(h)
}

... result will be:

8e245d9679d31e12

Warning

The error handling is left out for the sake of brevity. However, do not ignore this in actual code.

Command Line Tool

Additionally, moviehash is also available as a command-line tool.

Installation

Use Go itself to install the command:

go install github.com/opensubtitlescli/moviehash/cmd/moviehash@latest

... or manually download the release binary that matches your operating system.

Usage

moviehash: calculate the moviehash of the file.
usage: moviehash [-hv] <path...>

Imagine you have an AVI file from OpenSubtitles and you want to calculate its hash:

moviehash ./breakdance.avi

... output will be:

8e245d9679d31e12

Contribution

To work on the package, install the following versions of the tools:

$ cat .tool-versions
go            1.17
golangci-lint 1.55
goreleaser    1.25
# make        4.4

Once you have installed the tools, download the dependencies:

go mod download

Now you are ready to start working, good luck:

$ make
all       Run all recipes.
build     Build a binary.
help      Show help information.
lint      Lint the source code.
test      Run tests.

Acknowledgments

Thanks to everyone who has previously implemented this algorithm in various languages. Your work has been a joy to read and has greatly contributed to my understanding.

License

MIT (c) Ivan Uhalin