当前位置: 首页>>代码示例>>C#>>正文


C# Net.HttpRequestOptions类代码示例

本文整理汇总了C#中MediaBrowser.Common.Net.HttpRequestOptions的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestOptions类的具体用法?C# HttpRequestOptions怎么用?C# HttpRequestOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequestOptions类属于MediaBrowser.Common.Net命名空间,在下文中一共展示了HttpRequestOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BeforeExecute

 protected override void BeforeExecute(HttpRequestOptions options)
 {
     options.RequestHeaders.Add("ClientId", "95add99f-9445-49f4-aa85-5ef3f77ac032");
     options.UserAgent = "TouTvApp/2.0.13,(iPad3.1; iOS/8.1.2; fr-ca)";
     options.AcceptHeader = "application/json";
     base.BeforeExecute(options);
 }
开发者ID:algel,项目名称:Emby.Channels,代码行数:7,代码来源:PresentationService.cs

示例2: DownloadNews

        private async Task DownloadNews(string path)
        {
            DateTime? lastUpdate = null;

			if (_fileSystem.FileExists(path))
            {
                lastUpdate = _fileSystem.GetLastWriteTimeUtc(path);
            }

            var requestOptions = new HttpRequestOptions
            {
                Url = "http://emby.media/community/index.php?/blog/rss/1-media-browser-developers-blog",
                Progress = new Progress<double>(),
                UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.42 Safari/537.36",
                BufferContent = false
            };

            using (var stream = await _httpClient.Get(requestOptions).ConfigureAwait(false))
            {
                var doc = new XmlDocument();
                doc.Load(stream);

                var news = ParseRssItems(doc).ToList();

                _json.SerializeToFile(news, path);

                await CreateNotifications(news, lastUpdate, CancellationToken.None).ConfigureAwait(false);
            }
        }
开发者ID:t-andre,项目名称:Emby,代码行数:29,代码来源:NewsEntryPoint.cs

示例3: GetDeviceInfo

 public async Task GetDeviceInfo(CancellationToken cancellationToken)
 {
     var httpOptions = new HttpRequestOptions()
     {
         Url = string.Format("{0}/", getWebUrl()),
         CancellationToken = cancellationToken
     };
     using (var stream = await _httpClient.Get(httpOptions))
     {
         using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8))
         {
             while (!sr.EndOfStream)
             {
                 string line = StringHelper.StripXML(sr.ReadLine());
                 if (line.StartsWith("Model:")) { model = line.Replace("Model: ", ""); }
                 if (line.StartsWith("Device ID:")) { deviceID = line.Replace("Device ID: ", ""); }
                 if (line.StartsWith("Firmware:")) { firmware = line.Replace("Firmware: ", ""); }
             }
             if (String.IsNullOrWhiteSpace(model))
             {
                 throw new ApplicationException("Failed to locate the tuner host.");
             }
         }
     }
 }
开发者ID:heksesang,项目名称:Emby.Plugins,代码行数:25,代码来源:HdHomeRun.cs

示例4: DownloadNews

        private async Task DownloadNews(string path)
        {
            DateTime? lastUpdate = null;

            if (File.Exists(path))
            {
                lastUpdate = _fileSystem.GetLastWriteTimeUtc(path);
            }

            var requestOptions = new HttpRequestOptions
            {
                Url = "http://emby.media/community/index.php?/blog/rss/1-media-browser-developers-blog",
                Progress = new Progress<double>()
            };

            using (var stream = await _httpClient.Get(requestOptions).ConfigureAwait(false))
            {
                var doc = new XmlDocument();
                doc.Load(stream);

                var news = ParseRssItems(doc).ToList();

                _json.SerializeToFile(news, path);

                await CreateNotifications(news, lastUpdate, CancellationToken.None).ConfigureAwait(false);
            }
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:27,代码来源:NewsEntryPoint.cs

示例5: InitiateSession

        /// <summary>
        /// Initiate the nextPvr session
        /// </summary>
        private async Task InitiateSession(CancellationToken cancellationToken)
        {
            _logger.Info("[NextPvr] Start InitiateSession");
            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/Util/NPVR/Client/Instantiate", baseUrl)
            };

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                var clientKeys = new InstantiateResponse().GetClientKeys(stream, _jsonSerializer, _logger);

                var sid = clientKeys.sid;
                var salt = clientKeys.salt;
                _logger.Info(string.Format("[NextPvr] Sid: {0}", sid));

                var loggedIn = await Login(sid, salt, cancellationToken).ConfigureAwait(false);

                if (loggedIn)
                {
                    _logger.Info("[NextPvr] Session initiated.");
                    Sid = sid;
                }
            }
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:31,代码来源:LiveTvService.cs

