Esempio n. 1
0
 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 LibrarySection createFromSearch(string _query)
        {
            LibrarySection librarySection = null;

            if (m_owner != null && !String.IsNullOrEmpty(_query))
            {
                string searchUrl = String.Format("{0}{1}&query={2}", m_owner.SectionUrl, Search, _query);
                librarySection = new LibrarySection()
                {
                    Key = Search, SectionUrl = searchUrl, Title = String.Format("{0} '{1}'", Prompt, _query)
                };
            }
            return(librarySection);
        }
Esempio n. 3
0
 public void loadFolders(string _baseUrl, ImportManager.ProgressEventHandler _progressMessage)
 {
     if (m_folders.Count == 0)
     {
         m_folders.Clear();
         string         sectionUrl     = String.Format("{0}{1}", SectionUrl, FOLDER);
         LibrarySection librarySection = new LibrarySection()
         {
             Key     = sectionUrl.Remove(0, _baseUrl.Length),
             Title   = "",
             IsMusic = this.IsMusic
         };
         librarySection.SectionUrl = Utils.getSectionUrl(librarySection.Key, sectionUrl, _baseUrl, "");
         m_folders.Add(librarySection);
         addFolder(String.Format("{0}/", sectionUrl), _baseUrl, "", _progressMessage);
         saveToCache();
     }
 }
Esempio n. 4
0
        public IEnumerable <XElement> getSectionElements(LibrarySection _section, bool _allowDirectory)
        {
            XElement sectionElements = Utils.elementFromURL(_section.SectionUrl);

            string xpath    = _section.IsMusic ? TRACK : VIDEO;
            var    elements =
                from element in sectionElements.Elements(xpath)
                select element;

            _section.HasTracks = elements.Count() > 0;
            if (!_section.HasTracks && _allowDirectory)
            {
                return
                    (from element in sectionElements.Elements(DIRECTORY)
                     where element.Attribute("search") == null
                     select element);
            }
            return(elements);
        }
Esempio n. 5
0
        private List <LibrarySection> listFromElements(IEnumerable <XElement> _elements, string _parentUrl, bool _hasTracks, bool _isMainSection, bool _isMusicSection)
        {
            List <LibrarySection> sections = new List <LibrarySection>();

            foreach (XElement element in _elements)
            {
                string         key     = attributeValue(element, KEY);
                LibrarySection section = _isMainSection
          ? new MainSection()
                {
                    Key = key, Title = attributeValue(element, TITLE), SectionUrl = getSectionUrl(key, _parentUrl), IsMusic = _isMusicSection
                }
          : new LibrarySection()
                {
                    Key = key, Title = attributeValue(element, TITLE), SectionUrl = getSectionUrl(key, _parentUrl), HasTracks = _hasTracks, IsMusic = _isMusicSection
                };
                sections.Add(section);
                if (_isMainSection)
                {
                    ((MainSection)section).Owner = this;
                    ((MainSection)section).addLocations(element);
                    ((MainSection)section).addSearchSections();
                    if (!_isMusicSection)
                    {
                        section.IsEpisode = attributeValue(element, PMSBase.ATTR_TYPE).Equals(PMSBase.TYPE_SHOW, StringComparison.OrdinalIgnoreCase);
                    }
                }
                else
                {
                    section.IsEpisode = attributeValue(element, PMSBase.ATTR_TYPE).Equals(PMSBase.TYPE_EPISODE, StringComparison.OrdinalIgnoreCase);
                }
            }
            // CP 2015-01-26: Proposed changesfrom marc_al
            sections.Sort(new CustomLibrarySectiontringComparer());
            // CP 2015-01-26
            return(sections);
        }
Esempio n. 6
0
 public List <LibrarySection> librarySections(LibrarySection _section)
 {
     return(listFromElements(getSectionElements(_section, true), _section.SectionUrl, _section.HasTracks, false, _section.IsMusic));
 }
Esempio n. 7
0
 public IEnumerable <XElement> getSectionTracks(LibrarySection _section)
 {
     return(getSectionElements(_section, false));
 }