mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 15:44:26 -04:00
better Link string and is_archived methods
This commit is contained in:
parent
11fd436305
commit
8f63f24002
1 changed files with 16 additions and 6 deletions
|
@ -92,6 +92,9 @@ class Link:
|
||||||
updated: Optional[datetime] = None
|
updated: Optional[datetime] = None
|
||||||
schema: str = 'Link'
|
schema: str = 'Link'
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f'[{self.timestamp}] {self.base_url} "{self.title}"'
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.typecheck()
|
self.typecheck()
|
||||||
|
|
||||||
|
@ -215,8 +218,8 @@ class Link:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link_dir(self) -> str:
|
def link_dir(self) -> str:
|
||||||
from .config import ARCHIVE_DIR
|
from .config import CONFIG
|
||||||
return os.path.join(ARCHIVE_DIR, self.timestamp)
|
return os.path.join(CONFIG['ARCHIVE_DIR'], self.timestamp)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def archive_path(self) -> str:
|
def archive_path(self) -> str:
|
||||||
|
@ -309,11 +312,18 @@ class Link:
|
||||||
from .config import ARCHIVE_DIR
|
from .config import ARCHIVE_DIR
|
||||||
from .util import domain
|
from .util import domain
|
||||||
|
|
||||||
return os.path.exists(os.path.join(
|
output_paths = (
|
||||||
ARCHIVE_DIR,
|
|
||||||
self.timestamp,
|
|
||||||
domain(self.url),
|
domain(self.url),
|
||||||
))
|
'output.pdf',
|
||||||
|
'screenshot.png',
|
||||||
|
'output.html',
|
||||||
|
'media',
|
||||||
|
)
|
||||||
|
|
||||||
|
return any(
|
||||||
|
os.path.exists(os.path.join(ARCHIVE_DIR, self.timestamp, path))
|
||||||
|
for path in output_paths
|
||||||
|
)
|
||||||
|
|
||||||
def latest_outputs(self, status: str=None) -> Dict[str, ArchiveOutput]:
|
def latest_outputs(self, status: str=None) -> Dict[str, ArchiveOutput]:
|
||||||
"""get the latest output that each archive method produced for link"""
|
"""get the latest output that each archive method produced for link"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue