def consume_task(task, services=None):
 if (services is None):
  services = {}
 logger.info((u'Consuming %r' % task))
 result = None
 if isinstance(task, ListTask):
  service = get_service(services, task.service, config=task.config)
  result = service.list(task.video, task.languages)
 elif isinstance(task, DownloadTask):
  for subtitle in task.subtitles:
   service = get_service(services, subtitle.service)
   try:
    service.download(subtitle)
    result = [subtitle]
    break
   except DownloadFailedError:
    logger.warning((u'Could not download subtitle %r, trying next' % subtitle))
    continue
  if (result is None):
   logger.error((u'No subtitles could be downloaded for video %r' % task.video))
 return result

def consume_task ( task , services = None ) : if ( services is None ) : services = { } logger . info ( ( u'Consuming %r' % task ) ) result = None if isinstance ( task , ListTask ) : service = get_service ( services , task . service , config = task . config ) result = service . list ( task . video , task . languages ) elif isinstance ( task , DownloadTask ) : for subtitle in task . subtitles : service = get_service ( services , subtitle . service ) try : service . download ( subtitle ) result = [ subtitle ] break except DownloadFailedError : logger . warning ( ( u'Could not download subtitle %r, trying next' % subtitle ) ) continue if ( result is None ) : logger . error ( ( u'No subtitles could be downloaded for video %r' % task . video ) ) return result
consume a task .