public DualSourceHTTPDownloader(DualSourceHTTPDownloadInfo info, IHttpClient hc = null, AuthenticationInfo?authentication = null, ProxyInfo?proxy = null, BaseMediaProcessor mediaProcessor = null) { Id = Guid.NewGuid().ToString(); var uri1 = new Uri(info.Uri1); var uri2 = new Uri(info.Uri2); this.state = new DualSourceHTTPDownloaderState { Url1 = uri1, Url2 = uri2, Id = Id, Cookies1 = info.Cookies1, Cookies2 = info.Cookies2, Headers1 = info.Headers1, Headers2 = info.Headers2, TempDir = Path.Combine(Config.Instance.TempDir, Id), Authentication = authentication, Proxy = proxy }; if (this.state.Authentication == null) { this.state.Authentication = Helpers.GetAuthenticationInfoFromConfig(this.state.Url1); } this.http = hc; this.TargetFileName = FileHelper.SanitizeFileName(info.File); this.mediaProcessor = mediaProcessor; }
public SingleSourceHTTPDownloader(SingleSourceHTTPDownloadInfo info, IHttpClient?hc = null, AuthenticationInfo?authentication = null, ProxyInfo?proxy = null, BaseMediaProcessor mediaProcessor = null, bool convertToMp3 = false) { Id = Guid.NewGuid().ToString(); this.state = new SingleSourceHTTPDownloaderState { Url = new Uri(info.Uri), Id = this.Id, Cookies = info.Cookies, Headers = info.Headers, TempDir = Path.Combine(Config.Instance.TempDir, Id), Authentication = authentication, Proxy = proxy, ConvertToMp3 = convertToMp3 }; if (this.state.Headers == null) { this.CreateDefaultHeaders(); } if (this.state.Authentication == null) { this.state.Authentication = Helpers.GetAuthenticationInfoFromConfig(this.state.Url); } this.TargetFileName = FileHelper.SanitizeFileName(info.File); this.http = hc; this.mediaProcessor = mediaProcessor; }
public DualSourceHTTPDownloader(string id, IHttpClient http = null, BaseMediaProcessor mediaProcessor = null) { Id = id; cancelFlag = new(); this.http = http; this.mediaProcessor = mediaProcessor; }
public MultiSourceHLSDownloader(MultiSourceHLSDownloadInfo info, IHttpClient http = null, BaseMediaProcessor mediaProcessor = null, AuthenticationInfo?authentication = null, ProxyInfo?proxy = null) : base(info, http, mediaProcessor) { var state = new MultiSourceHLSDownloadState { Id = base.Id, Cookies = info.Cookies, Headers = info.Headers, Authentication = authentication, Proxy = proxy, TempDirectory = Path.Combine(Config.Instance.TempDir, Id) }; if (state.Authentication == null) { state.Authentication = Helpers.GetAuthenticationInfoFromConfig(new Uri(info.VideoUri ?? info.AudioUri)); } Log.Debug("Video playlist url: " + info.VideoUri + " Audio playlist url: " + info.AudioUri); if (info.VideoUri != null && info.AudioUri != null) { state.NonMuxedVideoPlaylistUrl = new Uri(info.VideoUri); state.NonMuxedAudioPlaylistUrl = new Uri(info.AudioUri); state.Demuxed = true; } else { state.MuxedPlaylistUrl = new Uri(info.VideoUri); state.Demuxed = false; } this._state = state; this.TargetFileName = FileHelper.SanitizeFileName(info.File); }
public MultiSourceHLSDownloader(string id, IHttpClient http = null, BaseMediaProcessor mediaProcessor = null) : base(id, http, mediaProcessor) { }
public MultiSourceDASHDownloader(MultiSourceDASHDownloadInfo info, IHttpClient http = null, BaseMediaProcessor mediaProcessor = null, AuthenticationInfo?authentication = null, ProxyInfo?proxy = null) : base(info, http, mediaProcessor) { var state = new MultiSourceDASHDownloadState { Id = base.Id, Demuxed = info.VideoSegments != null && info.AudioSegments != null, Cookies = info.Cookies, Headers = info.Headers, Url = info.Url, Authentication = authentication, Proxy = proxy, TempDirectory = Path.Combine(Config.Instance.TempDir, Id) }; if (state.Authentication == null) { state.Authentication = Helpers.GetAuthenticationInfoFromConfig(new Uri(info.Url)); } this._state = state; this.TargetFileName = FileHelper.SanitizeFileName(info.File); state.FileSize = -1; var i = 0; if (state.Demuxed) { state.AudioChunkCount = info.AudioSegments.Count; state.VideoChunkCount = info.VideoSegments.Count; state.AudioSegments = info.AudioSegments; state.VideoSegments = info.VideoSegments; state.Duration = info.Duration; state.AudioContainerFormat = info.AudioFormat ?? FileExtensionHelper.GetExtensionFromMimeType(info.AudioMimeType) ?? GuessContainerFormatFromPlaylist(info.AudioSegments); state.VideoContainerFormat = info.VideoFormat ?? FileExtensionHelper.GetExtensionFromMimeType(info.VideoMimeType) ?? GuessContainerFormatFromPlaylist(info.VideoSegments); CreateChunks2(state, _chunks, _chunkStreamMap); //for (; i < Math.Min(this._state.AudioChunkCount, this._state.VideoChunkCount); i++) //{ // var chunk1 = CreateChunk(info.VideoSegments[i], 0); // _chunks.Add(chunk1); // _chunkStreamMap.StreamMap[chunk1.Id] = Path.Combine(_state.TempDirectory, "1_" + chunk1.Id + FileHelper.GetFileName(chunk1.Uri)); // var chunk2 = CreateChunk(info.AudioSegments[i], 1); // _chunks.Add(chunk2); // _chunkStreamMap.StreamMap[chunk2.Id] = Path.Combine(_state.TempDirectory, "2_" + chunk2.Id + FileHelper.GetFileName(chunk2.Uri)); //} //for (; i < this._state.VideoChunkCount; i++) //{ // var chunk = CreateChunk(info.VideoSegments[i], 0); // _chunks.Add(chunk); // _chunkStreamMap.StreamMap[chunk.Id] = Path.Combine(_state.TempDirectory, "1_" + chunk.Id + FileHelper.GetFileName(chunk.Uri)); //} //for (; i < this._state.AudioChunkCount; i++) //{ // var chunk = CreateChunk(info.AudioSegments[i], 1); // _chunks.Add(chunk); // _chunkStreamMap.StreamMap[chunk.Id] = Path.Combine(_state.TempDirectory, "2_" + chunk.Id + FileHelper.GetFileName(chunk.Uri)); //} var ext = FileExtensionHelper.GetExtensionFromMimeType(info.VideoMimeType) ?? FileExtensionHelper.GuessContainerFormatFromSegmentExtension(state.VideoContainerFormat); //if (!(string.IsNullOrWhiteSpace(state.VideoContainerFormat) || state.VideoContainerFormat == ".")) //{ // ext = Helpers.GetExtensionFromMimeType(info.VideoMimeType) // ?? Helpers.GuessContainerFormatFromSegmentExtension( // state.VideoContainerFormat.ToLowerInvariant(), true); //} TargetFileName = Path.GetFileNameWithoutExtension(TargetFileName ?? "video") + ext; } else { var segments = info.VideoSegments ?? info.AudioSegments; state.VideoChunkCount = segments.Count; state.VideoSegments = segments; state.Duration = info.Duration; CreateChunks1(state, _chunks, _chunkStreamMap); //for (; i < this._state.VideoChunkCount; i++) //{ // var chunk = CreateChunk(segments[i], 0); // _chunks.Add(chunk); // _chunkStreamMap.StreamMap[chunk.Id] = Path.Combine(_state.TempDirectory, "1_" + chunk.Id + FileHelper.GetFileName(chunk.Uri)); //} state.VideoContainerFormat = GuessContainerFormatFromPlaylist(segments); var ext = FileExtensionHelper.GuessContainerFormatFromSegmentExtension( this._state.VideoContainerFormat.ToLowerInvariant()); TargetFileName = Path.GetFileNameWithoutExtension(TargetFileName ?? "video") + ext; } }