Giter VIP home page Giter VIP logo

sublime's Introduction

sublime

Golang subtitles downloader

Usage

$ sublime -config 'opensubtitles.username=user opensubtitles.password=pass legendastv.username=user legendastv.password=pass legendastv.retriesAllowed=10' -languages pt-Br,en 'Squid.Game.S01.KOREAN.WEBRip.x264-ION10/'

This command will download subtitles for all the files inside the Squid Game directory, in brazilian portuguese and english. Since no services were specified (with -services opensubtitles,service2,...), it'll use all the available ones (only OpenSubtitles for now).

Extending

The codebase is small and simple, so extending this software should be easy enough. Just add a new service at pkg/sublime/services/ that implements the service interface and register it. Reading opensubtitles.go should give you good guidance.

func init() {
    s := &MyCoolService{}

    sublime.Services[s.GetName()] = s
}

// Service knows how to get candidates for FileTargets and Languages
type Service interface {
    // Returns a string identifying this service. Should be all lowercase
    GetName() string
    // For each FileTarget, returns candidates of all of the possible languages
    GetCandidatesForFiles([]*FileTarget, []language.Tag) <-chan SubtitleCandidate
    // Configure values. No costly/long operations should be performed
    SetConfig(name, value string) error
    // Initialize the service
    Initialize() error
}

sublime's People

Contributors

pietrocarrara avatar

Stargazers

 avatar

Watchers

 avatar

sublime's Issues

Rework osdb library to download an io.Reader

This is so we can stop using the disk on

func (s OpenSubtitlesSubtitle) Open() (io.ReadCloser, error) {
// TODO: Rework the library so we don't have to do this disk operation
tmpFile, err := ioutil.TempFile(os.TempDir(), "sublime-opensubtitles-")
if err != nil {
return nil, err
}
filename := tmpFile.Name()
tmpFile.Close()
err = s.c.DownloadTo(&s.s, filename)
if err != nil {
return nil, err
}
return os.Open(filename)
}

Movie packs with many subtitles for different movies

Common occurrence for movie sagas. Should scan the pack for the subtitle which fits the target movie the most.

Example of such a pack: http://legendas.tv/download/579d268d8bb90/Harry_Potter_and_the_Order_of_the_Phoenix/Harry_Potter_Complete_Collection_2001_2011_1080p_BluRay_x264_DTS_ETRG

To solve this the search criteria must be changed in

// Loop for all of the ".srt" and ".ass" files and select the biggest
biggest := 0
for f, err := archive.Read(); err != io.EOF; f, err = archive.Read() {
if err != nil {
return nil, err
}
ext := filepath.Ext(f.FileInfo.Name())
if ext == ".srt" || ext == ".ass" {
buff, err := ioutil.ReadAll(f.ReadCloser)
if err != nil {
f.Close()
return nil, err
}
// Choose the biggest file
if len(buff) > biggest {
biggest = len(buff)
result = buff
}
}
f.Close()
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.