void singleStreamDownload(String fullpath, YoutubeVideoStreamedItem item) { FileStream outFile = null; try { outFile = new FileStream(fullpath, FileMode.Create); string mimeType; ItemProgressMax = 1; ItemProgress = 0; ItemInfo = "Downloading: " + fullpath; StreamUtils.readHttpRequest(new Uri(item.Location), outFile, out mimeType, CancellationToken, downloadProgressCallback); ItemProgressMax = 1; ItemProgress = 1; outFile.Close(); } catch (Exception e) { InfoMessages.Add("Error downloading: " + fullpath + " " + e.Message); if (outFile != null) { outFile.Close(); File.Delete(fullpath); } return; } }
private void downloadAndMuxStreams(string fullpath, YoutubeVideoStreamedItem videoStream, YoutubeVideoStreamedItem audioStream) { TotalProgress = 0; ItemProgressMax = 100; Dictionary <String, Object> options = new Dictionary <string, object>(); options.Add("videoStreamMode", StreamOptions.Copy); options.Add("audioStreamMode", StreamOptions.Copy); ItemProgress = 0; ItemInfo = "Downloading and muxing: " + videoStream.Name; try { OpenVideoArgs openArgs = new OpenVideoArgs(videoStream.Location, null, audioStream.Location, null); videoTranscoder.transcode(openArgs, fullpath, CancellationToken, options, muxingProgressCallback); } catch (Exception e) { InfoMessages.Add("Error muxing: " + e.Message); try { File.Delete(fullpath); } catch (Exception ex) { InfoMessages.Add("Error deleting: " + fullpath + " " + ex.Message); } return; } ItemProgress = 100; }