Skip to content

Commit

Permalink
Always use IMDB ID too When Searching for Subs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba authored May 31, 2020
1 parent d7020a6 commit fd4aedd
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions src/components/Player/components/SubtitleText/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import ControlActions from '../Controls/actions';
import subUtil from '../../utils/subtitles';
import ls from 'local-storage';
import _ from 'lodash';
import nameToImdb from 'name-to-imdb';
import parseVideo from 'video-name-parser';
import player from '../../utils/player';
import parser from '../../utils/parser';

class SubtitleActions {

Expand Down Expand Up @@ -37,6 +40,24 @@ class SubtitleActions {
if (itemDesc.path)
subQuery.filepath = itemDesc.path

if (itemDesc.byteSize)
subQuery.byteLength = itemDesc.byteSize;

if (itemDesc.torrentHash) {
subQuery.torrentHash = itemDesc.torrentHash;
subQuery.isFinished = false;
}

subQuery.cb = subs => {
if (!subs) {
if (!ls.isSet('playerNotifs') || ls('playerNotifs'))
player.notifier.info('Subtitles Not Found', '', 6000);
cb && cb(false);
} else {
this.actions.foundSubs(subs, true, idx, cb);
}
}

if (window.getExtendedDetails) {
if (itemDesc.parsed) {

Expand All @@ -55,23 +76,23 @@ class SubtitleActions {
subQuery.query = window.extendedTitle
}
window.getExtendedDetails = null
}

if (itemDesc.byteSize)
subQuery.byteLength = itemDesc.byteSize;

if (itemDesc.torrentHash) {
subQuery.torrentHash = itemDesc.torrentHash;
subQuery.isFinished = false;
}

subQuery.cb = subs => {
if (!subs) {
if (!ls.isSet('playerNotifs') || ls('playerNotifs'))
player.notifier.info('Subtitles Not Found', '', 6000);
cb && cb(false);
} else {
this.actions.foundSubs(subs, true, idx, cb);
} else if (subQuery.filepath) {
var filename = parser(subQuery.filepath).filename();
var parsedFilename = parseVideo(filename);
if (parsedFilename) {
nameToImdb(parsedFilename, function(err, res, inf) {
if (res) {
subQuery.imdbid = res;

if (parsedFilename.type == 'series' && parsedFilename.season && (parsedFilename.episode || []).length) {
subQuery.season = parsedFilename.season + '';
subQuery.episode = parsedFilename.episode[0] + '';
}
}

subUtil.fetchSubs(subQuery);
})
return
}
}

Expand Down

0 comments on commit fd4aedd

Please sign in to comment.