< Summary - Jellyfin

Information
Class: Emby.Naming.Common.NamingOptions
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/Common/NamingOptions.cs
Line coverage
100%
Covered lines: 747
Uncovered lines: 0
Coverable lines: 747
Total lines: 930
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/31/2026 - 12:15:44 AM Line coverage: 100% (739/739) Total lines: 9227/26/2026 - 12:17:51 AM Line coverage: 100% (741/741) Total lines: 92410/29/2026 - 12:17:11 AM Line coverage: 100% (747/747) Total lines: 930

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Compile()100%11100%
Compile(...)100%11100%

File(s)

/srv/git/jellyfin/Emby.Naming/Common/NamingOptions.cs

#LineLine coverage
 1#pragma warning disable CA1819
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Linq;
 6using System.Text.RegularExpressions;
 7using Emby.Naming.Video;
 8using MediaBrowser.Model.Entities;
 9
 10// ReSharper disable StringLiteralTypo
 11
 12namespace Emby.Naming.Common
 13{
 14    /// <summary>
 15    /// Big ugly class containing lot of different naming options that should be split and injected instead of passes ev
 16    /// </summary>
 17    public class NamingOptions
 18    {
 19        /// <summary>
 20        /// Initializes a new instance of the <see cref="NamingOptions"/> class.
 21        /// </summary>
 22        public NamingOptions()
 23        {
 83424            VideoFileExtensions =
 83425            [
 83426                ".001",
 83427                ".3g2",
 83428                ".3gp",
 83429                ".amv",
 83430                ".asf",
 83431                ".asx",
 83432                ".avi",
 83433                ".bin",
 83434                ".bivx",
 83435                ".divx",
 83436                ".dv",
 83437                ".dvr-ms",
 83438                ".f4v",
 83439                ".fli",
 83440                ".flv",
 83441                ".ifo",
 83442                ".img",
 83443                ".iso",
 83444                ".m2t",
 83445                ".m2ts",
 83446                ".m2v",
 83447                ".m4v",
 83448                ".mkv",
 83449                ".mk3d",
 83450                ".mov",
 83451                ".mp4",
 83452                ".mpe",
 83453                ".mpeg",
 83454                ".mpg",
 83455                ".mts",
 83456                ".mxf",
 83457                ".nrg",
 83458                ".nsv",
 83459                ".nuv",
 83460                ".ogm",
 83461                ".ogv",
 83462                ".pva",
 83463                ".qt",
 83464                ".rec",
 83465                ".rm",
 83466                ".rmvb",
 83467                ".strm",
 83468                ".svq3",
 83469                ".tp",
 83470                ".ts",
 83471                ".ty",
 83472                ".viv",
 83473                ".vob",
 83474                ".vp3",
 83475                ".webm",
 83476                ".wmv",
 83477                ".wtv",
 83478                ".xvid"
 83479            ];
 80
 83481            VideoFlagDelimiters =
 83482            [
 83483                '(',
 83484                ')',
 83485                '-',
 83486                '.',
 83487                '_',
 83488                '[',
 83489                ']'
 83490            ];
 91
 83492            StubFileExtensions =
 83493            [
 83494                ".disc"
 83495            ];
 96
 83497            StubTypes =
 83498            [
 83499                new StubTypeRule(
 834100                    stubType: "dvd",
 834101                    token: "dvd"),
 834102
 834103                new StubTypeRule(
 834104                    stubType: "hddvd",
 834105                    token: "hddvd"),
 834106
 834107                new StubTypeRule(
 834108                    stubType: "bluray",
 834109                    token: "bluray"),
 834110
 834111                new StubTypeRule(
 834112                    stubType: "bluray",
 834113                    token: "brrip"),
 834114
 834115                new StubTypeRule(
 834116                    stubType: "bluray",
 834117                    token: "bd25"),
 834118
 834119                new StubTypeRule(
 834120                    stubType: "bluray",
 834121                    token: "bd50"),
 834122
 834123                new StubTypeRule(
 834124                    stubType: "vhs",
 834125                    token: "vhs"),
 834126
 834127                new StubTypeRule(
 834128                    stubType: "tv",
 834129                    token: "HDTV"),
 834130
 834131                new StubTypeRule(
 834132                    stubType: "tv",
 834133                    token: "PDTV"),
 834134
 834135                new StubTypeRule(
 834136                    stubType: "tv",
 834137                    token: "DSR")
 834138            ];
 139
 834140            VideoFileStackingRules =
 834141            [
 834142                new FileStackRule(@"^(?<filename>.*?)(?:(?<=[\]\)\}])|[ _.-]+)[\(\[]?(?<parttype>cd|dvd|part|pt|dis[ck])
 834143                new FileStackRule(@"^(?<filename>.*?)(?:(?<=[\]\)\}])|[ _.-]+)[\(\[]?(?<parttype>cd|dvd|part|pt|dis[ck])
 834144            ];
 145
 834146            CleanDateTimes =
 834147            [
 834148                @"(.+[^_\,\.\(\)\[\]\-])[_\.\(\)\[\]\-](19[0-9]{2}|20[0-9]{2})(?![0-9]+|\W[0-9]{2}\W[0-9]{2})([ _\,\.\(\
 834149                @"(.+[^_\,\.\(\)\[\]\-])[ _\.\(\)\[\]\-]+(19[0-9]{2}|20[0-9]{2})(?![0-9]+|\W[0-9]{2}\W[0-9]{2})([ _\,\.\
 834150            ];
 151
 834152            CleanStrings =
 834153            [
 834154                @"^\s*(?<cleaned>.+?)[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|d
 834155                @"^\s*(?<cleaned>.+?)((\s*\[[^\]]+\]\s*)+)(\.[^\s]+)?$",
 834156                @"^\s*(?<cleaned>.+?)\WE[0-9]+(-|~)E?[0-9]+(\W|$)",
 834157                @"^\s*\[[^\]]+\](?!\.\w+$)\s*(?<cleaned>.+)",
 834158                @"^\s*(?<cleaned>.+?)\s+-\s+[0-9]+\s*$",
 834159                @"^\s*(?<cleaned>.+?)(([-._ ](trailer|sample))|-(scene|clip|behindthescenes|deleted|deletedscene|feature
 834160            ];
 161
 834162            SubtitleFileExtensions =
 834163            [
 834164                ".ass",
 834165                ".mks",
 834166                ".sami",
 834167                ".smi",
 834168                ".srt",
 834169                ".ssa",
 834170                ".sub",
 834171                ".sup",
 834172                ".vtt",
 834173            ];
 174
 834175            LyricFileExtensions =
 834176            [
 834177                ".lrc",
 834178                ".elrc",
 834179                ".txt"
 834180            ];
 181
 834182            AlbumStackingPrefixes =
 834183            [
 834184                "cd",
 834185                "digital media",
 834186                "disc",
 834187                "disk",
 834188                "vol",
 834189                "volume",
 834190                "part",
 834191                "act"
 834192            ];
 193
 834194            ArtistSubfolders =
 834195            [
 834196                "albums",
 834197                "broadcasts",
 834198                "bootlegs",
 834199                "compilations",
 834200                "dj-mixes",
 834201                "eps",
 834202                "live",
 834203                "mixtapes",
 834204                "others",
 834205                "remixes",
 834206                "singles",
 834207                "soundtracks",
 834208                "spokenwords",
 834209                "streets"
 834210            ];
 211
 834212            AudioFileExtensions =
 834213            [
 834214                ".669",
 834215                ".3gp",
 834216                ".aa",
 834217                ".aac",
 834218                ".aax",
 834219                ".ac3",
 834220                ".act",
 834221                ".adp",
 834222                ".adplug",
 834223                ".adx",
 834224                ".afc",
 834225                ".amf",
 834226                ".aif",
 834227                ".aifc",
 834228                ".aiff",
 834229                ".alac",
 834230                ".amr",
 834231                ".ape",
 834232                ".ast",
 834233                ".au",
 834234                ".awb",
 834235                ".cda",
 834236                ".cue",
 834237                ".dmf",
 834238                ".dsf",
 834239                ".dsm",
 834240                ".dsp",
 834241                ".dts",
 834242                ".dvf",
 834243                ".eac3",
 834244                ".ec3",
 834245                ".far",
 834246                ".flac",
 834247                ".gdm",
 834248                ".gsm",
 834249                ".gym",
 834250                ".hps",
 834251                ".imf",
 834252                ".it",
 834253                ".m15",
 834254                ".m4a",
 834255                ".m4b",
 834256                ".mac",
 834257                ".med",
 834258                ".mka",
 834259                ".mmf",
 834260                ".mod",
 834261                ".mogg",
 834262                ".mp2",
 834263                ".mp3",
 834264                ".mpa",
 834265                ".mpc",
 834266                ".mpp",
 834267                ".mp+",
 834268                ".msv",
 834269                ".nmf",
 834270                ".nsf",
 834271                ".nsv",
 834272                ".oga",
 834273                ".ogg",
 834274                ".okt",
 834275                ".opus",
 834276                ".pls",
 834277                ".ra",
 834278                ".rf64",
 834279                ".rm",
 834280                ".s3m",
 834281                ".sfx",
 834282                ".shn",
 834283                ".sid",
 834284                ".stm",
 834285                ".strm",
 834286                ".ult",
 834287                ".uni",
 834288                ".vox",
 834289                ".wav",
 834290                ".wma",
 834291                ".wv",
 834292                ".xm",
 834293                ".xsp",
 834294                ".ymf"
 834295            ];
 296
 834297            MediaFlagDelimiters =
 834298            [
 834299                '.'
 834300            ];
 301
 834302            MediaForcedFlags =
 834303            [
 834304                "foreign",
 834305                "forced"
 834306            ];
 307
 834308            MediaDefaultFlags =
 834309            [
 834310                "default"
 834311            ];
 312
 834313            MediaHearingImpairedFlags =
 834314            [
 834315                "cc",
 834316                "hi",
 834317                "sdh"
 834318            ];
 319
 834320            EpisodeExpressions =
 834321            [
 834322                // *** Begin Kodi Standard Naming
 834323                // <!-- foo.s01.e01, foo.s01_e01, S01E02 foo, S01 - E02 -->
 834324                new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+))[^\\\/])*)?[Ss](?<s
 834325                {
 834326                    IsNamed = true
 834327                },
 834328                // <!-- foo.ep01, foo.EP_01 -->
 834329                new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
 834330                // <!-- foo.E01., foo.e01. -->
 834331                new EpisodeExpression(@"[^\\/]*?()\.?[Ee]([0-9]+)\.([^\\/]*)$"),
 834332                new EpisodeExpression("(?<year>[0-9]{4})[._ -](?<month>[0-9]{2})[._ -](?<day>[0-9]{2})", true)
 834333                {
 834334                    DateTimeFormats =
 834335                    [
 834336                        "yyyy.MM.dd",
 834337                        "yyyy-MM-dd",
 834338                        "yyyy_MM_dd",
 834339                        "yyyy MM dd"
 834340                    ]
 834341                },
 834342                new EpisodeExpression("(?<day>[0-9]{2})[._ -](?<month>[0-9]{2})[._ -](?<year>[0-9]{4})", true)
 834343                {
 834344                    DateTimeFormats =
 834345                    [
 834346                        "dd.MM.yyyy",
 834347                        "dd-MM-yyyy",
 834348                        "dd_MM_yyyy",
 834349                        "dd MM yyyy"
 834350                    ]
 834351                },
 834352
 834353                // This isn't a Kodi naming rule, but the expression below causes false episode numbers for
 834354                // Title Season X Episode X naming schemes.
 834355                // "Series Season X Episode X - Title.avi", "Series S03 E09.avi", "s3 e9 - Title.avi"
 834356                new EpisodeExpression(@".*[\\\/]((?<seriesname>[^\\/]+?)\s)?[Ss](?:eason)?\s*(?<seasonnumber>[0-9]+)\s+[
 834357                {
 834358                    IsNamed = true
 834359                },
 834360
 834361                // Not a Kodi rule as well, but the expression below also causes false positives,
 834362                // so we make sure this one gets tested first.
 834363                // "Foo Bar 889"
 834364                // Names carrying an SxxEyy marker are excluded because the Kodi expression above already covers them.
 834365                // Without that guard this expression reads digits out of the title instead, turning
 834366                // "S01E01 1-23-45 [Bluray-1080p]" into episodes 1 through 45.
 834367                new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?![^\\\/]*[Ss][0-9]+[][ ._-]*[Ee][0-9]+)(?<seriesname>[\w
 834368                {
 834369                    IsNamed = true
 834370                },
 834371
 834372                new EpisodeExpression(@"[\\\/\._ \[\(-]([0-9]+)x([0-9]+(?:(?:[a-i]|\.[1-9])(?![0-9]))?)([^\\\/]*)$")
 834373                {
 834374                    SupportsAbsoluteEpisodeNumbers = true
 834375                },
 834376
 834377                // Not a Kodi rule as well, but below rule also causes false positives for triple-digit episode names
 834378                // [bar] Foo - 1 [baz] special case of below expression to prevent false positives with digits in the se
 834379                new EpisodeExpression(@".*[\\\/]?.*?(\[.*?\])+.*?(?<seriesname>[-\w\s]+?)[\s_]*-[\s_]*(?<epnumber>[0-9]+
 834380                {
 834381                    IsNamed = true
 834382                },
 834383
 834384                // "Name - 101.mkv", "Name - 101 [720p].mkv", "Name - 101 (2020).mkv"
 834385                // Handles absolute episode numbers with hyphen delimiter (common in anime)
 834386                // Without brackets (bracketed version handled above)
 834387                new EpisodeExpression(@".*[\\\/](?<seriesname>[^\\\/]+?)[\s_]+-[\s_]+(?<epnumber>[0-9]+)[\s_]*(?:\[.*?\]
 834388                {
 834389                    IsNamed = true
 834390                },
 834391
 834392                // /server/anything_102.mp4
 834393                // /server/james.corden.2017.04.20.anne.hathaway.720p.hdtv.x264-crooks.mkv
 834394                // /server/anything_1996.11.14.mp4
 834395                new EpisodeExpression(@"[\\/._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/_])*)[\\\/._ -](?<seasonnumber
 834396                {
 834397                    IsOptimistic = true,
 834398                    IsNamed = true,
 834399                    SupportsAbsoluteEpisodeNumbers = false
 834400                },
 834401                new EpisodeExpression(@"[\/._ -]p(?:ar)?t[_. -]()([ivx]+|[0-9]+)([._ -][^\/]*)$")
 834402                {
 834403                    SupportsAbsoluteEpisodeNumbers = true
 834404                },
 834405
 834406                // *** End Kodi Standard Naming
 834407
 834408                // "Episode 16", "Episode 16 - Title"
 834409                new EpisodeExpression(@"[Ee]pisode (?<epnumber>[0-9]+)(-(?<endingepnumber>[0-9]+))?[^\\\/]*$")
 834410                {
 834411                    IsNamed = true
 834412                },
 834413
 834414                new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>[0-9]+)[xX](?<epnumber>[0-9]+)[^\\\/]*$")
 834415                {
 834416                    IsNamed = true
 834417                },
 834418
 834419                new EpisodeExpression(@".*(\\|\/)[sS](?<seasonnumber>[0-9]+)[x,X]?[eE](?<epnumber>[0-9]+)[^\\\/]*$")
 834420                {
 834421                    IsNamed = true
 834422                },
 834423
 834424                new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![sS]?[0-9]{1,4}[xX][0-9]{1,3})[^\\\/])*)?([sS]?(?<sea
 834425                {
 834426                    IsNamed = true
 834427                },
 834428
 834429                new EpisodeExpression(@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>[0-9]{1,4})[xX\.]?[eE](?<epn
 834430                {
 834431                    IsNamed = true
 834432                },
 834433
 834434                // "01.avi"
 834435                new EpisodeExpression(@".*[\\\/](?<epnumber>[0-9]+)(-(?<endingepnumber>[0-9]+))*\.\w+$")
 834436                {
 834437                    IsOptimistic = true,
 834438                    IsNamed = true
 834439                },
 834440
 834441                // "1-12 episode title"
 834442                new EpisodeExpression("([0-9]+)-([0-9]+)"),
 834443
 834444                // "01 - blah.avi", "01-blah.avi"
 834445                new EpisodeExpression(@".*(\\|\/)(?<epnumber>[0-9]{1,3})(-(?<endingepnumber>[0-9]{2,3}))*\s?-\s?[^\\\/]*
 834446                {
 834447                    IsOptimistic = true,
 834448                    IsNamed = true
 834449                },
 834450
 834451                // "01.blah.avi"
 834452                new EpisodeExpression(@".*(\\|\/)(?<epnumber>[0-9]{1,3})(-(?<endingepnumber>[0-9]{2,3}))*\.[^\\\/]+$")
 834453                {
 834454                    IsOptimistic = true,
 834455                    IsNamed = true
 834456                },
 834457
 834458                // "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi",
 834459                new EpisodeExpression(@".*[\\\/][^\\\/]* - (?<epnumber>[0-9]{1,3})(-(?<endingepnumber>[0-9]{2,3}))*[^\\\
 834460                {
 834461                    IsOptimistic = true,
 834462                    IsNamed = true
 834463                },
 834464
 834465                // "01 episode title.avi"
 834466                new EpisodeExpression(@"[Ss]eason[\._ ](?<seasonnumber>[0-9]+)[\\\/](?<epnumber>[0-9]{1,3})([^\\\/]*)$")
 834467                {
 834468                    IsOptimistic = true,
 834469                    IsNamed = true
 834470                },
 834471
 834472                // Series and season only expression
 834473                // "the show/season 1", "the show/s01"
 834474                new EpisodeExpression(@"(.*(\\|\/))*(?<seriesname>.+)\/[Ss](eason)?[\. _\-]*(?<seasonnumber>[0-9]+)")
 834475                {
 834476                    IsNamed = true
 834477                },
 834478
 834479                // Series and season only expression
 834480                // "the show S01", "the show season 1"
 834481                new EpisodeExpression(@"(.*(\\|\/))*(?<seriesname>.+)[\. _\-]+[sS](eason)?[\. _\-]*(?<seasonnumber>[0-9]
 834482                {
 834483                    IsNamed = true
 834484                },
 834485
 834486                // Anime style expression
 834487                // "[Group][Series Name][21][1080p][FLAC][HASH]"
 834488                // "[Group] Series Name [04][BDRIP]"
 834489                new EpisodeExpression(@"(?:\[(?:[^\]]+)\]\s*)?(?<seriesname>\[[^\]]+\]|[^[\]]+)\s*\[(?<epnumber>[0-9]+)\
 834490                {
 834491                    IsNamed = true
 834492                },
 834493            ];
 494
 834495            VideoExtraRules =
 834496            [
 834497                new ExtraRule(
 834498                    ExtraType.Trailer,
 834499                    ExtraRuleType.DirectoryName,
 834500                    "trailers",
 834501                    MediaType.Video),
 834502
 834503                new ExtraRule(
 834504                    ExtraType.ThemeVideo,
 834505                    ExtraRuleType.DirectoryName,
 834506                    "backdrops",
 834507                    MediaType.Video),
 834508
 834509                new ExtraRule(
 834510                    ExtraType.ThemeSong,
 834511                    ExtraRuleType.DirectoryName,
 834512                    "theme-music",
 834513                    MediaType.Audio),
 834514
 834515                new ExtraRule(
 834516                    ExtraType.BehindTheScenes,
 834517                    ExtraRuleType.DirectoryName,
 834518                    "behind the scenes",
 834519                    MediaType.Video),
 834520
 834521                new ExtraRule(
 834522                    ExtraType.DeletedScene,
 834523                    ExtraRuleType.DirectoryName,
 834524                    "deleted scenes",
 834525                    MediaType.Video),
 834526
 834527                new ExtraRule(
 834528                    ExtraType.Interview,
 834529                    ExtraRuleType.DirectoryName,
 834530                    "interviews",
 834531                    MediaType.Video),
 834532
 834533                new ExtraRule(
 834534                    ExtraType.Scene,
 834535                    ExtraRuleType.DirectoryName,
 834536                    "scenes",
 834537                    MediaType.Video),
 834538
 834539                new ExtraRule(
 834540                    ExtraType.Sample,
 834541                    ExtraRuleType.DirectoryName,
 834542                    "samples",
 834543                    MediaType.Video),
 834544
 834545                new ExtraRule(
 834546                    ExtraType.Sample,
 834547                    ExtraRuleType.DirectoryName,
 834548                    "sample",
 834549                    MediaType.Video),
 834550
 834551                new ExtraRule(
 834552                    ExtraType.Short,
 834553                    ExtraRuleType.DirectoryName,
 834554                    "shorts",
 834555                    MediaType.Video),
 834556
 834557                new ExtraRule(
 834558                    ExtraType.Featurette,
 834559                    ExtraRuleType.DirectoryName,
 834560                    "featurettes",
 834561                    MediaType.Video),
 834562
 834563                new ExtraRule(
 834564                    ExtraType.Unknown,
 834565                    ExtraRuleType.DirectoryName,
 834566                    "extras",
 834567                    MediaType.Video),
 834568
 834569                new ExtraRule(
 834570                    ExtraType.Unknown,
 834571                    ExtraRuleType.DirectoryName,
 834572                    "extra",
 834573                    MediaType.Video),
 834574
 834575                new ExtraRule(
 834576                    ExtraType.Unknown,
 834577                    ExtraRuleType.DirectoryName,
 834578                    "other",
 834579                    MediaType.Video),
 834580
 834581                new ExtraRule(
 834582                    ExtraType.Clip,
 834583                    ExtraRuleType.DirectoryName,
 834584                    "clips",
 834585                    MediaType.Video),
 834586
 834587                new ExtraRule(
 834588                    ExtraType.Trailer,
 834589                    ExtraRuleType.Filename,
 834590                    "trailer",
 834591                    MediaType.Video),
 834592
 834593                new ExtraRule(
 834594                    ExtraType.Sample,
 834595                    ExtraRuleType.Filename,
 834596                    "sample",
 834597                    MediaType.Video),
 834598
 834599                new ExtraRule(
 834600                    ExtraType.ThemeSong,
 834601                    ExtraRuleType.Filename,
 834602                    "theme",
 834603                    MediaType.Audio),
 834604
 834605                new ExtraRule(
 834606                    ExtraType.Trailer,
 834607                    ExtraRuleType.Suffix,
 834608                    "-trailer",
 834609                    MediaType.Video),
 834610
 834611                new ExtraRule(
 834612                    ExtraType.Trailer,
 834613                    ExtraRuleType.Suffix,
 834614                    ".trailer",
 834615                    MediaType.Video),
 834616
 834617                new ExtraRule(
 834618                    ExtraType.Trailer,
 834619                    ExtraRuleType.Suffix,
 834620                    "_trailer",
 834621                    MediaType.Video),
 834622
 834623                new ExtraRule(
 834624                    ExtraType.Trailer,
 834625                    ExtraRuleType.Suffix,
 834626                    "- trailer",
 834627                    MediaType.Video),
 834628
 834629                new ExtraRule(
 834630                    ExtraType.Sample,
 834631                    ExtraRuleType.Suffix,
 834632                    "-sample",
 834633                    MediaType.Video),
 834634
 834635                new ExtraRule(
 834636                    ExtraType.Sample,
 834637                    ExtraRuleType.Suffix,
 834638                    ".sample",
 834639                    MediaType.Video),
 834640
 834641                new ExtraRule(
 834642                    ExtraType.Sample,
 834643                    ExtraRuleType.Suffix,
 834644                    "_sample",
 834645                    MediaType.Video),
 834646
 834647                new ExtraRule(
 834648                    ExtraType.Sample,
 834649                    ExtraRuleType.Suffix,
 834650                    "- sample",
 834651                    MediaType.Video),
 834652
 834653                new ExtraRule(
 834654                    ExtraType.Scene,
 834655                    ExtraRuleType.Suffix,
 834656                    "-scene",
 834657                    MediaType.Video),
 834658
 834659                new ExtraRule(
 834660                    ExtraType.Clip,
 834661                    ExtraRuleType.Suffix,
 834662                    "-clip",
 834663                    MediaType.Video),
 834664
 834665                new ExtraRule(
 834666                    ExtraType.Interview,
 834667                    ExtraRuleType.Suffix,
 834668                    "-interview",
 834669                    MediaType.Video),
 834670
 834671                new ExtraRule(
 834672                    ExtraType.BehindTheScenes,
 834673                    ExtraRuleType.Suffix,
 834674                    "-behindthescenes",
 834675                    MediaType.Video),
 834676
 834677                new ExtraRule(
 834678                    ExtraType.DeletedScene,
 834679                    ExtraRuleType.Suffix,
 834680                    "-deleted",
 834681                    MediaType.Video),
 834682
 834683                new ExtraRule(
 834684                    ExtraType.DeletedScene,
 834685                    ExtraRuleType.Suffix,
 834686                    "-deletedscene",
 834687                    MediaType.Video),
 834688
 834689                new ExtraRule(
 834690                    ExtraType.Featurette,
 834691                    ExtraRuleType.Suffix,
 834692                    "-featurette",
 834693                    MediaType.Video),
 834694
 834695                new ExtraRule(
 834696                    ExtraType.Short,
 834697                    ExtraRuleType.Suffix,
 834698                    "-short",
 834699                    MediaType.Video),
 834700
 834701                new ExtraRule(
 834702                    ExtraType.Unknown,
 834703                    ExtraRuleType.Suffix,
 834704                    "-extra",
 834705                    MediaType.Video),
 834706
 834707                new ExtraRule(
 834708                    ExtraType.Unknown,
 834709                    ExtraRuleType.Suffix,
 834710                    "-other",
 834711                    MediaType.Video)
 834712            ];
 713
 834714            AllExtrasTypesFolderNames = VideoExtraRules
 834715                .Where(i => i.RuleType == ExtraRuleType.DirectoryName)
 834716                .ToDictionary(i => i.Token, i => i.ExtraType, StringComparer.OrdinalIgnoreCase);
 717
 834718            Format3DRules =
 834719            [
 834720                // Kodi rules:
 834721                new Format3DRule(
 834722                    precedingToken: "3d",
 834723                    token: "hsbs"),
 834724
 834725                new Format3DRule(
 834726                    precedingToken: "3d",
 834727                    token: "sbs"),
 834728
 834729                new Format3DRule(
 834730                    precedingToken: "3d",
 834731                    token: "htab"),
 834732
 834733                new Format3DRule(
 834734                    precedingToken: "3d",
 834735                    token: "tab"),
 834736
 834737                 // Media Browser rules:
 834738                new Format3DRule("fsbs"),
 834739                new Format3DRule("hsbs"),
 834740                new Format3DRule("sbs"),
 834741                new Format3DRule("ftab"),
 834742                new Format3DRule("htab"),
 834743                new Format3DRule("tab"),
 834744                new Format3DRule("sbs3d"),
 834745                new Format3DRule("mvc")
 834746            ];
 747
 834748            AudioBookPartsExpressions =
 834749            [
 834750                // Detect specified chapters, like CH 01
 834751                @"ch(?:apter)?[\s_-]?(?<chapter>[0-9]+)",
 834752                // Detect specified parts, like Part 02
 834753                @"p(?:ar)?t[\s_-]?(?<part>[0-9]+)",
 834754                // Chapter is often beginning of filename
 834755                "^(?<chapter>[0-9]+)",
 834756                // Part if often ending of filename
 834757                "(?<!ch(?:apter) )(?<part>[0-9]+)$",
 834758                // Sometimes named as 0001_005 (chapter_part)
 834759                "(?<chapter>[0-9]+)_(?<part>[0-9]+)",
 834760                // Some audiobooks are ripped from cd's, and will be named by disk number.
 834761                @"dis(?:c|k)[\s_-]?(?<chapter>[0-9]+)"
 834762            ];
 763
 834764            AudioBookNamesExpressions =
 834765            [
 834766                // Detect year usually in brackets after name Batman (2020)
 834767                @"^(?<name>.+?)\s*\(\s*(?<year>[0-9]{4})\s*\)\s*$",
 834768                @"^\s*(?<name>[^ ].*?)\s*$"
 834769            ];
 770
 834771            MultipleEpisodeExpressions = new[]
 834772            {
 834773                @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?<endinge
 834774                @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[xX][eE](?<endin
 834775                @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )?[xXeE](?<endingepnumber>[
 834776                @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})(-[xE]?[eE]?(?<endingepnumber>[0-9
 834777                @".*(\\|\/)(?<seriesname>((?![sS]?[0-9]{1,4}[xX][0-9]{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>[0-9]{1,4})[
 834778                @".*(\\|\/)(?<seriesname>((?![sS]?[0-9]{1,4}[xX][0-9]{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>[0-9]{1,4})[
 834779                @".*(\\|\/)(?<seriesname>((?![sS]?[0-9]{1,4}[xX][0-9]{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>[0-9]{1,4})[
 834780                @".*(\\|\/)(?<seriesname>((?![sS]?[0-9]{1,4}[xX][0-9]{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>[0-9]{1,4})[
 834781                @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>[0-9]{1,4})[xX\.]?[eE](?<epnumber>[0-9]{1,3})((-| 
 834782                @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>[0-9]{1,4})[xX\.]?[eE](?<epnumber>[0-9]{1,3})(-[xX
 834783            }.Select(i => new EpisodeExpression(i)
 834784            {
 834785                IsNamed = true
 834786            }).ToArray();
 787
 834788            Compile();
 834789        }
 790
 791        /// <summary>
 792        /// Gets or sets the folder name to extra types mapping.
 793        /// </summary>
 794        public Dictionary<string, ExtraType> AllExtrasTypesFolderNames { get; set; }
 795
 796        /// <summary>
 797        /// Gets or sets list of audio file extensions.
 798        /// </summary>
 799        public string[] AudioFileExtensions { get; set; }
 800
 801        /// <summary>
 802        /// Gets or sets list of external media flag delimiters.
 803        /// </summary>
 804        public char[] MediaFlagDelimiters { get; set; }
 805
 806        /// <summary>
 807        /// Gets or sets list of external media forced flags.
 808        /// </summary>
 809        public string[] MediaForcedFlags { get; set; }
 810
 811        /// <summary>
 812        /// Gets or sets list of external media default flags.
 813        /// </summary>
 814        public string[] MediaDefaultFlags { get; set; }
 815
 816        /// <summary>
 817        /// Gets or sets list of external media hearing impaired flags.
 818        /// </summary>
 819        public string[] MediaHearingImpairedFlags { get; set; }
 820
 821        /// <summary>
 822        /// Gets or sets list of album stacking prefixes.
 823        /// </summary>
 824        public string[] AlbumStackingPrefixes { get; set; }
 825
 826        /// <summary>
 827        /// Gets or sets list of artist subfolders.
 828        /// </summary>
 829        public string[] ArtistSubfolders { get; set; }
 830
 831        /// <summary>
 832        /// Gets or sets list of subtitle file extensions.
 833        /// </summary>
 834        public string[] SubtitleFileExtensions { get; set; }
 835
 836        /// <summary>
 837        /// Gets the list of lyric file extensions.
 838        /// </summary>
 839        public string[] LyricFileExtensions { get; }
 840
 841        /// <summary>
 842        /// Gets or sets list of episode regular expressions.
 843        /// </summary>
 844        public EpisodeExpression[] EpisodeExpressions { get; set; }
 845
 846        /// <summary>
 847        /// Gets or sets list of video file extensions.
 848        /// </summary>
 849        public string[] VideoFileExtensions { get; set; }
 850
 851        /// <summary>
 852        /// Gets or sets list of video stub file extensions.
 853        /// </summary>
 854        public string[] StubFileExtensions { get; set; }
 855
 856        /// <summary>
 857        /// Gets or sets list of raw audiobook parts regular expressions strings.
 858        /// </summary>
 859        public string[] AudioBookPartsExpressions { get; set; }
 860
 861        /// <summary>
 862        /// Gets or sets list of raw audiobook names regular expressions strings.
 863        /// </summary>
 864        public string[] AudioBookNamesExpressions { get; set; }
 865
 866        /// <summary>
 867        /// Gets or sets list of stub type rules.
 868        /// </summary>
 869        public StubTypeRule[] StubTypes { get; set; }
 870
 871        /// <summary>
 872        /// Gets or sets list of video flag delimiters.
 873        /// </summary>
 874        public char[] VideoFlagDelimiters { get; set; }
 875
 876        /// <summary>
 877        /// Gets or sets list of 3D Format rules.
 878        /// </summary>
 879        public Format3DRule[] Format3DRules { get; set; }
 880
 881        /// <summary>
 882        /// Gets the file stacking rules.
 883        /// </summary>
 884        public FileStackRule[] VideoFileStackingRules { get; }
 885
 886        /// <summary>
 887        /// Gets or sets list of raw clean DateTimes regular expressions strings.
 888        /// </summary>
 889        public string[] CleanDateTimes { get; set; }
 890
 891        /// <summary>
 892        /// Gets or sets list of raw clean strings regular expressions strings.
 893        /// </summary>
 894        public string[] CleanStrings { get; set; }
 895
 896        /// <summary>
 897        /// Gets or sets list of multi-episode regular expressions.
 898        /// </summary>
 899        public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
 900
 901        /// <summary>
 902        /// Gets or sets list of extra rules for videos.
 903        /// </summary>
 904        public ExtraRule[] VideoExtraRules { get; set; }
 905
 906        /// <summary>
 907        /// Gets list of clean datetime regular expressions.
 908        /// </summary>
 909        public Regex[] CleanDateTimeRegexes { get; private set; } = [];
 910
 911        /// <summary>
 912        /// Gets list of clean string regular expressions.
 913        /// </summary>
 914        public Regex[] CleanStringRegexes { get; private set; } = [];
 915
 916        /// <summary>
 917        /// Compiles raw regex strings into regexes.
 918        /// </summary>
 919        public void Compile()
 920        {
 835921            CleanDateTimeRegexes = CleanDateTimes.Select(Compile).ToArray();
 835922            CleanStringRegexes = CleanStrings.Select(Compile).ToArray();
 835923        }
 924
 925        private Regex Compile(string exp)
 926        {
 6680927            return new Regex(exp, RegexOptions.IgnoreCase | RegexOptions.Compiled);
 928        }
 929    }
 930}