示例6: Record

        public async Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
        {
            var httpRequestOptions = new HttpRequestOptions()
            {
                Url = mediaSource.Path
            };

            httpRequestOptions.BufferContent = false;

            using (var response = await _httpClient.SendAsync(httpRequestOptions, "GET").ConfigureAwait(false))
            {
                _logger.Info("Opened recording stream from tuner provider");

                using (var output = _fileSystem.GetFileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    onStarted();

                    _logger.Info("Copying recording stream to file {0}", targetFile);

                    // The media source if infinite so we need to handle stopping ourselves
                    var durationToken = new CancellationTokenSource(duration);
                    cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;

                    await CopyUntilCancelled(response.Content, output, cancellationToken).ConfigureAwait(false);
                }
            }

            _logger.Info("Recording completed to file {0}", targetFile);
        }
开发者ID:t-andre,项目名称:Emby,代码行数:29,代码来源:DirectRecorder.cs

示例7: SubscribeAsync

        public async Task SubscribeAsync(string url, 
            string ip, 
            int port, 
            string localIp, 
            int eventport, 
            int timeOut = 3600)
        {
            var options = new HttpRequestOptions
            {
                Url = url,
                UserAgent = USERAGENT,
                LogRequest = _config.Configuration.DlnaOptions.EnableDebugLogging
            };

            options.RequestHeaders["HOST"] = ip + ":" + port.ToString(_usCulture);
            options.RequestHeaders["CALLBACK"] = "<" + localIp + ":" + eventport.ToString(_usCulture) + ">";
            options.RequestHeaders["NT"] = "upnp:event";
            options.RequestHeaders["TIMEOUT"] = "Second-" + timeOut.ToString(_usCulture);

            // TODO: Method should be SUBSCRIBE
            // https://github.com/stormboy/node-upnp-controlpoint/blob/master/lib/upnp-service.js#L106
            using (await _httpClient.Get(options).ConfigureAwait(false))
            {
            }
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:25,代码来源:SsdpHttpClient.cs

示例8: GetImage

        public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
        {
            var channelItem = (IChannelItem)item;

            var imageResponse = new DynamicImageResponse();

            if (!string.IsNullOrEmpty(channelItem.OriginalImageUrl))
            {
                var options = new HttpRequestOptions
                {
                    CancellationToken = cancellationToken,
                    Url = channelItem.OriginalImageUrl
                };

                var response = await _httpClient.GetResponse(options).ConfigureAwait(false);

                if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
                {
                    imageResponse.HasImage = true;
                    imageResponse.Stream = response.Content;
                    imageResponse.SetFormatFromMimeType(response.ContentType);
                }
                else
                {
                    _logger.Error("Provider did not return an image content type.");
                }
            }

            return imageResponse;
        }
开发者ID:Sile626,项目名称:MediaBrowser,代码行数:30,代码来源:ChannelItemImageProvider.cs

示例9: Refresh

        public async Task<IEnumerable<ChannelItemInfo>> Refresh(IProviderManager providerManager,
            IHttpClient httpClient,
            string url,
            INotificationManager notificationManager,
            CancellationToken cancellationToken)
        {
            var options = new HttpRequestOptions
            {
                Url = url,
                CancellationToken = cancellationToken,

                // Seeing some deflate stream errors
                EnableHttpCompression = false
            };

            using (Stream stream = await httpClient.Get(options).ConfigureAwait(false))
            {
                using (var reader = new StreamReader(stream))
                {
                    XDocument document = XDocument.Parse(reader.ReadToEnd());
                    var x = from c in document.Root.Element("channel").Elements("item") select c;

                    return x.Select(CreatePodcast).Where(i => i != null);
                }
            }
        }
开发者ID:curtisghanson,项目名称:Emby.Channels,代码行数:26,代码来源:RSSFeed.cs

示例10: GetChannelsInternal

        protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
        {
            var options = new HttpRequestOptions
            {
                Url = string.Format("{0}/lineup.json", GetApiUrl(info, false)),
                CancellationToken = cancellationToken
            };
            using (var stream = await _httpClient.Get(options))
            {
                var root = JsonSerializer.DeserializeFromStream<List<Channels>>(stream);

                if (root != null)
                {
                    var result = root.Select(i => new ChannelInfo
                    {
                        Name = i.GuideName,
                        Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture),
                        Id = ChannelIdPrefix + i.GuideNumber.ToString(CultureInfo.InvariantCulture),
                        IsFavorite = i.Favorite

                    });

                    if (info.ImportFavoritesOnly)
                    {
                        result = result.Where(i => (i.IsFavorite ?? true)).ToList();
                    }

                    return result;
                }
                return new List<ChannelInfo>();
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:32,代码来源:HdHomerunHost.cs

示例11: CheckForUpdateResult

        public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename, CancellationToken cancellationToken)
        {
            var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository);

            var options = new HttpRequestOptions
            {
                Url = url,
                EnableKeepAlive = false,
                CancellationToken = cancellationToken,
                UserAgent = "Emby/3.0"

            };

            if (_cacheLength.Ticks > 0)
            {
                options.CacheMode = CacheMode.Unconditional;
                options.CacheLength = _cacheLength;
            }

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream);

                return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename);
            }
        }
