Giter VIP home page Giter VIP logo

opensubtitles-api's People

Contributors

amilajack avatar axfree avatar buzut avatar charbgr avatar joa-queen avatar js-kyle avatar kumalee avatar nogro avatar segovia avatar subjunk avatar vankasteelj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensubtitles-api's Issues

Can't pass the tests

I failed to run the tests.

> node test
http client: 9773.827ms
https client: 8657.769ms
Test failed
Error: 415 Disabled user agent
    at Error (native)
    at api.LogIn.then.response (/Users/kuma/Projects/opensubtitles-api/index.js:58:19)
    at process._tickCallback (internal/process/next_tick.js:103:7)

SearchSubtitles protocol changed?

Searching used to work flawlessly until yesterday. Then I debugged it a little and found that the response data returned from OS.SearchSubtitles (invoked in index.js:86) is no longer an array; instead it is an object with keys '0', '1', etc.

As a result, no subtitles are ever returned by OpenSubtitles.search. This is visible when observing the value returned at tests.js:34.

I am using [email protected], which seems to have not changed for two years.

When I change index.js:86 to (notice Object.values near the end of the line):

  return this.api.SearchSubtitles(this.credentials.status.token, [op]).then(result => subs = subs.concat(Object.values(result.data)))

Then everything works well again.

Typescript support not found.

I haven't find any typescript support for this package, So I think it will be a good feature to add as a contributor.

Recommendation about usage

@vankasteelj From From your experience, what have you found to be the best way of finding accurate subtitles for a movie? A lot of the time when querying subtitles, the returned subtitles are for the correct movie but are 'off sync with the movie'. Do you know how to correct this? Which params have you found to be most important when finding the correct movie (infohash, imdb, etc)?

can't install

npm install opensubtitles-api

npm ERR! code ETARGET
npm ERR! notarget No matching version found for opensubtitles-api@^1.3.1
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

Don't save file utf-8 char set on local folder with DonwloadSubtitles method

const OS = require('opensubtitles-api');
const OpenSubtitles = new OS('Butter v1');

OpenSubtitles.api.LogIn('*****', '*****', '**', 'Butter v1').then(response => {
    console.log(response);
    OpenSubtitles.api.DownloadSubtitles(response.token, ['1955708358']).then(data => {
        console.log(data);
    }).catch(error => {
        console.log(error);
    });
}).catch(error => {
    console.log(error);
});

i want to data save to utf-8 char code. Are you using another framework for file download process? I have not found what I need to do here.

Block-scoped declarations (let, const, function, class) not yet supported outside strict mode - Can't intergrate with my Express app "use strict"; error

