Skip to content

Commit

Permalink
fix(subtitles): fixes wrong levenshtein order direction
Browse files Browse the repository at this point in the history
  • Loading branch information
naholyr committed Sep 29, 2017
1 parent 33ceaae commit 6321320
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const selectSubtitle = (lang/*:string*/, log/*:Function*/, show/*:?Show*/) => (a
return Promise.resolve(null)
}

// Sort by similarity asc (= levenshtein desc), date desc
// Sort by similarity desc (= levenshtein asc), date desc
const dn = show && qs.parse(show.url).dn // Use magnet's dn when possible (more info about releaser)
const title = show ? dn || show.title : null
debug('Reference title to sort subtitles', { show, title })
Expand All @@ -255,7 +255,7 @@ const selectSubtitle = (lang/*:string*/, log/*:Function*/, show/*:?Show*/) => (a
const l1 = levenshtein(title, s1.MovieReleaseName)
const l2 = levenshtein(title, s2.MovieReleaseName)
debug('Levenshtein', { title, s1: s1.MovieReleaseName, s2: s2.MovieReleaseName, l1, l2 })
if (l1 !== l2) return l2 - l1;
if (l1 !== l2) return l1 - l2;
// else: fallback to date when title distance is the same
}
const d1 = new Date(s1.SubAddDate)
Expand Down

0 comments on commit 6321320

Please sign in to comment.