def cli_search(options): search_term = ' '.join(options.keywords) tags = options.tags sources = options.sources query = re.sub(r'[ \(\)\:]+', ' ', search_term).strip() table_data = [] with Session() as session: for archived_entry in flexget.components.archive.db.search( session, query, tags=tags, sources=sources ): days_ago = (datetime.now() - archived_entry.added).days source_names = ', '.join([s.name for s in archived_entry.sources]) tag_names = ', '.join([t.name for t in archived_entry.tags]) table_data.append(['ID', str(archived_entry.id)]) table_data.append(['Title', archived_entry.title]) table_data.append(['Added', str(days_ago) + ' days ago']) table_data.append(['URL', archived_entry.url]) table_data.append(['Source(s)', source_names or 'N/A']) table_data.append(['Tag(s)', tag_names or 'N/A']) if archived_entry.description: table_data.append(['Description', strip_html(archived_entry.description)]) table_data.append([]) if not table_data: console('No results found for search') return try: table = TerminalTable(options.table_type, table_data, wrap_columns=[1]) table.table.inner_heading_row_border = False console(table.output) except TerminalTableError as e: console('ERROR: %s' % str(e))
def cli_search(options): search_term = ' '.join(options.keywords) tags = options.tags sources = options.sources query = re.sub(r'[ \(\)]+', ' ', search_term).strip() table_data = [] with Session() as session: for archived_entry in search(session, query, tags=tags, sources=sources): days_ago = (datetime.now() - archived_entry.added).days source_names = ', '.join([s.name for s in archived_entry.sources]) tag_names = ', '.join([t.name for t in archived_entry.tags]) table_data.append(['ID', str(archived_entry.id)]) table_data.append(['Title', archived_entry.title]) table_data.append(['Added', str(days_ago) + ' days ago']) table_data.append(['URL', archived_entry.url]) table_data.append(['Source(s)', source_names or 'N/A']) table_data.append(['Tag(s)', tag_names or 'N/A']) if archived_entry.description: table_data.append(['Description', strip_html(archived_entry.description)]) table_data.append([]) if not table_data: console('No results found for search') return table = TerminalTable(options.table_type, table_data, wrap_columns=[1]) table.table.inner_heading_row_border = False try: console(table.output) except TerminalTableError as e: console('ERROR: %s' % str(e))
def cli_search(options): search_term = ' '.join(options.keywords) tags = options.tags sources = options.sources query = re.sub(r'[ \(\)\:]+', ' ', search_term).strip() table_data = [] with Session() as session: for archived_entry in flexget.components.archive.db.search( session, query, tags=tags, sources=sources): days_ago = (datetime.now() - archived_entry.added).days source_names = ', '.join([s.name for s in archived_entry.sources]) tag_names = ', '.join([t.name for t in archived_entry.tags]) table_data.append(['ID', str(archived_entry.id)]) table_data.append(['Title', archived_entry.title]) table_data.append(['Added', str(days_ago) + ' days ago']) table_data.append(['URL', archived_entry.url]) table_data.append(['Source(s)', source_names or 'N/A']) table_data.append(['Tag(s)', tag_names or 'N/A']) if archived_entry.description: table_data.append( ['Description', strip_html(archived_entry.description)]) table_data.append([]) if not table_data: console('No results found for search') return table = TerminalTable('Field', 'Value', table_type=options.table_type) for row in table_data: table.add_row(*row) console(table)
def print_ae(ae): diff = datetime.now() - ae.added console('ID: %-6s | Feed: %-10s | Title: %s\nAdded: %s (%d days ago)\nURL: %s' % \ (ae.id, ae.feed, ae.title, ae.added, diff.days, ae.url)) if ae.description: console('Description: %s' % strip_html(ae.description)) console('---')
def print_ae(ae): diff = datetime.now() - ae.added console('ID: %-6s | Title: %s\nAdded: %s (%d days ago)\nURL: %s' % (ae.id, ae.title, ae.added, diff.days, ae.url)) source_names = ', '.join([s.name for s in ae.sources]) tag_names = ', '.join([t.name for t in ae.tags]) console('Source(s): %s | Tag(s): %s' % (source_names or 'N/A', tag_names or 'N/A')) if ae.description: console('Description: %s' % strip_html(ae.description)) console('---')
def print_ae(ae): diff = datetime.now() - ae.added console( "ID: %-6s | Title: %s\nAdded: %s (%d days ago)\nURL: %s" % (ae.id, ae.title, ae.added, diff.days, ae.url) ) source_names = ", ".join([s.name for s in ae.sources]) tag_names = ", ".join([t.name for t in ae.tags]) console("Source(s): %s | Tag(s): %s" % (source_names or "N/A", tag_names or "N/A")) if ae.description: console("Description: %s" % strip_html(ae.description)) console("---")