Skip to content

Commit

Permalink
ttvdb: use levenshtein from MythTV.utilities in mythbindings
Browse files Browse the repository at this point in the history
* less dependencies and works just as well
refs #13514
  • Loading branch information
mspieth committed Nov 21, 2019
1 parent 0353355 commit 7767658
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions mythtv/bindings/python/MythTV/ttvdb/tvdb_api.py
Expand Up @@ -16,7 +16,7 @@
import warnings
import logging
import datetime
from fuzzywuzzy import process
from MythTV.utility import levenshtein


"""Simple-to-use Python interface to The TVDB's API (thetvdb.com)
Expand Down Expand Up @@ -945,14 +945,10 @@ def _getSeries(self, series, by_id=False):
ui = ConsoleUI(config=self.config)

if self.config['sort_series']:
lookup = dict()
choices = list()
for i, s in enumerate(allSeries):
lookup[s[u'seriesName']] = i
choices.append(s[u'seriesName'])
seriesList2 = process.extract(series, choices)
allSeries2 = [allSeries[lookup[si[0]]] for si in seriesList2]
return ui.selectSeries(allSeries2)
series_lowercase = series.lower()
for s in allSeries:
s[u'match_similarity'] = levenshtein(series_lowercase, s[u'seriesName'].lower())
allSeries.sort(key=lambda s: s[u'match_similarity'])

return ui.selectSeries(allSeries)

Expand Down

0 comments on commit 7767658

Please sign in to comment.