YouTubeDownload(TransferManager manager, YouTubeCrawledSearchResult sr) {
    this.manager = manager;
    this.sr = sr;
    this.downloadType = buildDownloadType(sr);
    this.size = sr.getSize();

    String filename = sr.getFilename();

    File savePath = SystemPaths.getTorrentData();

    ensureDirectoryExits(savePath);
    ensureDirectoryExits(SystemPaths.getTemp());

    completeFile = buildFile(savePath, filename);
    tempVideo = buildTempFile(FilenameUtils.getBaseName(filename), "m4v");
    tempAudio = buildTempFile(FilenameUtils.getBaseName(filename), "m4a");

    bytesReceived = 0;
    dateCreated = new Date();

    httpClientListener = new HttpDownloadListenerImpl();

    httpClient = HttpClientFactory.getInstance(HttpClientFactory.HttpContext.DOWNLOAD);
    httpClient.setListener(httpClientListener);

    if (TransferManager.isCurrentMountAlmostFull()) {
      this.status = STATUS_ERROR_DISK_FULL;
    }
  }
 private static File buildTempFile(String name, String ext) {
   return new File(SystemPaths.getTemp(), name + "." + ext);
 }