SubDB

Elixir client for SubDB API

Installation

Add sub_db to your list of dependencies in mix.exs:

def deps do
  [{:sub_db, "~> 0.1.3"}]
end

Ensure sub_db is started before your application:

def application do
  [applications: [:sub_db]]
end

Usage

Video hash

The hash function is the core of our database system. You'll need to know the hash of the video file, either to download or upload subtitles. Our hash is composed by taking the first and the last 64kb of the video file, putting all together and generating a md5 of the resulting data (128kb). -- http://thesubdb.com/api/

SubDB provides implementation of hash function:

file_path = "/Users/MyName/Videos/some_video.mp4"
SubDB.Hash.compose(file_path) # => "ffd8d4aa68033dc03d1c8ef373b9028c"

Languages

Get a list of all available languages in SubDB database:

result = SubDB.Client.languages

# SUCCESS
result # => {:ok, ["en", "pt", "es"]}

# BAD REQUEST
result # => {:error, "Bad request"}

Search

Get a list of all available languages for specific video:

result = SubDB.Client.search(hash)

# SUCCESS
result # => {:ok, ["en", "es"]}

# NOT FOUND
result # => {:not_found, "Not found"}

# BAD REQUEST
result # => {:error, "Bad request"}

Download

Get subtitle for specific video:

result = SubDB.Client.download(hash, language: "en")

# SUCCESS
result # => {:ok, "some long subtitle content"}

# NOT FOUND
result # => {:not_found, "Not found"}

# BAD REQUEST
result # => {:error, "Bad request"}

Default value for language option is "en". If you want to download subtitle in another language you need to pass it explicitly.

Upload

TODO

Contributing

License

sub_db is Copyright © 2016 Aleksandar Radunovic. It is free software, and may be redistributed under the terms specified in the LICENSE file.