NamingOptions.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. #pragma warning disable CS1591
  2. #pragma warning disable SA1600
  3. using System;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6. using Emby.Naming.Video;
  7. namespace Emby.Naming.Common
  8. {
  9. public class NamingOptions
  10. {
  11. public string[] AudioFileExtensions { get; set; }
  12. public string[] AlbumStackingPrefixes { get; set; }
  13. public string[] SubtitleFileExtensions { get; set; }
  14. public char[] SubtitleFlagDelimiters { get; set; }
  15. public string[] SubtitleForcedFlags { get; set; }
  16. public string[] SubtitleDefaultFlags { get; set; }
  17. public EpisodeExpression[] EpisodeExpressions { get; set; }
  18. public string[] EpisodeWithoutSeasonExpressions { get; set; }
  19. public string[] EpisodeMultiPartExpressions { get; set; }
  20. public string[] VideoFileExtensions { get; set; }
  21. public string[] StubFileExtensions { get; set; }
  22. public string[] AudioBookPartsExpressions { get; set; }
  23. public StubTypeRule[] StubTypes { get; set; }
  24. public char[] VideoFlagDelimiters { get; set; }
  25. public Format3DRule[] Format3DRules { get; set; }
  26. public string[] VideoFileStackingExpressions { get; set; }
  27. public string[] CleanDateTimes { get; set; }
  28. public string[] CleanStrings { get; set; }
  29. public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
  30. public ExtraRule[] VideoExtraRules { get; set; }
  31. public NamingOptions()
  32. {
  33. VideoFileExtensions = new[]
  34. {
  35. ".m4v",
  36. ".3gp",
  37. ".nsv",
  38. ".ts",
  39. ".ty",
  40. ".strm",
  41. ".rm",
  42. ".rmvb",
  43. ".ifo",
  44. ".mov",
  45. ".qt",
  46. ".divx",
  47. ".xvid",
  48. ".bivx",
  49. ".vob",
  50. ".nrg",
  51. ".img",
  52. ".iso",
  53. ".pva",
  54. ".wmv",
  55. ".asf",
  56. ".asx",
  57. ".ogm",
  58. ".m2v",
  59. ".avi",
  60. ".bin",
  61. ".dvr-ms",
  62. ".mpg",
  63. ".mpeg",
  64. ".mp4",
  65. ".mkv",
  66. ".avc",
  67. ".vp3",
  68. ".svq3",
  69. ".nuv",
  70. ".viv",
  71. ".dv",
  72. ".fli",
  73. ".flv",
  74. ".001",
  75. ".tp"
  76. };
  77. VideoFlagDelimiters = new[]
  78. {
  79. '(',
  80. ')',
  81. '-',
  82. '.',
  83. '_',
  84. '[',
  85. ']'
  86. };
  87. StubFileExtensions = new[]
  88. {
  89. ".disc"
  90. };
  91. StubTypes = new[]
  92. {
  93. new StubTypeRule
  94. {
  95. StubType = "dvd",
  96. Token = "dvd"
  97. },
  98. new StubTypeRule
  99. {
  100. StubType = "hddvd",
  101. Token = "hddvd"
  102. },
  103. new StubTypeRule
  104. {
  105. StubType = "bluray",
  106. Token = "bluray"
  107. },
  108. new StubTypeRule
  109. {
  110. StubType = "bluray",
  111. Token = "brrip"
  112. },
  113. new StubTypeRule
  114. {
  115. StubType = "bluray",
  116. Token = "bd25"
  117. },
  118. new StubTypeRule
  119. {
  120. StubType = "bluray",
  121. Token = "bd50"
  122. },
  123. new StubTypeRule
  124. {
  125. StubType = "vhs",
  126. Token = "vhs"
  127. },
  128. new StubTypeRule
  129. {
  130. StubType = "tv",
  131. Token = "HDTV"
  132. },
  133. new StubTypeRule
  134. {
  135. StubType = "tv",
  136. Token = "PDTV"
  137. },
  138. new StubTypeRule
  139. {
  140. StubType = "tv",
  141. Token = "DSR"
  142. }
  143. };
  144. VideoFileStackingExpressions = new[]
  145. {
  146. "(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\\.[^.]+)$",
  147. "(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\\.[^.]+)$",
  148. "(.*?)([ ._-]*[a-d])(.*?)(\\.[^.]+)$"
  149. };
  150. CleanDateTimes = new[]
  151. {
  152. @"(.+[^ _\,\.\(\)\[\]\-])[ _\.\(\)\[\]\-]+(19[0-9][0-9]|20[0-1][0-9])([ _\,\.\(\)\[\]\-][^0-9]|$)"
  153. };
  154. CleanStrings = new[]
  155. {
  156. @"[ _\,\.\(\)\[\]\-](ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
  157. @"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
  158. @"(\[.*\])"
  159. };
  160. SubtitleFileExtensions = new[]
  161. {
  162. ".srt",
  163. ".ssa",
  164. ".ass",
  165. ".sub"
  166. };
  167. SubtitleFlagDelimiters = new[]
  168. {
  169. '.'
  170. };
  171. SubtitleForcedFlags = new[]
  172. {
  173. "foreign",
  174. "forced"
  175. };
  176. SubtitleDefaultFlags = new[]
  177. {
  178. "default"
  179. };
  180. AlbumStackingPrefixes = new[]
  181. {
  182. "disc",
  183. "cd",
  184. "disk",
  185. "vol",
  186. "volume"
  187. };
  188. AudioFileExtensions = new[]
  189. {
  190. ".nsv",
  191. ".m4a",
  192. ".flac",
  193. ".aac",
  194. ".strm",
  195. ".pls",
  196. ".rm",
  197. ".mpa",
  198. ".wav",
  199. ".wma",
  200. ".ogg",
  201. ".opus",
  202. ".mp3",
  203. ".mp2",
  204. ".mod",
  205. ".amf",
  206. ".669",
  207. ".dmf",
  208. ".dsm",
  209. ".far",
  210. ".gdm",
  211. ".imf",
  212. ".it",
  213. ".m15",
  214. ".med",
  215. ".okt",
  216. ".s3m",
  217. ".stm",
  218. ".sfx",
  219. ".ult",
  220. ".uni",
  221. ".xm",
  222. ".sid",
  223. ".ac3",
  224. ".dts",
  225. ".cue",
  226. ".aif",
  227. ".aiff",
  228. ".ape",
  229. ".mac",
  230. ".mpc",
  231. ".mp+",
  232. ".mpp",
  233. ".shn",
  234. ".wv",
  235. ".nsf",
  236. ".spc",
  237. ".gym",
  238. ".adplug",
  239. ".adx",
  240. ".dsp",
  241. ".adp",
  242. ".ymf",
  243. ".ast",
  244. ".afc",
  245. ".hps",
  246. ".xsp",
  247. ".acc",
  248. ".m4b",
  249. ".oga",
  250. ".dsf",
  251. ".mka"
  252. };
  253. EpisodeExpressions = new[]
  254. {
  255. // *** Begin Kodi Standard Naming
  256. // <!-- foo.s01.e01, foo.s01_e01, S01E02 foo, S01 - E02 -->
  257. new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+))[^\\\/])*)?[Ss](?<seasonnumber>[0-9]+)[][ ._-]*[Ee](?<epnumber>[0-9]+)([^\\/]*)$")
  258. {
  259. IsNamed = true
  260. },
  261. // <!-- foo.ep01, foo.EP_01 -->
  262. new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
  263. new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true)
  264. {
  265. DateTimeFormats = new[]
  266. {
  267. "yyyy.MM.dd",
  268. "yyyy-MM-dd",
  269. "yyyy_MM_dd"
  270. }
  271. },
  272. new EpisodeExpression("([0-9]{2})[\\.-]([0-9]{2})[\\.-]([0-9]{4})", true)
  273. {
  274. DateTimeFormats = new[]
  275. {
  276. "dd.MM.yyyy",
  277. "dd-MM-yyyy",
  278. "dd_MM_yyyy"
  279. }
  280. },
  281. // This isn't a Kodi naming rule, but the expression below causes false positives,
  282. // so we make sure this one gets tested first.
  283. // "Foo Bar 889"
  284. new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?<seriesname>[\w\s]+?)\s(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$")
  285. {
  286. IsNamed = true
  287. },
  288. new EpisodeExpression("[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")
  289. {
  290. SupportsAbsoluteEpisodeNumbers = true
  291. },
  292. new EpisodeExpression(@"[\\\\/\\._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/])*)[\\\\/\\._ -](?<seasonnumber>[0-9]+)(?<epnumber>[0-9][0-9](?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([\\._ -][^\\\\/]*)$")
  293. {
  294. IsOptimistic = true,
  295. IsNamed = true,
  296. SupportsAbsoluteEpisodeNumbers = false
  297. },
  298. new EpisodeExpression("[\\/._ -]p(?:ar)?t[_. -]()([ivx]+|[0-9]+)([._ -][^\\/]*)$")
  299. {
  300. SupportsAbsoluteEpisodeNumbers = true
  301. },
  302. // *** End Kodi Standard Naming
  303.                 // [bar] Foo - 1 [baz]
  304. new EpisodeExpression(@".*?(\[.*?\])+.*?(?<seriesname>[\w\s]+?)[-\s_]+(?<epnumber>\d+).*$")
  305. {
  306. IsNamed = true
  307. },
  308. new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d+)[xX](?<epnumber>\d+)[^\\\/]*$")
  309. {
  310. IsNamed = true
  311. },
  312. new EpisodeExpression(@".*(\\|\/)[sS](?<seasonnumber>\d+)[x,X]?[eE](?<epnumber>\d+)[^\\\/]*$")
  313. {
  314. IsNamed = true
  315. },
  316. new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d+))[^\\\/]*$")
  317. {
  318. IsNamed = true
  319. },
  320. new EpisodeExpression(@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d+)[^\\\/]*$")
  321. {
  322. IsNamed = true
  323. },
  324. // "01.avi"
  325. new EpisodeExpression(@".*[\\\/](?<epnumber>\d+)(-(?<endingepnumber>\d+))*\.\w+$")
  326. {
  327. IsOptimistic = true,
  328. IsNamed = true
  329. },
  330. // "1-12 episode title"
  331. new EpisodeExpression(@"([0-9]+)-([0-9]+)"),
  332. // "01 - blah.avi", "01-blah.avi"
  333. new EpisodeExpression(@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$")
  334. {
  335. IsOptimistic = true,
  336. IsNamed = true
  337. },
  338. // "01.blah.avi"
  339. new EpisodeExpression(@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.[^\\\/]+$")
  340. {
  341. IsOptimistic = true,
  342. IsNamed = true
  343. },
  344. // "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi", "blah 2 - 01 - blah"
  345. new EpisodeExpression(@".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$")
  346. {
  347. IsOptimistic = true,
  348. IsNamed = true
  349. },
  350. // "01 episode title.avi"
  351. new EpisodeExpression(@"[Ss]eason[\._ ](?<seasonnumber>[0-9]+)[\\\/](?<epnumber>\d{1,3})([^\\\/]*)$")
  352. {
  353. IsOptimistic = true,
  354. IsNamed = true
  355. },
  356. // "Episode 16", "Episode 16 - Title"
  357. new EpisodeExpression(@".*[\\\/][^\\\/]* (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$")
  358. {
  359. IsOptimistic = true,
  360. IsNamed = true
  361. }
  362. };
  363. EpisodeWithoutSeasonExpressions = new[]
  364. {
  365. @"[/\._ \-]()([0-9]+)(-[0-9]+)?"
  366. };
  367. EpisodeMultiPartExpressions = new[]
  368. {
  369. @"^[-_ex]+([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)"
  370. };
  371. VideoExtraRules = new[]
  372. {
  373. new ExtraRule
  374. {
  375. ExtraType = "trailer",
  376. RuleType = ExtraRuleType.Filename,
  377. Token = "trailer",
  378. MediaType = MediaType.Video
  379. },
  380. new ExtraRule
  381. {
  382. ExtraType = "trailer",
  383. RuleType = ExtraRuleType.Suffix,
  384. Token = "-trailer",
  385. MediaType = MediaType.Video
  386. },
  387. new ExtraRule
  388. {
  389. ExtraType = "trailer",
  390. RuleType = ExtraRuleType.Suffix,
  391. Token = ".trailer",
  392. MediaType = MediaType.Video
  393. },
  394. new ExtraRule
  395. {
  396. ExtraType = "trailer",
  397. RuleType = ExtraRuleType.Suffix,
  398. Token = "_trailer",
  399. MediaType = MediaType.Video
  400. },
  401. new ExtraRule
  402. {
  403. ExtraType = "trailer",
  404. RuleType = ExtraRuleType.Suffix,
  405. Token = " trailer",
  406. MediaType = MediaType.Video
  407. },
  408. new ExtraRule
  409. {
  410. ExtraType = "sample",
  411. RuleType = ExtraRuleType.Filename,
  412. Token = "sample",
  413. MediaType = MediaType.Video
  414. },
  415. new ExtraRule
  416. {
  417. ExtraType = "sample",
  418. RuleType = ExtraRuleType.Suffix,
  419. Token = "-sample",
  420. MediaType = MediaType.Video
  421. },
  422. new ExtraRule
  423. {
  424. ExtraType = "sample",
  425. RuleType = ExtraRuleType.Suffix,
  426. Token = ".sample",
  427. MediaType = MediaType.Video
  428. },
  429. new ExtraRule
  430. {
  431. ExtraType = "sample",
  432. RuleType = ExtraRuleType.Suffix,
  433. Token = "_sample",
  434. MediaType = MediaType.Video
  435. },
  436. new ExtraRule
  437. {
  438. ExtraType = "sample",
  439. RuleType = ExtraRuleType.Suffix,
  440. Token = " sample",
  441. MediaType = MediaType.Video
  442. },
  443. new ExtraRule
  444. {
  445. ExtraType = "themesong",
  446. RuleType = ExtraRuleType.Filename,
  447. Token = "theme",
  448. MediaType = MediaType.Audio
  449. },
  450. new ExtraRule
  451. {
  452. ExtraType = "scene",
  453. RuleType = ExtraRuleType.Suffix,
  454. Token = "-scene",
  455. MediaType = MediaType.Video
  456. },
  457. new ExtraRule
  458. {
  459. ExtraType = "clip",
  460. RuleType = ExtraRuleType.Suffix,
  461. Token = "-clip",
  462. MediaType = MediaType.Video
  463. },
  464. new ExtraRule
  465. {
  466. ExtraType = "interview",
  467. RuleType = ExtraRuleType.Suffix,
  468. Token = "-interview",
  469. MediaType = MediaType.Video
  470. },
  471. new ExtraRule
  472. {
  473. ExtraType = "behindthescenes",
  474. RuleType = ExtraRuleType.Suffix,
  475. Token = "-behindthescenes",
  476. MediaType = MediaType.Video
  477. },
  478. new ExtraRule
  479. {
  480. ExtraType = "deletedscene",
  481. RuleType = ExtraRuleType.Suffix,
  482. Token = "-deleted",
  483. MediaType = MediaType.Video
  484. },
  485. new ExtraRule
  486. {
  487. ExtraType = "featurette",
  488. RuleType = ExtraRuleType.Suffix,
  489. Token = "-featurette",
  490. MediaType = MediaType.Video
  491. },
  492. new ExtraRule
  493. {
  494. ExtraType = "short",
  495. RuleType = ExtraRuleType.Suffix,
  496. Token = "-short",
  497. MediaType = MediaType.Video
  498. }
  499. };
  500. Format3DRules = new[]
  501. {
  502. // Kodi rules:
  503. new Format3DRule
  504. {
  505. PreceedingToken = "3d",
  506. Token = "hsbs"
  507. },
  508. new Format3DRule
  509. {
  510. PreceedingToken = "3d",
  511. Token = "sbs"
  512. },
  513. new Format3DRule
  514. {
  515. PreceedingToken = "3d",
  516. Token = "htab"
  517. },
  518. new Format3DRule
  519. {
  520. PreceedingToken = "3d",
  521. Token = "tab"
  522. },
  523. // Media Browser rules:
  524. new Format3DRule
  525. {
  526. Token = "fsbs"
  527. },
  528. new Format3DRule
  529. {
  530. Token = "hsbs"
  531. },
  532. new Format3DRule
  533. {
  534. Token = "sbs"
  535. },
  536. new Format3DRule
  537. {
  538. Token = "ftab"
  539. },
  540. new Format3DRule
  541. {
  542. Token = "htab"
  543. },
  544. new Format3DRule
  545. {
  546. Token = "tab"
  547. },
  548. new Format3DRule
  549. {
  550. Token = "sbs3d"
  551. },
  552. new Format3DRule
  553. {
  554. Token = "mvc"
  555. }
  556. };
  557. AudioBookPartsExpressions = new[]
  558. {
  559. // Detect specified chapters, like CH 01
  560. @"ch(?:apter)?[\s_-]?(?<chapter>\d+)",
  561. // Detect specified parts, like Part 02
  562. @"p(?:ar)?t[\s_-]?(?<part>\d+)",
  563. // Chapter is often beginning of filename
  564. @"^(?<chapter>\d+)",
  565. // Part if often ending of filename
  566. @"(?<part>\d+)$",
  567. // Sometimes named as 0001_005 (chapter_part)
  568. @"(?<chapter>\d+)_(?<part>\d+)",
  569. // Some audiobooks are ripped from cd's, and will be named by disk number.
  570. @"dis(?:c|k)[\s_-]?(?<chapter>\d+)"
  571. };
  572. var extensions = VideoFileExtensions.ToList();
  573. extensions.AddRange(new[]
  574. {
  575. ".mkv",
  576. ".m2t",
  577. ".m2ts",
  578. ".img",
  579. ".iso",
  580. ".mk3d",
  581. ".ts",
  582. ".rmvb",
  583. ".mov",
  584. ".avi",
  585. ".mpg",
  586. ".mpeg",
  587. ".wmv",
  588. ".mp4",
  589. ".divx",
  590. ".dvr-ms",
  591. ".wtv",
  592. ".ogm",
  593. ".ogv",
  594. ".asf",
  595. ".m4v",
  596. ".flv",
  597. ".f4v",
  598. ".3gp",
  599. ".webm",
  600. ".mts",
  601. ".m2v",
  602. ".rec",
  603. ".mxf"
  604. });
  605. MultipleEpisodeExpressions = new string[]
  606. {
  607. @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  608. @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  609. @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  610. @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  611. @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  612. @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  613. @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  614. @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  615. @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
  616. @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$"
  617. }.Select(i => new EpisodeExpression(i)
  618. {
  619. IsNamed = true
  620. }).ToArray();
  621. VideoFileExtensions = extensions
  622. .Distinct(StringComparer.OrdinalIgnoreCase)
  623. .ToArray();
  624. Compile();
  625. }
  626. public Regex[] VideoFileStackingRegexes { get; private set; }
  627. public Regex[] CleanDateTimeRegexes { get; private set; }
  628. public Regex[] CleanStringRegexes { get; private set; }
  629. public Regex[] EpisodeWithoutSeasonRegexes { get; private set; }
  630. public Regex[] EpisodeMultiPartRegexes { get; private set; }
  631. public void Compile()
  632. {
  633. VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray();
  634. CleanDateTimeRegexes = CleanDateTimes.Select(Compile).ToArray();
  635. CleanStringRegexes = CleanStrings.Select(Compile).ToArray();
  636. EpisodeWithoutSeasonRegexes = EpisodeWithoutSeasonExpressions.Select(Compile).ToArray();
  637. EpisodeMultiPartRegexes = EpisodeMultiPartExpressions.Select(Compile).ToArray();
  638. }
  639. private Regex Compile(string exp)
  640. {
  641. return new Regex(exp, RegexOptions.IgnoreCase | RegexOptions.Compiled);
  642. }
  643. }
  644. }