开发者ID:paul-777,项目名称:Emby,代码行数:26,代码来源:GithubUpdater.cs

示例12: GetChannels

        public async Task<IEnumerable<ChannelInfo>> GetChannels(CancellationToken cancellationToken)
        {
            ChannelList = new List<ChannelInfo>();
           
            var options = new HttpRequestOptions()
            {
                Url = string.Format("http://{0}/LiveTv/Channels?api_key={1}", Url,ApiKey),
                CancellationToken = cancellationToken,
                AcceptHeader = "application/json"
            };
           
            using (var stream = await _httpClient.Get(options))
            {

                var root = _jsonSerializer.DeserializeFromStream<ChannelResponse>(stream);
                channels = root.Items;
                _logger.Info("Found " + root.Items.Count() + "channels on host: " );
                if (root.Items != null)
                {
                    ChannelList = root.Items.Select(i => new ChannelInfo
                    {
                        Name = i.Name,
                        Number = i.Number,
                        Id = i.Number
                    }).ToList();

                }
                return ChannelList;
            }
        }
开发者ID:ryu4000,项目名称:MediaBrowser.Plugins,代码行数:30,代码来源:Emby.cs

示例13: GetImage

        public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
        {
            var liveTvItem = (LiveTvProgram)item;

            var imageResponse = new DynamicImageResponse();

            if (!string.IsNullOrEmpty(liveTvItem.ProviderImagePath))
            {
                imageResponse.Path = liveTvItem.ProviderImagePath;
                imageResponse.HasImage = true;
            }
            else if (!string.IsNullOrEmpty(liveTvItem.ProviderImageUrl))
            {
                var options = new HttpRequestOptions
                {
                    CancellationToken = cancellationToken,
                    Url = liveTvItem.ProviderImageUrl
                };

                var response = await _httpClient.GetResponse(options).ConfigureAwait(false);

                if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
                {
                    imageResponse.HasImage = true;
                    imageResponse.Stream = response.Content;
                    imageResponse.SetFormatFromMimeType(response.ContentType);
                }
                else
                {
                    _logger.Error("Provider did not return an image content type.");
                }
            }
            else if (liveTvItem.HasProviderImage ?? true)
            {
                var service = _liveTvManager.Services.FirstOrDefault(i => string.Equals(i.Name, liveTvItem.ServiceName, StringComparison.OrdinalIgnoreCase));

                if (service != null)
                {
                    try
                    {
                        var channel = _liveTvManager.GetInternalChannel(liveTvItem.ChannelId);

                        var response = await service.GetProgramImageAsync(liveTvItem.ExternalId, channel.ExternalId, cancellationToken).ConfigureAwait(false);

                        if (response != null)
                        {
                            imageResponse.HasImage = true;
                            imageResponse.Stream = response.Stream;
                            imageResponse.Format = response.Format;
                        }
                    }
                    catch (NotImplementedException)
                    {
                    }
                }
            }

            return imageResponse;
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:59,代码来源:ProgramImageProvider.cs

示例14: BeforeExecute

 protected override void BeforeExecute(HttpRequestOptions options)
 {
     var authorization = "Bearer " + AccessToken;
     options.RequestHeaders.Add("Authorization", authorization);
     options.UserAgent = "TouTvApp/2.0.13,(iPad3.1; iOS/8.1.2; fr-ca)";
     options.AcceptHeader = "application/json";
     base.BeforeExecute(options);
 }
开发者ID:algel,项目名称:Emby.Channels,代码行数:8,代码来源:MediaValidationV2Service.cs

示例15: RecordInternal

        public async Task RecordInternal(MediaSourceInfo mediaSource, string tempFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
        {
            var httpRequestOptions = new HttpRequestOptions()
            {
                Url = mediaSource.Path
            };

            httpRequestOptions.BufferContent = false;

            using (var response = await _httpClient.SendAsync(httpRequestOptions, "GET").ConfigureAwait(false))
            {
                _logger.Info("Opened recording stream from tuner provider");

                Directory.CreateDirectory(Path.GetDirectoryName(tempFile));

                using (var output = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    //onStarted();

                    _logger.Info("Copying recording stream to file {0}", tempFile);

                    var bufferMs = 5000;

                    if (mediaSource.RunTimeTicks.HasValue)
                    {
                        // The media source already has a fixed duration
                        // But add another stop 1 minute later just in case the recording gets stuck for any reason
                        var durationToken = new CancellationTokenSource(duration.Add(TimeSpan.FromMinutes(1)));
                        cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
                    }
                    else
                    {
                        // The media source if infinite so we need to handle stopping ourselves
                        var durationToken = new CancellationTokenSource(duration.Add(TimeSpan.FromMilliseconds(bufferMs)));
                        cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
                    }

                    var tempFileTask = response.Content.CopyToAsync(output, StreamDefaults.DefaultCopyToBufferSize, cancellationToken);

                    // Give the temp file a little time to build up
                    await Task.Delay(bufferMs, cancellationToken).ConfigureAwait(false);

                    var recordTask = Task.Run(() => RecordFromFile(mediaSource, tempFile, targetFile, duration, onStarted, cancellationToken), cancellationToken);

                    await tempFileTask.ConfigureAwait(false);

                    await recordTask.ConfigureAwait(false);
                }
            }

            _logger.Info("Recording completed to file {0}", targetFile);
        }
开发者ID:softworkz,项目名称:Emby,代码行数:52,代码来源:EncodedRecorder.cs


注:本文中的MediaBrowser.Common.Net.HttpRequestOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。