tools

package
v0.0.0-...-f7e652a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2015 License: GPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Interactions with the OpenSubtitles API

Some useful functions

Index

Constants

View Source
const LANG_EN = "eng"
View Source
const LANG_FR = "fre"

Variables

This section is empty.

Functions

func CheckFilePath

func CheckFilePath(path string) bool

Check if a file exists

func GetFilesFromSubfolder

func GetFilesFromSubfolder(subfolder string, extension string, recursive bool) ([]string, error)

Get all files with the given extension in the given directory

func GetSlugFromString

func GetSlugFromString(filename string) string

Get a slug from the given filename

func Hash

func Hash(password, salt string) string

Hash function

func InArray

func InArray(a []string, e string) bool

Check if e is in a

func InitFromConfiguration

func InitFromConfiguration()

func Login

func Login() error

Create a token

func Logout

func Logout() error

Delete the current token

func OpenSubtitlesClose

func OpenSubtitlesClose()

Defer this function's call in the main function

func OpensubtitlesHash

func OpensubtitlesHash(filename string) (string, uint64, error)

Compute the hash of a file, and returns it plus its size Adapted from https://github.com/oz/osdb

func SaltGenerator

func SaltGenerator() string

Salt generating function

func SearchSubtitles

func SearchSubtitles(hash string, size uint64, imdbId string, lang string) ([]string, error)

Search subtitles

func TryToUtf8

func TryToUtf8(s string, lang string) string

Try to guess the encoding, depending on the lang, and convert s to utf8

func UuidGenerator

func UuidGenerator() (string, error)

UUID generating function From: http://play.golang.org/p/4FkNSiUDMg

func WriteJsonResult

func WriteJsonResult(ret map[string]interface{}, w http.ResponseWriter, code int)

Answer the user's query with the given codes and with a json object constructed from 'ret'.

func WriteResponse

func WriteResponse(content interface{}, w http.ResponseWriter, contentType string, code int)

Set http error code and content-type and write response

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL