using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Threading.Tasks; using WebDav.Client; namespace Jellyfin.Plugin.Webdav { /// /// Service for interacting with WebDAV endpoints. /// public class WebDavClientService { private readonly PluginConfiguration _config; private readonly WebDavClient _client; public WebDavClientService(PluginConfiguration config) { _config = config; var parameters = new WebDavClientParams { BaseAddress = new Uri(_config.BaseUrl), Credentials = new NetworkCredential(_config.Username, _config.Password) }; _client = new WebDavClient(parameters); } /// /// List resources at the specified WebDAV path. /// public async Task> ListAsync(string path) { var response = await _client.Propfind(path).ConfigureAwait(false); return response.Resources; } /// /// Get a raw file stream from the WebDAV endpoint. /// public async Task GetStreamAsync(string path) { var response = await _client.GetRawFile(path).ConfigureAwait(false); return response.Stream; } } }