def download_best_subtitles(videos, languages, min_score=0, hearing_impaired=False, only_one=False, compute_score=None, pool_class=ProviderPool, **kwargs):
 downloaded_subtitles = defaultdict(list)
 checked_videos = []
 for video in videos:
  if (not check_video(video, languages=languages, undefined=only_one)):
   logger.info('Skipping video %r', video)
   continue
  checked_videos.append(video)
 if (not checked_videos):
  return downloaded_subtitles
 with pool_class(**kwargs) as pool:
  for video in checked_videos:
   logger.info('Downloading best subtitles for %r', video)
   subtitles = pool.download_best_subtitles(pool.list_subtitles(video, (languages - video.subtitle_languages)), video, languages, min_score=min_score, hearing_impaired=hearing_impaired, only_one=only_one, compute_score=compute_score)
   logger.info('Downloaded %d subtitle(s)', len(subtitles))
   downloaded_subtitles[video].extend(subtitles)
 return downloaded_subtitles

def download_best_subtitles ( videos , languages , min_score = 0 , hearing_impaired = False , only_one = False , compute_score = None , pool_class = ProviderPool , ** kwargs ) : downloaded_subtitles = defaultdict ( list ) checked_videos = [ ] for video in videos : if ( not check_video ( video , languages = languages , undefined = only_one ) ) : logger . info ( 'Skipping video %r' , video ) continue checked_videos . append ( video ) if ( not checked_videos ) : return downloaded_subtitles with pool_class ( ** kwargs ) as pool : for video in checked_videos : logger . info ( 'Downloading best subtitles for %r' , video ) subtitles = pool . download_best_subtitles ( pool . list_subtitles ( video , ( languages - video . subtitle_languages ) ) , video , languages , min_score = min_score , hearing_impaired = hearing_impaired , only_one = only_one , compute_score = compute_score ) logger . info ( 'Downloaded %d subtitle(s)' , len ( subtitles ) ) downloaded_subtitles [ video ] . extend ( subtitles ) return downloaded_subtitles
list and download the best matching subtitles .