aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
blob: 76541e0efe51df6834af6c6dbd63449e8f4aa728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Entities.TV;

namespace MediaBrowser.Controller.Resolvers
{
    public static class EntityResolutionHelper
    {
        /// <summary>
        /// Any folder named in this list will be ignored - can be added to at runtime for extensibility
        /// </summary>
        public static List<string> IgnoreFolders = new List<string>()
        {
            "trailers",
            "metadata",
            "bdmv",
            "certificate",
            "backup",
            "video_ts",
            "audio_ts",
            "ps3_update",
            "ps3_vprm"
        };
        /// <summary>
        /// Determines whether a path should be resolved or ignored entirely - called before we even look at the contents
        /// </summary>
        /// <param name="path"></param>
        /// <returns>false if the path should be ignored</returns>
        public static bool ShouldResolvePath(WIN32_FIND_DATA path)
        {
            bool resolve = true;
            // Ignore hidden files and folders
            if (path.IsHidden || path.IsSystemFile)
            {
                resolve = false;
            }

            // Ignore any folders in our list
            else if (path.IsDirectory && IgnoreFolders.Contains(Path.GetFileName(path.Path), StringComparer.OrdinalIgnoreCase))
            {
                resolve =  false;
            }

            return resolve;
        }

        /// <summary>
        /// Determines whether a path should be ignored based on its contents - called after the contents have been read
        /// </summary>
        public static bool ShouldResolvePathContents(ItemResolveEventArgs args)
        {
            bool resolve = true;
            if (args.ContainsFile(".ignore"))
            {
                // Ignore any folders containing a file called .ignore
                resolve = false;
            }

            return resolve;
        }
    }
}