NamingOptions.cs 23 KB

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