# SubDB
Elixir client for [SubDB](http://thesubdb.com/) API
Installation
------------
Add `sub_db` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:sub_db, "~> 0.1.0"}]
end
```
Ensure `sub_db` is started before your application:
```elixir
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:
```elixir
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:
```elixir
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:
```elixir
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:
```elixir
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
------------
* Read [CODE OF CONDUCT](/CODE_OF_CONDUCT.md)
* [Fork the project](https://github.com/aradunovic/sub-db)
* Create feature branch (`git checkout -b my-new-feature`)
* Add tests
* Commit changes
* Push to the branch (`git push origin my-new-feature`)
* Create a Pull Request
License
-------
**sub_db** is Copyright © 2016 Aleksandar Radunovic. It is free
software, and may be redistributed under the terms specified in the [LICENSE](/LICENSE) file.