Help with samples filter RegEx (1 Viewer)

kiwijunglist

Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    J:\MOVIES [HD]\Escobar Paradise Lost (2014) - tt2515030\Extras\Test File.mkv

    if I create like above, then I restart importer it tries to match the test file.mkv to the movie "Extras (2005)"
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,616
    10,544
    Kyiv
    Home Country
    Ukraine Ukraine
    May be:
    ((sample)s?)|(\\((extra)|(trailer))s?\\)
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,616
    10,544
    Kyiv
    Home Country
    Ukraine Ukraine
    @kiwijunglist
    Hmmm ... try:
    Code:
    (\\?((sample)|(extra)|(trailer))s?\\?(.+?\.[a-z]{3,4}))
    upload_2015-12-8_10-52-38.png
     

    RoChess

    Extension Developer
  • Premium Supporter
  • March 10, 2006
    4,434
    1,897
    I would need to see movingpictures.log debug results on what MovPic is using to apply sample filter on.

    Presuming of course that the log file contains all the info needed.

    It could also be that the setting is not actually using regular expression, or that it demands a single entry output.

    To debug, does "sample|extras" work?

    I don't think the noise filter will do any good, because that only works for filenames if memory serves me.

    PS: Have you considered just adjusting the "Max Filesize (MB)" values to one that would still work for your smallest actual movie, but then exclude all the extras/bonus/samples automatic? Unless of course you have those monster behind-the-scene high definition documentaries. Another solution for those is to rely on the multi-part system, and call the movie itself CD1/Part1/etc, and then the bonus CD2/Part2/etc. That way the movie only gets a single entry in Moving-Pictures, and you still have the ability to play the bonus features at the end. The only downside is that runtime will be off, as it will be calculated on both. Another alternative would be to use IMDb+ and add something like "([Bonus])" to the filename, so that it will become a separate entry in your collection that is easy to identify.

    Using sample|extras should have worked though :(
     
    Last edited:

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,616
    10,544
    Kyiv
    Home Country
    Ukraine Ukraine
    It could also be that the setting is not actually using regular expression, or that it demands a single entry output.
    Code:
            [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:
              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;
                }
            }
     
    Last edited:

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,616
    10,544
    Kyiv
    Home Country
    Ukraine Ukraine
    @kiwijunglist
    Try set "Max Filesize (MB) - If the filesize of the potential sample file is below this value it will be skipped." to large value, like 500 or bigger ... but:
    Code:
    long sampleMaxSize = MovingPicturesCore.Settings.MaxSampleFilesize * 1024 * 1024;
    bool match = (file.Length < sampleMaxSize);
    if(match){...
    IMHO wrong logic :( I would have done so:
    Code:
    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;
                }
            }
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,616
    10,544
    Kyiv
    Home Country
    Ukraine Ukraine
    And regexp:
    Code:
    (samples?)|(\\((extra)|(trailer))s?\\)
    or
    Code:
    (\\((sample)|(extra)|(trailer))s?\\)
     

    RoChess

    Extension Developer
  • Premium Supporter
  • March 10, 2006
    4,434
    1,897
    @ajs, thanks for pulling the relevant code, because I did notice that file, and folder are scanned seperate.

    I was expecting a full path+file match, which might explain why searching for \Extras\ or /Extras/ can fail if the folder string does not contain the 'slash' at the end.

    Log file might have clarified that if it shows the true debug value on what is being used.

    Also I can't remember if .Success works on regular expression arrays, in which case you would have to simplify your expressions to ensure no array results are returned.
     

    Users who are viewing this thread

    Similar threads

    Hello all, Recently I have been having a few problems importing movies to Moving Pictures using the IMDB+ plugin (missing fields) so I have decided to have a go at creating an XML based on the XBMC Local xml. This has not been tested with multi languages and it has been configured for my personal collection. I'm hoping it will work...
    Hello all, Recently I have been having a few problems importing movies to Moving Pictures using the IMDB+ plugin (missing fields)...
    Hello all, Recently I have been having a few problems importing movies to Moving Pictures using the IMDB+ plugin (missing fields)...
    Replies
    0
    Views
    509
    • Sticky
    MP1 MP2 [News] MediaPortal 2 - 2.5 Release DE
    Will be version 2.5.1 ready quite soon? I read somewhere it will be a bugfix release, no new features are probably not in focus.
    Will be version 2.5.1 ready quite soon? I read somewhere it will be a bugfix release, no new features are probably not in focus.
    We are proud to present MediaPortal 2.5 MediaPortal 2.5 is a full-blown media center software that addresses most common user...
    Replies
    70
    Views
    5K
    I have installed Mediaportal x64 and TV server X64 on a freshly built Win 11 OS. I'm getting an error related to Gentle.config . "Unable to open Gentle.Config" and "Root element is missing". Any idea how to fix this on the x64 version? Thanks Fangio (Edit: Fixed by putting newest Gentle.config file into every possible directory...
    I have installed Mediaportal x64 and TV server X64 on a freshly built Win 11 OS. I'm getting an error related to Gentle.config ...
    I have decided to rework this post, becouse is no longer relevant. The SharpDX version is already included in MediaPortal since...
    Replies
    963
    Views
    79K
    This is not possible if it is a self made series, like personal travel videos etc.
    This is not possible if it is a self made series, like personal travel videos etc.
    Hi! I have videos that I want to show in TV-Series, such as personal TV series and educational series. As some examples I have...
    Replies
    8
    Views
    2K
    MP1 MP2 MP2 - V2.4 MediaPortal 2 - 2.4 Release DE
    Good job, nice release as usual (y)
    Good job, nice release as usual (y)
    We are proud to present MediaPortal 2.4 MediaPortal 2.4 is a full-blown media center software that addresses most common user...
    Replies
    5
    Views
    3K
    Top Bottom