archivebox.personas.importers

Shared persona browser discovery/import helpers.

These helpers are used by both the CLI and the Django admin so Persona import behavior stays consistent regardless of where it is triggered from.

Module Contents

Classes

PersonaImportSource

PersonaImportResult

Functions

_path_exists

_path_is_dir

_iter_children

_is_copyable_profile_entry

profile_copy_ignore

get_chrome_user_data_dir

Get the default Chrome user data directory for the current platform.

get_chromium_user_data_dir

Select Chromium’s own profile even when Google Chrome is installed.

get_brave_user_data_dir

Get the default Brave user data directory for the current platform.

get_edge_user_data_dir

Get the default Edge user data directory for the current platform.

validate_persona_name

Validate persona name to prevent path traversal.

discover_local_browser_profiles

discover_persona_template_profiles

resolve_browser_import_source

resolve_browser_profile_source

resolve_custom_import_source

pick_default_profile_dir

resolve_source_browser_binary

Use the originating browser so OS-protected cookies use the correct keychain.

import_persona_from_source

export_profile_cookies

Decode with the host keychain, never by starting the user’s browser.

copy_browser_user_data_dir

export_browser_state

_list_profile_names

_looks_like_profile_dir

_looks_like_cdp_url

_parse_netscape_cookies

_write_netscape_cookies

_merge_netscape_cookies

_merge_auth_storage

_load_auth_storage

_merge_cookie_dicts

_apply_imported_user_agent

Data

BROWSER_LABELS

BROWSER_PROFILE_DIR_NAMES

VOLATILE_PROFILE_COPY_PATTERNS

PERSONA_PROFILE_DIR_CANDIDATES

BROWSER_PROFILE_FINDERS

CHROMIUM_BROWSERS

NETSCAPE_COOKIE_HEADER

API

archivebox.personas.importers.BROWSER_LABELS[source]

None

archivebox.personas.importers.BROWSER_PROFILE_DIR_NAMES[source]

(‘Default’, ‘Profile ‘, ‘Guest Profile’)

archivebox.personas.importers.VOLATILE_PROFILE_COPY_PATTERNS[source]

