smfontes / xbmc-mylibrary

Automatically exported from code.google.com/p/xbmc-mylibrary
0 stars 0 forks source link

Patch: Added logical OR operator to contains filter #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
New feature added. Patch attached here includes all changes in issue #4 as well 
is this issue #5.

Read more about it at: 
http://forum.xbmc.org/showthread.php?tid=98210&pid=1171855#pid1171855

Another Feature
I got a little carried away tonight and knocked out another feature that I felt 
was missing from the tool, support for an OR logical operator in the filters 
section. This feature allows for a much cleaner configuration when filtering 
the content that you want included. Simply put, you can put a list of matches 
and it if matches any of them, then that contains filter will be considered 
successful. Between multiple contains elements it is still an AND operation, 
but within it can now be a list of items.

Quote:
Only videos that match ALL filters will be included (unless it matched an 
exclude)
That is what the documentation stated for the contains element of a filter. 
Unfortunately, that does not provide any way of specifying a logical operator 
OR to the filter. Because it must match ALL, it is always performing an AND 
comparison for each "contains" item listed. This features keeps that AND 
behavior between each contains element but allows the text of the contains 
element body to be delimited by an OR operator "||". This double pipe OR 
operator will be used as a delimiter to split the contains criteria and if any 
of them match, then the filter will pass.

It's easier to see it...
Code:
<!-- All full episodes over 20 minutes long for a subset of the History network 
shows -->
<subfolder name="History Channel" type="episodes" >
    <filter>
        <contains>Full Episodes</contains>
        <runtime>GT|1200</runtime>
        <contains>Modern Marvels || Top Gear || The Universe || Ice Road Truckers || Ax Men</contains>
    </filter>
</subfolder>

Here it is with some context... (scoombe, the last filter in this example may 
help you on your way learning Java)
Code:
<!--
<SearchFilters>                
    This is where you define what sources in XBMC should be added to the library.
    <source> - The source to search. The element name can be whatever you want. If the name matches a source in XBMC, you do no need to specify the path attribute.
        path - This is the actual path that XBMC uses for this source. If you are unsure what the path is, check your sources.xml is your userdata folder. Not needed if source name matches the XBMC source name.            
        <subfolder> - Each source can have multiple subfolder elements. These are directories that should be scanned and added to the library. 
            *Note: all of the attributes below can be used at the subfolder level or the source level. If specified at both levels, the subfolder takes precedence.
                    If specified at the source level, the attribute will be inherited by all subfolders.
                    Also, subfolders can be nested inside of other subfolders, and all attributes will be inherited. The name attribute will be appended as you would expect.
            name - required attribute; The name of the subfolder. (do not include the source name, just the subfolder). Use '/' to seperate folders in the name.
            type - optional attribute; default=auto determine; This is the type of content in the directory. Only set this if all content in the directory is the same type.
                    If the content type is all known to be TV Shows, use 'episodes';
                    If the content type is all known to be movies Movies/Films, use 'movies' 
                    If the content type is all known to be movies Music Videos, use 'music_videos'
                    If the content type is all known to be none of the above, use 'generic' - This will simply write a directory full of the strm files
                    NOTE: this does not filter the content in the directory; it tells this program what kind of content to expect!
            recursive - optional attribute; default=false; If true, the directory and all subfolders will be scanned for content. Otherwise only the top directory will be scanned.
            regex_name - optional, If true, the name attribute wil be evaluated as a regular expression. The regex must match the full actual name of the subfolder. Partial regex matches will be discarded!                                
            force_tvdb - optional, default=false; For episodes only. If true, the season/episode numbers retrieved from the source will be ignored and the show will be looked up on TheTVDB.com. (useful if the source incorrectly/absolutely numbers episodes for some series)
            max_series - optional attribute; default=unlimited; If TV Shows are in this subfolder, this is the maxinum number of TV series to archive. Useful for Hulu/Popular Shows filtering the top X series you want in your library.
            max_videos - optional attribute; default=unlimited; This is the maxinum number of episodes/movies/music videos to retrieve from the subfolder.
            movie_set - optional attribute; default=none; Specifies the name of the movie set to add the movie to; (Ignored for TV Episodes/Music Videos). More info: http://wiki.xbmc.org/index.php?title=Movie_Sets
            prefix - optional attribute; default=none; This will be prepended to the title of TV Episodes/Music Vidoes (Ignored for movies) in the directory. Can be useful if you want to identify which episodes are from which source.
            suffix - optional attribute; default=none; This will be appended  to the title of TV Episodes/Music Vidoes (Ignored for movies) in the directory. Can be useful if you want to identify which episodes are from which source.
            multi_part - optional arrtibute; default=false; Set this to true if the subfolder might contain any multi-part vidoes                
            force_series - optional attribute; default=none; This will override any series name that gets parsed.
            <exclude> - optional; If a video's path matches ANY of these, it will be skipped.
            <filter>  - optional; Only videos that match ALL filters will be included (unless it matched an exclude)
                <contains> - Matches if the video path contains at least one of the literal texts delimited by double pipes "||" (case-insensitive)
                <regexp> - Matches if any part of the video path matches this Regular Expression (case-insensitive) - see here for info on regex: http://java.sun.com/developer/technicalArticles/releases/1.4regex/
                <runtime> - Matches if the runtime of the file fits the criteria specified in seconds along with the relational operator value. The format is "<relational_operator>|<runtime_seconds>". Posible relational operators are: EQ:Equal to, GT:Greater than, LT:Less than, NE:Not equal to, GE:Greater than or equal to, LE:Less than or equal to. Matches only on files and not directories.
            <parser>  - optional; Overrides the default series and title parser with a regular expression that must contain two defined groups.
                <regexp> - Pattern must contain two groups like in the following: ([\w\s*'-]*):([\w\s*'-]*) pattern. The first will be the series, and the second the title. - see here for info on regex: http://java.sun.com/developer/technicalArticles/releases/1.4regex/

        Note: The exclude/filters filter on the video path. A typical video path looks something like "Hulu/Popular/Popular Episodes/s01e01 - MyTVShow - Pilot"
        Note: Be careful what you recursively search for. For example, a recursive search of PlayOn's Netflix/Browse Genres returns about 75,000 videos!
        Note: The '/' character is used exclusively to seperate folders. It cannot otherwise be used in the name attribute (there is currently no way to escape it)            

