'Populate self.books_to_catalog from database
Create self.books_to_catalog from filtered database.
Keys:
authors            massaged
author_sort        record[\'author_sort\'] or computed
cover              massaged record[\'cover\']
date               massaged record[\'pubdate\']
description        massaged record[\'comments\'] + merge_comments
id                 record[\'id\']
formats            massaged record[\'formats\']
notes              from opts.header_note_source_field
prefix             from self.discover_prefix()
publisher          massaged record[\'publisher\']
rating             record[\'rating\'] (0 if None)
series             record[\'series\'] or None
series_index       record[\'series_index\'] or 0.0
short_description  truncated description
tags               filtered record[\'tags\']
timestamp          record[\'timestamp\']
title              massaged record[\'title\']
title_sort         computed from record[\'title\']
uuid               record[\'uuid\']
Inputs:
data (list): filtered list of book metadata dicts
Outputs:
(list) books_to_catalog
Returns:
True: Successful
False: Empty data, (check filter restrictions)'

def fetch_books_to_catalog(self):

    def _populate_title(record):
        '    populate    this_title    with    massaged    metadata    '
        this_title = {}
        this_title['id'] = record['id']
        this_title['uuid'] = record['uuid']
        this_title['title'] = self.convert_html_entities(record['title'])
        if record['series']:
            this_title['series'] = record['series']
            self.all_series.add(this_title['series'])
            this_title['series_index'] = record['series_index']
        else:
            this_title['series'] = None
            this_title['series_index'] = 0.0
        this_title['title_sort'] = self.generate_sort_title(this_title['title'])
        if ('authors' in record):
            this_title['authors'] = record['authors']
            if record['authors']:
                this_title['author'] = '    &amp;    '.join(record['authors'])
            else:
                this_title['author'] = _('Unknown')
                this_title['authors'] = [this_title['author']]
        if (('author_sort' in record) and record['author_sort'].strip()):
            this_title['author_sort'] = record['author_sort']
        else:
            this_title['author_sort'] = self._kf_author_to_author_sort(this_title['author'])
        if record['publisher']:
            this_title['publisher'] = re.sub('&', '&amp;', record['publisher'])
        this_title['rating'] = (record['rating'] if record['rating'] else 0)
        if is_date_undefined(record['pubdate']):
            this_title['date'] = None
        else:
            this_title['date'] = strftime(u'%B    %Y', as_local_time(record['pubdate']).timetuple())
        this_title['timestamp'] = record['timestamp']
        if record['comments']:
            a_offset = record['comments'].find('<div    class="user_annotations">')
            ad_offset = record['comments'].find('<hr    class="annotations_divider"    />')
            if (a_offset >= 0):
                record['comments'] = record['comments'][:a_offset]
            if (ad_offset >= 0):
                record['comments'] = record['comments'][:ad_offset]
            this_title['description'] = self.massage_comments(record['comments'])
            paras = BeautifulSoup(this_title['description']).findAll('p')
            tokens = []
            for p in paras:
                for token in p.contents:
                    if (token.string is not None):
                        tokens.append(token.string)
            this_title['short_description'] = self.generate_short_description('    '.join(tokens), dest='description')
        else:
            this_title['description'] = None
            this_title['short_description'] = None
        if self.merge_comments_rule['field']:
            this_title['description'] = self.merge_comments(this_title)
        if record['cover']:
            this_title['cover'] = re.sub('&amp;', '&', record['cover'])
        this_title['prefix'] = self.discover_prefix(record)
        this_title['tags'] = []
        if record['tags']:
            this_title['tags'] = self.filter_excluded_genres(record['tags'], self.opts.exclude_genre)
        this_title['genres'] = []
        if (self.opts.genre_source_field == _('Tags')):
            this_title['genres'] = this_title['tags']
        else:
            record_genres = self.db.get_field(record['id'], self.opts.genre_source_field, index_is_id=True)
            if record_genres:
                if (type(record_genres) is not list):
                    record_genres = [record_genres]
                this_title['genres'] = self.filter_excluded_genres(record_genres, self.opts.exclude_genre)
        if record['formats']:
            formats = []
            for format in record['formats']:
                formats.append(self.convert_html_entities(format))
            this_title['formats'] = formats
        if self.opts.header_note_source_field:
            field_md = self.db.metadata_for_field(self.opts.header_note_source_field)
            notes = self.db.get_field(record['id'], self.opts.header_note_source_field, index_is_id=True)
            if notes:
                if (field_md['datatype'] == 'text'):
                    if isinstance(notes, list):
                        notes = '    &middot;    '.join(notes)
                elif (field_md['datatype'] == 'datetime'):
                    notes = format_date(notes, 'dd    MMM    yyyy')
                this_title['notes'] = {'source': field_md['name'], 'content': notes}
        return this_title
    self.opts.sort_by = 'title'
    search_phrase = ''
    if self.excluded_tags:
        search_terms = []
        for tag in self.excluded_tags:
            search_terms.append(('tag:=%s' % tag))
        search_phrase = ('not    (%s)' % '    or    '.join(search_terms))
    if self.opts.ids:
        self.opts.search_text = search_phrase
    elif self.opts.search_text:
        self.opts.search_text += ('    ' + search_phrase)
    else:
        self.opts.search_text = search_phrase
    data = self.plugin.search_sort_db(self.db, self.opts)
    data = self.process_exclusions(data)
    if self.DEBUG:
        if self.prefix_rules:
            self.opts.log.info('    Added    prefixes    (bools_are_tristate:    {0}):'.format(self.db.prefs.get('bools_are_tristate')))
        else:
            self.opts.log.info('    No    added    prefixes')
    titles = []
    for record in data:
        this_title = _populate_title(record)
        titles.append(this_title)
    return titles
