home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Moving Pictures
Help with samples filter RegEx
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ajs" data-source="post: 1164937" data-attributes="member: 68833"><p>[CODE=C#] [CornerstoneSetting(</p><p> Name = "Regular Expression Filter",</p><p> Description = "a regular expression that matches keywords in the filename or it's parent folder indicating that the file is possible sample.",</p><p> Groups = "|Movie Importer|Sample Filter|",</p><p> Identifier = "importer_sample_keyword",</p><p> Default = "sample")]</p><p> public string SampleRegExFilter {</p><p> get { return _sampleRegExFilter; }</p><p> set {</p><p> _sampleRegExFilter = value;</p><p> OnSettingChanged("importer_sample_keyword");</p><p> }</p><p> }</p><p> private string _sampleRegExFilter;[/CODE]</p><p>[CODE=C#] public static bool isSampleFile(FileInfo file) {</p><p> try {</p><p> // Create the sample filter regular expression</p><p> Regex expr = new Regex(MovingPicturesCore.Settings.SampleRegExFilter, RegexOptions.IgnoreCase);</p><p> // Set sample max size in bytes and check the file size</p><p> long sampleMaxSize = MovingPicturesCore.Settings.MaxSampleFilesize * 1024 * 1024;</p><p> bool match = (file.Length < sampleMaxSize);</p><p> if (match) {</p><p> // check the filename</p><p> match = expr.Match(file.Name).Success;</p><p> if (!match && MovingPicturesCore.Settings.SampleIncludeFolderName) {</p><p> // check the folder name if specified</p><p> match = expr.Match(file.DirectoryName).Success;</p><p> }</p><p> }</p><p> // Return result of given conditions </p><p> return match;</p><p> }</p><p> catch (Exception e) {</p><p> if (e is ThreadAbortException)</p><p> throw e;</p><p></p><p> logger.Warn("Sample file check failed: {0}", e.Message);</p><p> return false;</p><p> }</p><p> }[/CODE]</p></blockquote><p></p>
[QUOTE="ajs, post: 1164937, member: 68833"] [CODE=C#] [CornerstoneSetting( Name = "Regular Expression Filter", Description = "a regular expression that matches keywords in the filename or it's parent folder indicating that the file is possible sample.", Groups = "|Movie Importer|Sample Filter|", Identifier = "importer_sample_keyword", Default = "sample")] public string SampleRegExFilter { get { return _sampleRegExFilter; } set { _sampleRegExFilter = value; OnSettingChanged("importer_sample_keyword"); } } private string _sampleRegExFilter;[/CODE] [CODE=C#] public static bool isSampleFile(FileInfo file) { try { // Create the sample filter regular expression Regex expr = new Regex(MovingPicturesCore.Settings.SampleRegExFilter, RegexOptions.IgnoreCase); // Set sample max size in bytes and check the file size long sampleMaxSize = MovingPicturesCore.Settings.MaxSampleFilesize * 1024 * 1024; bool match = (file.Length < sampleMaxSize); if (match) { // check the filename match = expr.Match(file.Name).Success; if (!match && MovingPicturesCore.Settings.SampleIncludeFolderName) { // check the folder name if specified match = expr.Match(file.DirectoryName).Success; } } // Return result of given conditions return match; } catch (Exception e) { if (e is ThreadAbortException) throw e; logger.Warn("Sample file check failed: {0}", e.Message); return false; } }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Moving Pictures
Help with samples filter RegEx
Contact us
RSS
Top
Bottom