def download_subtitles(paths, languages=None, services=None, force=True, multi=False, cache_dir=None, max_depth=3, scan_filter=None, order=None):
 services = (services or SERVICES)
 languages = (language_list(languages) if (languages is not None) else language_list(LANGUAGES))
 if isinstance(paths, basestring):
  paths = [paths]
 order = (order or [LANGUAGE_INDEX, SERVICE_INDEX, SERVICE_CONFIDENCE, MATCHING_CONFIDENCE])
 subtitles_by_video = list_subtitles(paths, languages, services, force, multi, cache_dir, max_depth, scan_filter)
 for (video, subtitles) in subtitles_by_video.iteritems():
  subtitles.sort(key=(lambda s: key_subtitles(s, video, languages, services, order)), reverse=True)
 results = []
 service_instances = {}
 tasks = create_download_tasks(subtitles_by_video, languages, multi)
 for task in tasks:
  try:
   result = consume_task(task, service_instances)
   results.append((task.video, result))
  except:
   logger.error((u'Error consuming task %r' % task), exc_info=True)
 for service_instance in service_instances.itervalues():
  service_instance.terminate()
 return group_by_video(results)

def download_subtitles ( paths , languages = None , services = None , force = True , multi = False , cache_dir = None , max_depth = 3 , scan_filter = None , order = None ) : services = ( services or SERVICES ) languages = ( language_list ( languages ) if ( languages is not None ) else language_list ( LANGUAGES ) ) if isinstance ( paths , basestring ) : paths = [ paths ] order = ( order or [ LANGUAGE_INDEX , SERVICE_INDEX , SERVICE_CONFIDENCE , MATCHING_CONFIDENCE ] ) subtitles_by_video = list_subtitles ( paths , languages , services , force , multi , cache_dir , max_depth , scan_filter ) for ( video , subtitles ) in subtitles_by_video . iteritems ( ) : subtitles . sort ( key = ( lambda s : key_subtitles ( s , video , languages , services , order ) ) , reverse = True ) results = [ ] service_instances = { } tasks = create_download_tasks ( subtitles_by_video , languages , multi ) for task in tasks : try : result = consume_task ( task , service_instances ) results . append ( ( task . video , result ) ) except : logger . error ( ( u'Error consuming task %r' % task ) , exc_info = True ) for service_instance in service_instances . itervalues ( ) : service_instance . terminate ( ) return group_by_video ( results )
download :attr:~subliminal .