archiver/util.py
def derived_link_info(link):
    """extend link info with the archive urls and other derived data"""

    link_info = {
        **link,
        'date': datetime.fromtimestamp(float(link['timestamp'])).strftime('%Y-%m-%d %H:%M'),
        'google_favicon_url': 'https://www.google.com/s2/favicons?domain={domain}'.format(**link),
        'favicon_url': 'archive/{timestamp}/favicon.ico'.format(**link),
        'files_url': 'archive/{timestamp}/index.html'.format(**link),
        'archive_url': 'archive/{}/{}'.format(link['timestamp'], wget_output_path(link) or 'index.html'),
        'pdf_link': 'archive/{timestamp}/output.pdf'.format(**link),
        'screenshot_link': 'archive/{timestamp}/screenshot.png'.format(**link),
        'dom_link': 'archive/{timestamp}/output.html'.format(**link),
        'archive_org_url': 'https://web.archive.org/web/{base_url}'.format(**link),
    }

    # PDF and images are handled slightly differently
    # wget, screenshot, & pdf urls all point to the same file
    if link['type'] in ('PDF', 'image'):
        link_info.update({
            'archive_url': 'archive/{timestamp}/{base_url}'.format(**link),
            'pdf_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'screenshot_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'dom_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'title': '{title} ({type})'.format(**link),
        })
    return link_info
extend link info with the archive urls and other derived data
extend link info with the archive urls and other derived data
extend link info with the archive urls and other derived data
def derived_link_info(link):
    link_info = {
        **link,
        'date': datetime.fromtimestamp(float(link['timestamp'])).strftime('%Y-%m-%d %H:%M'),
        'google_favicon_url': 'https://www.google.com/s2/favicons?domain={domain}'.format(**link),
        'favicon_url': 'archive/{timestamp}/favicon.ico'.format(**link),
        'files_url': 'archive/{timestamp}/index.html'.format(**link),
        'archive_url': 'archive/{}/{}'.format(link['timestamp'], wget_output_path(link) or 'index.html'),
        'pdf_link': 'archive/{timestamp}/output.pdf'.format(**link),
        'screenshot_link': 'archive/{timestamp}/screenshot.png'.format(**link),
        'dom_link': 'archive/{timestamp}/output.html'.format(**link),
        'archive_org_url': 'https://web.archive.org/web/{base_url}'.format(**link),
    }
    if link['type'] in ('PDF', 'image'):
        link_info.update({
            'archive_url': 'archive/{timestamp}/{base_url}'.format(**link),
            'pdf_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'screenshot_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'dom_link': 'archive/{timestamp}/{base_url}'.format(**link),
            'title': '{title} ({type})'.format(**link),
        })
    return link_info
def derived_link_info ( link ) : link_info = { ** link , 'date' : datetime . fromtimestamp ( float ( link [ 'timestamp' ] ) ) . strftime ( '%Y-%m-%d %H:%M' ) , 'google_favicon_url' : 'https://www.google.com/s2/favicons?domain={domain}' . format ( ** link ) , 'favicon_url' : 'archive/{timestamp}/favicon.ico' . format ( ** link ) , 'files_url' : 'archive/{timestamp}/index.html' . format ( ** link ) , 'archive_url' : 'archive/{}/{}' . format ( link [ 'timestamp' ] , wget_output_path ( link ) or 'index.html' ) , 'pdf_link' : 'archive/{timestamp}/output.pdf' . format ( ** link ) , 'screenshot_link' : 'archive/{timestamp}/screenshot.png' . format ( ** link ) , 'dom_link' : 'archive/{timestamp}/output.html' . format ( ** link ) , 'archive_org_url' : 'https://web.archive.org/web/{base_url}' . format ( ** link ) , } if link [ 'type' ] in ( 'PDF' , 'image' ) : link_info . update ( { 'archive_url' : 'archive/{timestamp}/{base_url}' . format ( ** link ) , 'pdf_link' : 'archive/{timestamp}/{base_url}' . format ( ** link ) , 'screenshot_link' : 'archive/{timestamp}/{base_url}' . format ( ** link ) , 'dom_link' : 'archive/{timestamp}/{base_url}' . format ( ** link ) , 'title' : '{title} ({type})' . format ( ** link ) , } ) return link_info
extend link info with the archive urls and other derived data
extend link info with the archive urls and other derived data
"""extend link info with the archive urls and other derived data""" # PDF and images are handled slightly differently # wget, screenshot, & pdf urls all point to the same file
link