jaruba / PowderPlayer

Hybrid between a Torrent Client and a Player (torrent streaming) -
https://powder.media/
GNU Lesser General Public License v2.1
586 stars 95 forks source link

[OpenSubtitles] Manual Search #91

Open samukets opened 8 years ago

samukets commented 8 years ago

Button to navigate on OpenSubtitle will be a good feature:

image

Magnetlink to justify the necessity:

magnet:?xt=urn:btih:8CFA725050F0050B92E57CA0A010BAE0A0F104A8

samukets commented 8 years ago

Test trying to load Portuguese subtitle...

jaruba commented 8 years ago

A search form? Like VLSub?

vlsub_2

jaruba commented 8 years ago

Or just a link to the search on the OpenSubtitles site that already includes filename and file hash?

samukets commented 8 years ago

A search form like VLsub is a good idea with title using file name pré-loaded... Good ideia

jaruba commented 8 years ago

@vankasteelj any thoughts on this? :)

vankasteelj commented 8 years ago

Using filename is useless, it's already what happens when querying the api with opensubtitles-api

If you absolutely want a search input for OpenSubtitles: what I'm using with OpenSubtitles-Uploader is a trick to prefill the search bar:

    var clearName = function(name) {
        var title = require('path').parse(name).name;
        return title
            .replace(/(400|480|720|1080)[pix]/gi, '') // quality clean
            .replace(/[xh]26\d|hevc|xvid|divx|aac/gi, '') // codecs
            .replace(/bluray|bdrip|brrip|dsr|dvdrip|dvd\Wrip|hdtv|\Wts\W|telesync|\Wcam\W/gi, '') // source
            .replace(/\Wextended\W|\Wproper/ig, '') // specials
            .replace(/[\.]/g, ' ') // has '.'
            .replace(/^\[.*\]/, '') // starts with brackets
            .replace(/\[(\w|\d)+\]/g, '') // remove brackets
            .replace(/\((\w|\d)+\)/g, '') // remove parenthesis
            .replace(/_/g, ' ') // has '_'
            .replace(/-/g, ' ') // has '-'
            .replace(/\-$/, '') // ends with '-'
            .replace(/\s.$/, '') // ends with ' '
            .replace(/^\./, '') // starts with '.'
            .replace(/^\-/, '') // starts with '-'
            .replace(/ +/g, ' '); // has multiple spaces
    };

    var getTitle = function (filename) {
        var begin_title = [],
            clean_title = [],
            count = 0,
            toPush = 0,
            title = clearName(filename).split(' ');

        for (var t in title) {
            if (!title[t].match(/^(the|an|19\d{2}|20\d{2}|a|of|in)$/i)) {
                clean_title.push(title[t]);
                toPush++;
            }
        }
        for (var u in clean_title) {
            if (count < (toPush > 5 ? 4 : toPush - 1) ) {
                begin_title.push(clean_title[u]);
                count++;
            }
        }
        return begin_title.join(' ');
    };

then:

getTitle('The.Hateful.Eight.2015.1080p.BluRay.H264.AAC-RARBG.mp4');

returns Hateful Eight


But in general, if OpenSubtitles can't match your file with the things already being used in Powder, there's little chance a manual search will do any good. You'd better look at, maybe, automating a Google request (for example: open in browser 'https://google.com/?q=' + getTitle(filename) + ' ' + i18n.__('subtitle') + ' ' + i18n.getLocale();). Because I'm not aware of other good apis for subtitles, so this would probably lead to addic7ed as first result 80% of the time, and other like tvsubtitles the rest of the time.

IMO, if you create an entire search feature for OpenSubtitles, you won't get better results than with the actual search.


Note: I'm basing myself on how powder-react is currently behaving, with the imdb and such, I'm not sure what 0.97 knows about file metadatas.

jaruba commented 8 years ago

@vankasteelj Powder v0.98 (released today), searches for everything that react-powder does except imdb id. (and in the same way too)

As your module merges imdb and hash searches, I see how it may be lacking the entire subtitle list. You made very good points about this though.