mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Fix importing TV shows with utf8 characters in parent folders on Windows.
Fix import; add unicode encoding for str values of args and kwargs to ek.ek on Windows. Fix incorrect logic mixing seasons (All wanted episode numbers are checked against all season, not just the season belonging to the episode number).
This commit is contained in:
parent
c8973e0618
commit
0dce254473
3 changed files with 22 additions and 12 deletions
|
@ -66,8 +66,21 @@ def fixParaLists(x):
|
|||
return x
|
||||
|
||||
|
||||
def win_encode_unicode(x):
|
||||
if isinstance(x, str):
|
||||
try:
|
||||
return x.decode('UTF-8')
|
||||
except UnicodeDecodeError:
|
||||
return x
|
||||
return x
|
||||
|
||||
|
||||
def ek(func, *args, **kwargs):
|
||||
if os.name == 'nt':
|
||||
# convert all str parameter values to unicode
|
||||
args = tuple([win_encode_unicode(x) if isinstance(x, str) else x for x in args])
|
||||
kwargs = {k: win_encode_unicode(x) if isinstance(x, str) else x for k, x in
|
||||
kwargs.iteritems()}
|
||||
result = func(*args, **kwargs)
|
||||
else:
|
||||
result = func(*[callPeopleStupid(x) if type(x) in (str, unicode) else fixParaLists(x) for x in args], **kwargs)
|
||||
|
|
|
@ -597,9 +597,9 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
|
|||
best_season_result.provider.providerType), logger.DEBUG)
|
||||
|
||||
my_db = db.DBConnection()
|
||||
sql = 'SELECT episode FROM tv_episodes WHERE showid = %s AND (season IN (%s))' %\
|
||||
sql = 'SELECT season, episode FROM tv_episodes WHERE showid = %s AND (season IN (%s))' %\
|
||||
(show.indexerid, ','.join([str(x.season) for x in episodes]))
|
||||
ep_nums = [int(x['episode']) for x in my_db.select(sql)]
|
||||
ep_nums = [(int(x['season']), int(x['episode'])) for x in my_db.select(sql)]
|
||||
|
||||
logger.log(u'Executed query: [%s]' % sql)
|
||||
logger.log(u'Episode list: %s' % ep_nums, logger.DEBUG)
|
||||
|
@ -607,11 +607,10 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
|
|||
all_wanted = True
|
||||
any_wanted = False
|
||||
for ep_num in ep_nums:
|
||||
for season in set([x.season for x in episodes]):
|
||||
if not show.wantEpisode(season, ep_num, season_qual):
|
||||
all_wanted = False
|
||||
else:
|
||||
any_wanted = True
|
||||
if not show.wantEpisode(ep_num[0], ep_num[1], season_qual):
|
||||
all_wanted = False
|
||||
else:
|
||||
any_wanted = True
|
||||
|
||||
# if we need every ep in the season and there's nothing better then just download this and
|
||||
# be done with it (unless single episodes are preferred)
|
||||
|
@ -620,8 +619,7 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
|
|||
(best_season_result.provider.providerType, best_season_result.name))
|
||||
ep_objs = []
|
||||
for ep_num in ep_nums:
|
||||
for season in set([x.season for x in episodes]):
|
||||
ep_objs.append(show.getEpisode(season, ep_num))
|
||||
ep_objs.append(show.getEpisode(ep_num[0], ep_num[1]))
|
||||
best_season_result.episodes = ep_objs
|
||||
|
||||
return [best_season_result]
|
||||
|
@ -660,8 +658,7 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
|
|||
u'the episodes that you do not want to "don\'t download"')
|
||||
ep_objs = []
|
||||
for ep_num in ep_nums:
|
||||
for season in set([x.season for x in episodes]):
|
||||
ep_objs.append(show.getEpisode(season, ep_num))
|
||||
ep_objs.append(show.getEpisode(ep_num[0], ep_num[1]))
|
||||
best_season_result.episodes = ep_objs
|
||||
|
||||
ep_num = MULTI_EP_RESULT
|
||||
|
|
|
@ -3298,7 +3298,7 @@ class NewHomeAddShows(Home):
|
|||
if not file_list:
|
||||
try:
|
||||
file_list = ek.ek(os.listdir, root_dir)
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
continue
|
||||
|
||||
for cur_file in file_list:
|
||||
|
|
Loading…
Reference in a new issue