Browse Source

Nested media index

pull/3111/head
Ruud 11 years ago
parent
commit
8ce30f0aad
  1. 17
      couchpotato/core/media/_base/media/index.py
  2. 3
      couchpotato/core/media/_base/media/main.py

17
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

3
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):

Loading…
Cancel
Save