-->

<SearchFilters>
    <!--
    See here for sample search filter configurations: https://docs.google.com/document/d/1CDbdU1GOJlIblwGH8vaJT5c_99lK5H-gRMe3CFpZpUs/edit?hl=en#bookmark=id.g4i0iqa50b0b
    -->

    <!-- FreeCable Streaming TV Network Content -->
    <FreeCable path="plugin://plugin.video.free.cable" recursive="true" prefix="(F) " >
        <!-- All full episodes over 20 minutes long for a subset of the USA network shows -->
        <subfolder name="USA" type="episodes" >
            <filter>
                <contains>Full Episodes</contains>
                <runtime>GT|1200</runtime>
                <contains>Fairly Legal || In Plain Sight || Burn Notice</contains>
            </filter>
        </subfolder>
        <!-- All full episodes over 20 minutes long for a subset of the History network shows -->
        <subfolder name="History Channel" type="episodes" >
            <filter>
                <contains>Full Episodes</contains>
                <runtime>GT|1200</runtime>
                <contains>Modern Marvels || Top Gear || The Universe || Ice Road Truckers || Ax Men</contains>
            </filter>
        </subfolder>
    </FreeCable>

    <!-- TED Videos -->
    <TED path="plugin://plugin.video.ted.talks" recursive="true" >
        <!-- Newest TED Talks -->
        <subfolder name="Newest Talks" type="generic" suffix=" (TED)" force_series="TED Talks" >
            <!--Parse the series name then the title of the episode -->
            <parser>
                <regexp>()([\w\s*'-:]*)</regexp> <!-- ex: Include the entire name "Show Name: Title of the Episode" -->
            </parser>
        </subfolder>        
    </TED>

    <!-- Lectures -->
    <VideoLectures path="plugin.video.videolectures.net" recursive="true" regex_name="true" >
        <!--Java training courses -->
        <subfolder name="Categories/Computers \([0-9]+\)/Programming \([0-9]+\)/Java \([0-9]+\)" type="generic" force_series="Java Training" >  <!-- matches on directories like: /Categories/Computers (369)/Programming (138)/Java (4)/ -->
            <parser>
                <regexp>()([\w\s*'-:]*)</regexp>
            </parser>

            <filter>
                <runtime>GE|900</runtime>
                <regexp>Lecture [0-9]+</regexp>                
            </filter>
        </subfolder>
    </VideoLectures>

</SearchFilters>

Original issue reported on code.google.com by robbiene...@gmail.com on 18 Aug 2012 at 7:58

Attachments:

GoogleCodeExporter commented 9 years ago
I meant to say "as well as issue #6". Issue #5 is about non-english character 
support and is not addressed within this patch.

Original comment by robbiene...@gmail.com on 18 Aug 2012 at 7:59

GoogleCodeExporter commented 9 years ago
Should be resolved at Rev 13.  I believe I got all your patches Rob, but let me 
know if something looks wrong. Or just commit a fix as you see fit.  Lets get a 
stable version and make a dot release.

Original comment by bradyvid...@gmail.com on 22 Aug 2012 at 12:59