(‘.*.??????’, ‘Cache’, ‘Code Cache’, ‘GPUCache’, ‘ShaderCache’, ‘Crashpad’, ‘BrowserMetrics’, ‘Brows…

archivebox.personas.importers.PERSONA_PROFILE_DIR_CANDIDATES[source]

(‘chrome_profile’, ‘chrome_user_data’)

archivebox.personas.importers._path_exists(path: pathlib.Path) → bool[source]
archivebox.personas.importers._path_is_dir(path: pathlib.Path) → bool[source]
archivebox.personas.importers._iter_children(path: pathlib.Path) → list[pathlib.Path][source]
archivebox.personas.importers._is_copyable_profile_entry(path: pathlib.Path) → bool[source]
archivebox.personas.importers.profile_copy_ignore(src: str, names: list[str]) → set[str][source]
class archivebox.personas.importers.PersonaImportSource[source]
kind: str[source]

None

browser: str[source]

‘custom’

source_name: str | None[source]

None

user_data_dir: pathlib.Path | None[source]

None

profile_dir: str | None[source]

None

browser_binary: str | None[source]

None

cdp_url: str | None[source]

None

property browser_label: str[source]
property profile_path: pathlib.Path | None[source]
property display_label: str[source]
property choice_value: str[source]
as_choice_label() → django.utils.safestring.SafeString[source]
classmethod from_choice_value(value: str) → archivebox.personas.importers.PersonaImportSource[source]
class archivebox.personas.importers.PersonaImportResult[source]
source: archivebox.personas.importers.PersonaImportSource[source]

None

profile_copied: bool[source]

False

cookies_imported: bool[source]

False

cookie_count: int[source]

0

storage_captured: bool[source]

False

user_agent_imported: bool[source]

False

warnings: list[str][source]

‘field(…)’

property did_work: bool[source]
archivebox.personas.importers.get_chrome_user_data_dir(*, beta: bool = False) → pathlib.Path | None[source]

Get the default Chrome user data directory for the current platform.

archivebox.personas.importers.get_chromium_user_data_dir() → pathlib.Path | None[source]

Select Chromium’s own profile even when Google Chrome is installed.

archivebox.personas.importers.get_brave_user_data_dir() → pathlib.Path | None[source]

Get the default Brave user data directory for the current platform.

archivebox.personas.importers.get_edge_user_data_dir() → pathlib.Path | None[source]

Get the default Edge user data directory for the current platform.

archivebox.personas.importers.BROWSER_PROFILE_FINDERS[source]

None

archivebox.personas.importers.CHROMIUM_BROWSERS[source]

‘tuple(…)’

[’# Netscape HTTP Cookie File’, ‘# https://curl.se/docs/http-cookies.html’, ‘# This file was generat…

archivebox.personas.importers.validate_persona_name(name: str) → tuple[bool, str][source]

Validate persona name to prevent path traversal.

archivebox.personas.importers.discover_local_browser_profiles() → list[archivebox.personas.importers.PersonaImportSource][source]
archivebox.personas.importers.discover_persona_template_profiles(personas_dir: pathlib.Path | None = None) → list[archivebox.personas.importers.PersonaImportSource][source]
archivebox.personas.importers.resolve_browser_import_source(browser: str, profile_dir: str | None = None) → archivebox.personas.importers.PersonaImportSource[source]
archivebox.personas.importers.resolve_browser_profile_source(browser: str, user_data_dir: pathlib.Path, profile_dir: str, source_name: str | None = None, browser_binary: str | None = None) → archivebox.personas.importers.PersonaImportSource[source]
archivebox.personas.importers.resolve_custom_import_source(raw_value: str, profile_dir: str | None = None) → archivebox.personas.importers.PersonaImportSource[source]
archivebox.personas.importers.pick_default_profile_dir(user_data_dir: pathlib.Path) → str | None[source]
archivebox.personas.importers.resolve_source_browser_binary(source: archivebox.personas.importers.PersonaImportSource) → str[source]

Use the originating browser so OS-protected cookies use the correct keychain.

archivebox.personas.importers.import_persona_from_source(persona: archivebox.personas.models.Persona, source: archivebox.personas.importers.PersonaImportSource, *, copy_profile: bool = True, import_cookies: bool = True, capture_storage: bool = False) → archivebox.personas.importers.PersonaImportResult[source]
archivebox.personas.importers.export_profile_cookies(source: archivebox.personas.importers.PersonaImportSource, staged_profile: pathlib.Path, output: pathlib.Path) → dict[source]

Decode with the host keychain, never by starting the user’s browser.

archivebox.personas.importers.copy_browser_user_data_dir(source_dir: pathlib.Path, destination_dir: pathlib.Path) → None[source]
archivebox.personas.importers.export_browser_state(*, user_data_dir: pathlib.Path | None = None, cdp_url: str | None = None, profile_dir: str | None = None, chrome_binary: str | None = None, cookies_output_file: pathlib.Path | None = None, auth_output_file: pathlib.Path | None = None) → tuple[bool, dict | None, str][source]
archivebox.personas.importers._list_profile_names(user_data_dir: pathlib.Path) → list[str][source]
archivebox.personas.importers._looks_like_profile_dir(path: pathlib.Path) → bool[source]
archivebox.personas.importers._looks_like_cdp_url(value: str) → bool[source]
archivebox.personas.importers._parse_netscape_cookies(path: pathlib.Path) → dict[tuple[str, str, str], tuple[str, str, str, str, str, str, str]][source]
archivebox.personas.importers._write_netscape_cookies(path: pathlib.Path, cookies: dict[tuple[str, str, str], tuple[str, str, str, str, str, str, str]]) → None[source]
archivebox.personas.importers._merge_netscape_cookies(existing_file: pathlib.Path, new_file: pathlib.Path) → None[source]
archivebox.personas.importers._merge_auth_storage(existing_file: pathlib.Path, new_file: pathlib.Path) → None[source]
archivebox.personas.importers._load_auth_storage(path: pathlib.Path) → dict[source]
archivebox.personas.importers._apply_imported_user_agent(persona: archivebox.personas.models.Persona, auth_payload: dict | None) → bool[source]