I get this when trying to run my Express app OpenSubtitles.api.LogIn( without "use strict";

/Users/alex/Dropbox/Linkcast/subtitle/node_modules/opensubtitles-api/lib/opensubtitles.js:10
module.exports = class OS {
                 ^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/alex/Dropbox/Linkcast/subtitle/node_modules/opensubtitles-api/index.js:3:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Then I try to run it with "use strict"; or node --use_strict app.js I get the below error.

/Users/alex/Dropbox/Linkcast/subtitle/node_modules/opensubtitles-api/lib/opensubtitles.js:36
            this.client.methodCall(method, [...args], (err, data) => {
                                            ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/alex/Dropbox/Linkcast/subtitle/node_modules/opensubtitles-api/index.js:3:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Does this npm module work with express? can someone explain how to integrate this? spending way too long trying to run OpenSubtitles.api.LogIn(

Issue in Identify.js

Hi,

Awesome work.... 👍

I noticed an issue in identify.js, if a movie/series does not have a plot/synopsis, the following line will throw exception, since plot is undefined. Could you please fix this minor issue?

data.metadata.synopsys = response.data.plot.match(/add a plot/i) !== null ? undefined : response.data.plot;

PS: Also, just saying, 'synopsis' is the right spelling. :)

typescript support

i be glad to install the types for this package if you can provide that

Issue: vtt subtitle download not working

Download link for vtt doesn't work, i have extensions: ['srt', 'vtt'] passed on and as a result i get url, utf8 & vtt.

Both download links for url and utf8 work and download srt files but vtt doesn't work, am i doing something wrong or?

[Feature request ] VTT

As Opensubtitles included a vtt converter on the fly we would love to see it included on opensubtitles.api as a prototype maybe ? fetchvtt ?

Thank you !

Italian translation

in code updated files for support italian language

PATH\OpenSUbtitles Uploader\app\js\utils\localization.js = add 'it' option

PATH\OpenSUbtitles Uploader\app\localization\it.json =

"Upload": "Carica",
"Log in": "Accedi",
"Log out": "Disconnetti",
"Username": "Utente",
"Password": "Password",
"Video file": "File Video",
"Subtitle file": "Sottotitolo",
"Drop a video file or select one": "Trascina o seleziona un Video",
"Drop a subtitle file or select one": "Trascina o seleziona un Sottotitolo",
"Metadata": "Metadati",
"browse": "naviga",
"Save between sessions": "Mantieni",
"Search on IMDB directly": "Cerca su IMDB",
"Auto-detect the language": "Lingua Automatica",
"Reset": "Resetta",
"File name": "Nome File",
"OSDb Hash": "OSDb Hash",
"MD5 Hash": "MD5 Hash",
"Size": "Dimensioni",
"bytes": "bytes",
"High definition": "HD",
"Movie AKA": "Vdeo AKA",
"Release name": "Nome Release",
"FPS": "FPS",
"Total time": "Durata",
"Number of frames": "Numero Frame",
"Language": "Lingua",
"None": "Nessuno",
"Comment": "Commento",
"Hearing impaired": "Non Udenti",
"Auto-translated": "Auto-tradotto",
"Translator": "Traduttore",
"developed by": "sviluppato da",
"Enter a title": "Inserisci un Titolo",
"Search": "Cerca",
"OK": "OK",
"EDIT": "MODIFICA",
"UPLOAD": "CARICA",
"RETRY": "RIPROVA",
"OPEN IN BROWSER": "APRI NEL BROWSER",
"YES": "SI",
"NO": "NO",
"Language testing unconclusive, automatic detection failed": "Impossibile determinare lingua",
"Video cannot be imported because OpenSubtitles could not be reached. Is it online?": "Il Video non può essere importato, OpenSubtitles è online?",
"Unknown OpenSubtitles related error, please retry later or report the issue": "Errore sconosciuto di OpenSubtitles, riprova o segnala il problema",
"IMDB id mancante per il file. Raccomndimamo di inserirlo, per categorizzarlo meglio e rendere facile il download.": "IMDB id mancante per il file. Raccomndimamo di inserirlo, per categorizzarlo meglio e rendere facile il download.",
"Wrong username or password": "Username o Password Errati",
"Not found": "Non Trovato",
"Wrong IMDB id": "IMDB id errato",
"New version available, download %s now!": "Aggiornamento disponibile, download %s in corso!",
"Dropped file is not supported": "Il file inserito non è supportato",
"Cut": "Taglia",
"Copy": "Copia",
"Paste": "Incolla",
"Subtitle was already present in the database": "Sottotitolo già esistente",
"The hash has been added!": "Hash inserito!",
"The hash too...": "L'hash è lo stesso...",
"The file name has been added!": "Nome file inserito!",
"The file name too...": "Il nome file è lo stesso...",
"Subtitle was successfully uploaded!": "Sottotitolo caricato correttamente!",
"OpenSubtitles is temporarily unavailable, please retry in a little while": "OpenSubtitles è irragiungibile, riprova tra poco",
"OpenSubtitles is under maintenance, please retry in a few hours": "OpenSubtitles è in manutenzione, riprova tra qualche ora (CEST 08:30)",
"Something went wrong :(": "Qualcosa è andato storto :(",
"IMDB id": "IMDB id",
"Switch theme": "Cambia Tema",
"Formato sottotitolo non valido, controllalo prima di caricarlo su OpenSubtitles (Rimuovi gli url, spam e effetti ASS non consentiti)": "Formato sottotitolo non valido, controllalo prima di caricarlo su OpenSubtitles (Rimuovi gli url, spam e effetti ASS non consentiti)",
"Il sottotitolo contiene descrizioni delle scene, interiezioni e dialoghi specifici per i non udenti": "Il sottotitolo contiene descrizioni delle scene, interiezioni e dialoghi specifici per i non udenti",
"The subtitles were translated automatically by a machine": "I sottotitoli sono stati tradotti automaticamente",
"Foreign parts only": "Solo Forzati",
"The subtitles only translate non-native parts of the script, for example elvish and orkish in the Lord of the Rings": "The subtitles only translate non-native parts of the script, for example elvish and orkish in the Lord of the Rings",
"Replace the currently loaded file with the detected one: %s": "Sostituisci file precedente con quello attuale: %s",
"Settings": "Impostazioni",
"Theme": "Temi",
"Check for updates": "Controlla aggiornamenti",
"help translating": "Aiuta a tradurre",
"Import file(s)": "Importa file",
"Clear file(s)": "Chiudi file",
"Close popup(s)": "Chiudi popup",
"Developer tools": "Strumenti Sviluppatore",
"Next field": "Scheda successiva",
"Previous field": "Scheda precendente",
"Report an issue": "Segnala un proglena (eng)",
"Use HTTPS": "Usa HTTPS",
"This IMDB id could not be checked, be careful with your upload": "This IMDB id could not be checked, be careful with your upload"

TypeScript type definitions

Please add TypeScript type definitions to this when you can.

I know this has been suggested before. But it seems like they gave the impression that this project needs to be converted to TS. Instead, just a type declaration file is needed to be created.

A simple example, is if the project has a single function like:

function sum(a, b) {
  return a + b;
}

Then the type declaration file is:

export function sum(a: number, b: number): number;

Which simply defines the types needed for the inputs and outputs. This is in turn, used by IDEs like VS Code to show to the user, in type hints.

Please at least leave this issue open, so that this can be built over time, or if you have time.

Typo in document

For Identify method It Should be:
OpenSubtitles.identify({
path: 'C:\video\file.mp4',
extended: true
extend:true
})
.then(function (data) {
console.log(data);
});

It takes a look at the source code for someone to figure out. Its better to edit the docs.

Missing data in search

Hi,

Looking for FPS, I am not able to find it when I use search.

Adding it in search.js

tmp.fps = sub.MovieFPS;

or better

tmp.fps = parseFloat(sub.MovieFPS);

Works. I can do it.

Thanks.

New NPM release

Would you please publish the current master code to NPM? That will make it cleaner for me to use it

Failed to compile on npm run build

Hi, after create a app using create-react-app, and npm install --save opensubtitles-api and add:
import OS from 'opensubtitles-api';
when i run npm run build I get this error:

Failed to compile.

Failed to minify the code from this file:

    ./node_modules/opensubtitles-api/lib/hash.js:5

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: react-scripts build
npm ERR! Exit status 1

And the logfile:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]prebuild: [email protected]
6 info lifecycle [email protected]
build: [email protected]
7 verbose lifecycle [email protected]build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\ReactProjects\player\node_modules.bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\ProgramData\ComposerSetup\bin;C:\Program Files\nodejs;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Users\alex_\AppData\Local\Microsoft\WindowsApps;D:\xampp\php;C:\Users\alex_\AppData\Roaming\Composer\vendor\bin;C:\Users\alex_\AppData\Roaming\npm;D:\Android\sdk\platform-tools;C:\Users\alex_\AppData\Local\atom\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
9 verbose lifecycle [email protected]build: CWD: D:\ReactProjects\player
10 silly lifecycle [email protected]
build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle [email protected]build: Returned: code: 1 signal: null
12 info lifecycle [email protected]
build: Failed to exec build script
13 verbose stack Error: [email protected] build: react-scripts build
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack at emitTwo (events.js:135:13)
13 verbose stack at EventEmitter.emit (events.js:224:7)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:135:13)
13 verbose stack at ChildProcess.emit (events.js:224:7)
13 verbose stack at maybeClose (internal/child_process.js:943:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid [email protected]
15 verbose cwd D:\ReactProjects\player
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
18 verbose node v9.1.0
19 verbose npm v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: react-scripts build
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I'm missing something?

Cannot get authorized

Hi.

I'm trying to login with my credentials, but always get 401 Unauthorized. I use OSTestUserAgent UserAgent, as recommended in the documentation. I tried both plain text and md5 encrypted password.

Suggestion: TypeScript

I saw #42 but it seems the user didn't follow up with reasoning for the suggestion when asked, and I am willing to.

I really value the simple features that TypeScript offers, I find they help me write more accurate code, and spend less time learning the code.

To use a basic example, if we take https://github.com/vankasteelj/opensubtitles-api/blob/master/index.js#L144

hash(path) {
  if (!path) throw Error('Missing path')
  return libhash.computeHash(path)
}

There is nothing here that tells me what type of data I expect path to contain, and more importantly I don't know what to expect it to return. It turns out that it returns an object like:

{
  moviehash: string,
  moviebytesize: string
}

but in order to know that, you need to go into computeHash itself https://github.com/vankasteelj/opensubtitles-api/blob/master/lib/hash.js#L51 and find the resolve part.

Instead it could be like this:

interface ComputedFileInfo {
  moviehash: string;
  moviebytesize: string;
}

hash(path: string): ComputedFileInfo {
  if (!path) throw Error('Missing path')
  return libhash.computeHash(path)
}

and in IDEs we can just hover over that custom type ComputedFileInfo to see what we can expect to be returned.

Happy to rant more about it if it still doesn't seem like a good choice

How does GetAvailableTranslations work?

I am trying to get all the available subtitle languages for a given movie, will GetAvailableTranslations help me?

I really don't understand this function, it takes 2 args: token, program. What do they mean by program?

Thanks

error to investigate

I encountered an error in butter (using ccc:datenspuren), need to test and check what's up

subtitleProvider.fetch() TypeError: Cannot read property 'SubFormat' of undefined
    at E:\GIT\butter-desktop\node_modules\opensubtitles-api\lib\search.js:167:45
    at arrayEach (E:\GIT\butter-desktop\node_modules\opensubtitles-api\node_modules\lodash\lodash.js:537:11)
    at Function.forEach (E:\GIT\butter-desktop\node_modules\opensubtitles-api\node_modules\lodash\lodash.js:9344:14)
    at E:\GIT\butter-desktop\node_modules\opensubtitles-api\lib\search.js:165:11
    at Promise._execute (E:\GIT\butter-desktop\node_modules\bluebird\js\release\debuggability.js:299:9)
    at Promise._resolveFromExecutor (E:\GIT\butter-desktop\node_modules\bluebird\js\release\promise.js:481:18)
    at new Promise (E:\GIT\butter-desktop\node_modules\bluebird\js\release\promise.js:77:14)
    at LibSearch.optimizeSubs (E:\GIT\butter-desktop\node_modules\opensubtitles-api\lib\search.js:152:12)
    at E:\GIT\butter-desktop\node_modules\opensubtitles-api\index.js:98:30

Tag Matches Increase by # of tags not by matching tags

There is a small error when calculating matching tags.

This leads to subfile names having a higher score when they have a higher number of tags, not just matching tags.

I have fixed this error in a PR and the results are better matching subtitles

OpenSubtitles.search() not returning anything.

I am trying to use the OpenSubtitles API NPM package in my electron App.

OpenSubtitles API
https://github.com/vankasteelj/opensubtitles-api

However there is problem.

When i run this command to search for subtitles for a specified movie using its IMDB id and then sorting the results for a specific language:

	const OpenSubtitlesApi = require('opensubtitles-api');
	const OpenSubtitles = new OpenSubtitlesApi({
    	useragent:'UserAgent',
    	username: 'username',
    	password: 'password1',
    	ssl: true
	});

    OpenSubtitles.search({
    	sublanguageid: 'eng',
    	extensions: ['srt', 'vtt'],
    	imdbid: "tt0322259",
    	limit: 3
    }).then(res => {
    	console.log(res);
    }).catch(err => {
		console.log(err);
	);

It should respond with an object / array like this:

{
	0:
		date: "2011-05-15 13:19:33"
		downloads: 54215
		encoding: "CP850"
		filename: "The.Fast.And.The.Furious.II.2003.BluRay.720p.x264.DTS-WiKi.eng.srt"
		format: "srt"
		fps: 23.976
		id: "1952859375"
		lang: "English"
		langcode: "en"
		score: 0.5
		url: "https://dl.opensubtitles.org/en/download/src-api/vrf-19dd0c5f/sid-3DRrLRTBf9EAZEfRVAnmx,rlso0/filead/1952859375"
		utf8: "https://dl.opensubtitles.org/en/download/subencoding-utf8/src-api/vrf-19dd0c5f/sid-3DRrLRTBf9EAZEfRVAnmx,rlso0/filead/1952859375"
		vtt: "https://dl.opensubtitles.org/en/download/subformat-vtt/src-api/vrf-19dd0c5f/sid-3DRrLRTBf9EAZEfRVAnmx,rlso0/filead/1952859375"
}

But instead i get nothing. It doesnt error, otherwise the catch() would have caught it.

I have tried running the entire thing inside a SetInterval(() => {}, 100); where it will eventually return a response and then shortly error because i am spamming the openSubtitles servers.

The function is placed inside a $(document).ready(); which should wait for the document to be loaded, before proceeding - and it is also placed inside a setTimeout(() => {}, 5000); function to make sure the document is finished loading.

I have a suspiscion it is because it exists the .then() before it finishes and therefore it doesnt console.log(); the response it receieves? How do i test this further, or how do i stop it from exiting the then() if that is why this happens.

It might also be because it is thrown into a queue and not ended correctly, because when i paste the exact same function to call OpenSubtitles.Search() and paste it into the DevTools console, the response is the original call in the document.

Really hoping someone can help me out here :).

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.