platypush/plugins/media/search/local.py
def search(self, query, **kwargs):
        """
        Searches in the configured media directories given a query. It uses the
        built-in SQLite index if available. If any directory has changed since
        the last scan then it will be indexed again and the up-to-date results
        will be returned.
        """

        session = self._get_db_session()
        results = {}

        for media_dir in self.dirs:
            self.logger.info('Searching {} for "{}"'.format(media_dir, query))
            dir_record = self._get_or_create_dir_entry(session, media_dir)

            if self._has_directory_changed_since_last_indexing(dir_record):
                self.logger.info('{} has changed since last indexing, '.format(
                    media_dir) + 're-indexing')

                self.scan(media_dir, session=session, dir_record=dir_record)

            query_tokens = [_.lower() for _ in re.split(
                self._filename_separators, query.strip())]

            for file_record in session.query(MediaFile.path). \
                    join(MediaFileToken). \
                    join(MediaToken). \
                    filter(MediaToken.token.in_(query_tokens)). \
                    group_by(MediaFile.path). \
                    having(func.count(MediaFileToken.token_id) >= len(query_tokens)):
                if os.path.isfile(file_record.path):
                    results[file_record.path] = {
                        'url': 'file://' + file_record.path,
                        'title': os.path.basename(file_record.path),
                        'size': os.path.getsize(file_record.path)
                    }

        return results.values()

        Searches in the configured media directories given a query. It uses the
        built-in SQLite index if available. If any directory has changed since
        the last scan then it will be indexed again and the up-to-date results
        will be returned.
        
Searches in the configured media directories given a query. It uses the
built-in SQLite index if available. If any directory has changed since
the last scan then it will be indexed again and the up-to-date results
will be returned.
Searches in the configured media directories given a query . It uses the built - in SQLite index if available . If any directory has changed since the last scan then it will be indexed again and the up - to - date results will be returned .
def search(self, query, **kwargs):
        session = self._get_db_session()
        results = {}
        for media_dir in self.dirs:
            self.logger.info('Searching {} for "{}"'.format(media_dir, query))
            dir_record = self._get_or_create_dir_entry(session, media_dir)
            if self._has_directory_changed_since_last_indexing(dir_record):
                self.logger.info('{} has changed since last indexing, '.format(
                    media_dir) + 're-indexing')
                self.scan(media_dir, session=session, dir_record=dir_record)
            query_tokens = [_.lower() for _ in re.split(
                self._filename_separators, query.strip())]
            for file_record in session.query(MediaFile.path). \
                    join(MediaFileToken). \
                    join(MediaToken). \
                    filter(MediaToken.token.in_(query_tokens)). \
                    group_by(MediaFile.path). \
                    having(func.count(MediaFileToken.token_id) >= len(query_tokens)):
                if os.path.isfile(file_record.path):
                    results[file_record.path] = {
                        'url': 'file://' + file_record.path,
                        'title': os.path.basename(file_record.path),
                        'size': os.path.getsize(file_record.path)
                    }
        return results.values()
def search ( self , query , ** kwargs ) : session = self . _get_db_session ( ) results = { } for media_dir in self . dirs : self . logger . info ( 'Searching {} for "{}"' . format ( media_dir , query ) ) dir_record = self . _get_or_create_dir_entry ( session , media_dir ) if self . _has_directory_changed_since_last_indexing ( dir_record ) : self . logger . info ( '{} has changed since last indexing, ' . format ( media_dir ) + 're-indexing' ) self . scan ( media_dir , session = session , dir_record = dir_record ) query_tokens = [ _ . lower ( ) for _ in re . split ( self . _filename_separators , query . strip ( ) ) ] for file_record in session . query ( MediaFile . path ) . join ( MediaFileToken ) . join ( MediaToken ) . filter ( MediaToken . token . in_ ( query_tokens ) ) . group_by ( MediaFile . path ) . having ( func . count ( MediaFileToken . token_id ) >= len ( query_tokens ) ) : if os . path . isfile ( file_record . path ) : results [ file_record . path ] = { 'url' : 'file://' + file_record . path , 'title' : os . path . basename ( file_record . path ) , 'size' : os . path . getsize ( file_record . path ) } return results . values ( )
Searches in the configured media directories given a query.
Searches in the configured media directories given a query .
"""
        Searches in the configured media directories given a query. It uses the
        built-in SQLite index if available. If any directory has changed since
        the last scan then it will be indexed again and the up-to-date results
        will be returned.
        """
self
query