diff --git a/couchpotato/core/media/_base/media/index.py b/couchpotato/core/media/_base/media/index.py index b3cd82f..d0b52c3 100644 --- a/couchpotato/core/media/_base/media/index.py +++ b/couchpotato/core/media/_base/media/index.py @@ -159,3 +159,20 @@ from couchpotato.core.helpers.encoding import toUnicode, simplifyString""" break return str(title[0] if title and len(title) > 0 and title[0] in ascii_letters else '#').lower() + + + +class MediaChildrenIndex(TreeBasedIndex): + _version = 1 + + def __init__(self, *args, **kwargs): + kwargs['key_format'] = '32s' + super(MediaChildrenIndex, self).__init__(*args, **kwargs) + + def make_key(self, key): + return key + + def make_key_value(self, data): + if data.get('_t') == 'media' and data.get('parent_id'): + return data.get('parent_id'), None + diff --git a/couchpotato/core/media/_base/media/main.py b/couchpotato/core/media/_base/media/main.py index 62e8a16..29a98fd 100644 --- a/couchpotato/core/media/_base/media/main.py +++ b/couchpotato/core/media/_base/media/main.py @@ -8,7 +8,7 @@ from couchpotato.core.helpers.encoding import toUnicode from couchpotato.core.helpers.variable import splitString, getImdb, getTitle from couchpotato.core.logger import CPLog from couchpotato.core.media import MediaBase -from .index import MediaIndex, MediaStatusIndex, MediaTypeIndex, TitleSearchIndex, TitleIndex, StartsWithIndex +from .index import MediaIndex, MediaStatusIndex, MediaTypeIndex, TitleSearchIndex, TitleIndex, StartsWithIndex, MediaChildrenIndex log = CPLog(__name__) @@ -23,6 +23,7 @@ class MediaPlugin(MediaBase): 'media_by_type': MediaTypeIndex, 'media_title': TitleIndex, 'media_startswith': StartsWithIndex, + 'media_children': MediaChildrenIndex, } def __init__(self):