Пример #1
0
 @Override
 protected Object doCall() throws DownloadFailedException {
   final String outputFilename =
       TokenReplacer.replaceAll(downloaders.getDownloadOutput(), getEpisode());
   final String outputTmpFileName = outputFilename + TMP;
   // delete to prevent resuming since most of the download can't resume
   final File outputFile = new File(outputFilename);
   // create download dir if doesn't exist
   if (outputFile.getParentFile() != null && !outputFile.getParentFile().exists()) {
     outputFile.getParentFile().mkdir();
   }
   if (outputFile.exists()) {
     if (!outputFile.delete()) {
       throw new TechnicalException("can't delete file " + outputFile.getAbsolutePath());
     }
   }
   download(outputTmpFileName);
   File file = new File(outputTmpFileName);
   if (!file.exists()) {
     file = findFileWithoutExtension(outputFilename);
   }
   try {
     Files.move(file.toPath(), new File(outputFilename).toPath());
   } catch (IOException e) {
     throw new TechnicalException(e);
   }
   return null;
 }
Пример #2
0
  @Override
  public ProcessHolder download(
      final DownloadParamDTO downloadParam, final DownloaderPluginHolder downloaders)
      throws DownloadFailedException {
    final String downloaderBin = getBinParam(downloaders);
    String cmd = downloaderBin + CurlConf.CURL_CMD;
    cmd =
        cmd.replaceFirst(
            FrameworkConf.DOWNLOAD_INPUT,
            Matcher.quoteReplacement(downloadParam.getDownloadInput()));
    cmd =
        cmd.replaceFirst(
            FrameworkConf.DOWNLOAD_DESTINATION,
            Matcher.quoteReplacement(downloadParam.getDownloadOutput()));

    if (protocol2proxy != null) {
      final ProxyDTO httpProxy = protocol2proxy.get(ProxyDTO.ProtocolEnum.HTTP);
      if (httpProxy != null) {
        cmd += "--proxy " + httpProxy.getHost() + ":" + httpProxy.getPort();
      }
    }

    try {
      return (new CurlCmdExecutor(downloaders.getCmdProcessor(), cmd));
    } catch (final ExecutorFailedException e) {
      throw new DownloadFailedException(e);
    }
  }
Пример #3
0
 @Override
 public String toString() {
   return "DL"
       + getEpisode()
       + " "
       + (provider == null ? "no provider" : provider.getName())
       + " "
       + downloaders.getDownloadOutput();
 }
Пример #4
0
 @Override
 public int hashCode() {
   return getEpisode().hashCode() + downloaders.hashCode();
 }