diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-10-12 15:43:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-12 15:43:28 -0400 |
| commit | 25ef9777cafee83c46ff53ede2caa04e3295e98a (patch) | |
| tree | 5f1e6045d0b4d4d5b7d8dcaadf035b326f36e672 /MediaBrowser.Server.Implementations/Channels/ChannelManager.cs | |
| parent | 0677d4ec990aee9a3bf7bda39dda01eb6fa66281 (diff) | |
| parent | 5be6cf05e34459a046aceaa16c891f3034859476 (diff) | |
Merge pull request #2224 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Server.Implementations/Channels/ChannelManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Channels/ChannelManager.cs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index b76cf46b0..1369efae1 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -1577,97 +1577,5 @@ namespace MediaBrowser.Server.Implementations.Channels return await _libraryManager.GetNamedView(name, "channels", "zz_" + name, cancellationToken).ConfigureAwait(false); } - - public async Task DownloadChannelItem(BaseItem item, string destination, - IProgress<double> progress, CancellationToken cancellationToken) - { - var sources = await GetDynamicMediaSources(item, cancellationToken) - .ConfigureAwait(false); - - var list = sources.Where(i => i.Protocol == MediaProtocol.Http).ToList(); - - foreach (var source in list) - { - await TryDownloadChannelItem(source, item, destination, progress, cancellationToken).ConfigureAwait(false); - return; - } - } - - private async Task TryDownloadChannelItem(MediaSourceInfo source, - BaseItem item, - string destination, - IProgress<double> progress, - CancellationToken cancellationToken) - { - var options = new HttpRequestOptions - { - CancellationToken = cancellationToken, - Url = source.Path, - Progress = new Progress<double>() - }; - - var channel = GetChannel(item.ChannelId); - var channelProvider = GetChannelProvider(channel); - var features = channelProvider.GetChannelFeatures(); - - if (!features.SupportsContentDownloading) - { - throw new ArgumentException("The channel does not support downloading."); - } - - var limit = features.DailyDownloadLimit; - - foreach (var header in source.RequiredHttpHeaders) - { - options.RequestHeaders[header.Key] = header.Value; - } - - _fileSystem.CreateDirectory(Path.GetDirectoryName(destination)); - - // Determine output extension - var response = await _httpClient.GetTempFileResponse(options).ConfigureAwait(false); - - if (response.ContentType.StartsWith("text/html")) - { - throw new HttpException("File not found") - { - StatusCode = HttpStatusCode.NotFound - }; - } - - if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase) && response.ContentType.StartsWith("video/", StringComparison.OrdinalIgnoreCase)) - { - var extension = response.ContentType.Split('/') - .Last() - .Replace("quicktime", "mov", StringComparison.OrdinalIgnoreCase); - - destination += "." + extension; - } - else if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) && response.ContentType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase)) - { - var extension = response.ContentType.Replace("audio/mpeg", "audio/mp3", StringComparison.OrdinalIgnoreCase) - .Split('/') - .Last(); - - destination += "." + extension; - } - else - { - _fileSystem.DeleteFile(response.TempFilePath); - - throw new ApplicationException("Unexpected response type encountered: " + response.ContentType); - } - - _fileSystem.CopyFile(response.TempFilePath, destination, true); - - try - { - _fileSystem.DeleteFile(response.TempFilePath); - } - catch - { - - } - } } }
\ No newline at end of file |
