예제 #1
0
 /// <summary>
 /// Initializes a progress report.
 /// </summary>
 /// <param name="percent">The percentage of completion</param>
 /// <param name="finishedItem">The item that was queried</param>
 /// <param name="success">Whether the query was successful</param>
 /// <param name="error">The exception message in case the query was not successful</param>
 /// <param name="time">The time at which the query was completed</param>
 /// <param name="count">The percentage of completion</param>
 public ProgressReport(float percent, FetchedItem finishedItem, bool success, string error, DateTime time, int count)
 {
     this.percent      = percent;
     this.finishedItem = finishedItem;
     this.success      = success;
     this.error        = error;
     this.time         = time;
     this.count        = count;
 }
예제 #2
0
        /// <summary>
        /// Downloads a fetched item to disk.
        /// </summary>
        /// <param name="item">The item to download</param>
        public async Task RipAsync(FetchedItem item)
        {
            // Create the directory tree
            var dir = Path.GetDirectoryName(item.path);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            // Try to get the stream from the server
            var uri = item.uri.StartsWith("/") ? new Uri(Domain, item.uri) : new Uri(item.uri);

            SetHeaders();
            var response = await httpClient.GetStreamAsync(uri);

            // Copy it to a file
            using (var fs = new FileStream(item.path, FileMode.Create))
            {
                await response.CopyToAsync(fs);
            }
        }