protected void addFolder(string _url, string _baseUrl, string _parentTitle, ImportManager.ProgressEventHandler _progressMessage) { if (!String.IsNullOrEmpty(_url)) { if (_progressMessage != null) { _progressMessage(_parentTitle, false); } XElement folderElements = Utils.elementFromURL(_url); var elements = from element in folderElements.Elements(PMSBase.DIRECTORY) select element; foreach (XElement folderSection in elements) { LibrarySection librarySection = new LibrarySection() { Key = PMSBase.attributeValue(folderSection, PMSBase.KEY), Title = _parentTitle + PMSBase.attributeValue(folderSection, PMSBase.TITLE), IsMusic = this.IsMusic }; librarySection.SectionUrl = Utils.getSectionUrl(librarySection.Key, _url, _baseUrl, ""); m_folders.Add(librarySection); Debug.WriteLine(String.Format("{0} - {1}", librarySection.Key, librarySection.Title)); addFolder(Utils.getSectionUrl(librarySection.Key, _url, _baseUrl, ""), _baseUrl, String.Format("{0}{1}", librarySection.Title, PMSServer.DirectorySeparator), _progressMessage); } } }
public void addLocations(XElement _sectionElement) { if (_sectionElement != null) { var locations = from location in _sectionElement.Elements("Location") select location; foreach (XElement locationSection in locations) { m_locations.Add(PMSBase.attributeValue(locationSection, PATH)); } } }
public void addSearchSections() { m_searchSections.Clear(); XElement sectionElements = Utils.elementFromURL(SectionUrl); var elements = from element in sectionElements.Elements(PMSBase.DIRECTORY) where element.Attribute(SEARCH) != null select element; foreach (XElement searchSection in elements) { m_searchSections.Add(new SearchSection(this) { Search = PMSBase.attributeValue(searchSection, PMSBase.KEY), Prompt = PMSBase.attributeValue(searchSection, PROMPT), Title = PMSBase.attributeValue(searchSection, PMSBase.TITLE) }); } }
public static bool authenticate(string _userName, string _password) { authToken = ""; try { using (var client = new WebClient()) { string url = "https://plex.tv/users/sign_in.xml"; // CP 2015-01-26: Proposed changesfrom marc_al client.Encoding = Encoding.UTF8; // CP 2015-01-26 client.Headers.Add(HEADER_ENTRY_PLEX_CLIENT, PLEX_CLIENT_IDENTIFIER); client.Headers.Add("Authorization", authHeaderVal(_userName, _password)); XElement response = XElement.Parse(client.UploadString(url, ""), LoadOptions.None); authToken = PMSBase.attributeValue(response, "authenticationToken", ""); } } catch (Exception ex) { } return(!String.IsNullOrEmpty(authToken)); }