Example #1
0
        protected override IntelligentString GetDescription(IntelligentString seperator)
        {
            IntelligentString description = IntelligentString.Empty;

            if (!IntelligentString.IsNullOrEmpty(Genre))
            {
                description += Genre.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Program))
            {
                description += Program.Trim() + seperator;
            }

            if (Series != 0)
            {
                description += "Series " + Series.ToString() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(EpisodeOfString))
            {
                description += "Episode " + EpisodeOfString + seperator;
            }

            if (description.EndsWith(seperator))
            {
                description = description.Substring(0, description.Length - seperator.Length);
            }

            return(description.Trim());
        }
        private static IntelligentString AppendTrailingSlash(IntelligentString value)
        {
            if (!value.EndsWith("\\"))
            {
                value += "\\";
            }

            return(value);
        }
Example #3
0
        protected override IntelligentString GetDescription(IntelligentString seperator)
        {
            IntelligentString description = IntelligentString.Empty;

            if (!IntelligentString.IsNullOrEmpty(Genre))
            {
                description += Genre.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Artist))
            {
                description += Artist.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Album))
            {
                description += Album.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(DiskNumberOfString))
            {
                description += "Disk " + DiskNumberOfString + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(TrackNumberOfString))
            {
                description += "Track " + TrackNumberOfString + seperator;
            }

            if (description.EndsWith(seperator))
            {
                description = description.Substring(0, description.Length - seperator.Length);
            }

            return(description.Trim());
        }
Example #4
0
        /// <summary>
        /// Gets the media items that need to be organised from the specified collection
        /// </summary>
        /// <param name="mediaItems">Collection of media items being checked</param>
        /// <param name="rootFolders">Collection of root folders the media items could be organised into</param>
        /// <param name="organiseHiddenMediaItems">Value determining whether or not hidden media items should be organised</param>
        /// <param name="organiseMissingMediaItems">Value determining whether or not media items with missing parts should be organised</param>
        /// <returns>Media items that need to be organised from the specified collection</returns>
        private static OrganisingMediaItemPart[] GetTypedUnorganisedMediaItems(MediaItem[] mediaItems, RootFolder[] rootFolders, Boolean?organiseHiddenMediaItems, Boolean organiseMissingMediaItems)
        {
            if (rootFolders.Length == 0)
            {
                return(new OrganisingMediaItemPart[0]);
            }

            List <OrganisingMediaItemPart> unorganised = new List <OrganisingMediaItemPart>();

            foreach (MediaItem mediaItem in mediaItems)
            {
                if (organiseHiddenMediaItems.HasValue)
                {
                    if (mediaItem.IsHidden != organiseHiddenMediaItems.Value)
                    {
                        continue;
                    }
                }

                if (!organiseMissingMediaItems)
                {
                    if (!mediaItem.Parts.PartsExist)
                    {
                        continue;
                    }
                }

                foreach (MediaItemPart part in mediaItem.Parts)
                {
                    Boolean isPartOrgnised = false;
                    Boolean requiresMove   = true;

                    IntelligentString organisedPath = mediaItem.Parts.GetPartOrganisedPath(mediaItem.OrganisedPath, part.Index);

                    foreach (RootFolder rootFolder in rootFolders)
                    {
                        IntelligentString rootFolderPath = rootFolder.Path;

                        if (!rootFolderPath.EndsWith("\\"))
                        {
                            rootFolderPath += "\\";
                        }

                        IntelligentString fullOrganisedPath = rootFolderPath + organisedPath;

                        if (part.Location == fullOrganisedPath)
                        {
                            isPartOrgnised = true;
                            requiresMove   = false;
                            break;
                        }
                    }

                    FileInfo fi           = new FileInfo(part.Location.Value);
                    Boolean  isFileHidden = ((fi.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);

                    if (isFileHidden != mediaItem.IsHidden)
                    {
                        isPartOrgnised = false;
                    }

                    if (!isPartOrgnised)
                    {
                        unorganised.Add(new OrganisingMediaItemPart(mediaItem, part.Index, organisedPath, requiresMove));
                    }
                }
            }

            return(unorganised.ToArray());
        }