public FileDownload(string token, string workingDir, string dest) { this.dest = dest; this.id = token; this.workingDir = workingDir; this.downloaded = true; this.probeInfo = null; this.failed = false; }
public FileDownload(string token, string url, string workingDir, string dest) { this.dest = dest; this.id = token; this.url = url; this.workingDir = workingDir; this.complete = false; this.failed = false; this.probeInfo = null; }
public void Download() { try { if (downloaded) { if (this.probeInfo == null) { var data = FFmpeg.ExecProbe(buildProbeArguments(this.workingDir + dest)); if (string.IsNullOrEmpty(data)) { this.complete = true; this.failed = true; log.Debug("Failed to probe information from video file"); throw new JobFailureException("Failed to probe information from video file"); } var serializer = new FastSerialize.Serializer(typeof(FastSerialize.JsonSerializerGeneric)); this.probeInfo = serializer.Deserialize <ProbeInfo>(data, false); } this.complete = true; } else { //Download the file System.Net.WebClient wc = new System.Net.WebClient(); wc.DownloadFile(url, this.workingDir + dest); if (this.probeInfo == null) { var data = FFmpeg.ExecProbe(buildProbeArguments(this.workingDir + dest)); if (string.IsNullOrEmpty(data)) { this.complete = true; this.failed = true; log.Debug("Failed to probe information from video file"); throw new JobFailureException("Failed to probe information from video file"); } var serializer = new FastSerialize.Serializer(typeof(FastSerialize.JsonSerializerGeneric)); this.probeInfo = serializer.Deserialize <ProbeInfo>(data, false); } this.downloaded = true; this.complete = true; } } catch (Exception ex) { log.Error("An error occured Download()", ex); } }
public void Download() { try { if (downloaded) { if (this.probeInfo == null) { var data = FFmpeg.ExecProbe(buildProbeArguments(this.workingDir + dest)); if (string.IsNullOrEmpty(data)) { this.complete = true; this.failed = true; log.Debug("Failed to probe information from video file"); throw new JobFailureException("Failed to probe information from video file"); } var serializer = new FastSerialize.Serializer(typeof(FastSerialize.JsonSerializerGeneric)); this.probeInfo = serializer.Deserialize<ProbeInfo>(data, false); } this.complete = true; } else { //Download the file System.Net.WebClient wc = new System.Net.WebClient(); wc.DownloadFile(url, this.workingDir + dest); if (this.probeInfo == null) { var data = FFmpeg.ExecProbe(buildProbeArguments(this.workingDir + dest)); if (string.IsNullOrEmpty(data)) { this.complete = true; this.failed = true; log.Debug("Failed to probe information from video file"); throw new JobFailureException("Failed to probe information from video file"); } var serializer = new FastSerialize.Serializer(typeof(FastSerialize.JsonSerializerGeneric)); this.probeInfo = serializer.Deserialize<ProbeInfo>(data, false); } this.downloaded = true; this.complete = true; } } catch (Exception ex) { log.Error("An error occured Download()", ex); } }