mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-29 05:55:28 -04:00
wip
This commit is contained in:
parent
4b6f08b0fe
commit
5d9a32c364
178 changed files with 2982 additions and 1322 deletions
0
packages/abx-plugin-readability-extractor/README.md
Normal file
0
packages/abx-plugin-readability-extractor/README.md
Normal file
46
packages/abx-plugin-readability-extractor/__init__.py
Normal file
46
packages/abx-plugin-readability-extractor/__init__.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
__package__ = 'plugins_extractor.readability'
|
||||
__label__ = 'readability'
|
||||
__version__ = '2024.10.14'
|
||||
__author__ = 'ArchiveBox'
|
||||
__homepage__ = 'https://github.com/ArchiveBox/readability-extractor'
|
||||
__dependencies__ = ['npm']
|
||||
|
||||
import abx
|
||||
|
||||
|
||||
@abx.hookimpl
|
||||
def get_PLUGIN():
|
||||
return {
|
||||
'readability': {
|
||||
'PACKAGE': __package__,
|
||||
'LABEL': __label__,
|
||||
'VERSION': __version__,
|
||||
'AUTHOR': __author__,
|
||||
'HOMEPAGE': __homepage__,
|
||||
'DEPENDENCIES': __dependencies__,
|
||||
}
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_CONFIG():
|
||||
from .config import READABILITY_CONFIG
|
||||
|
||||
return {
|
||||
'readability': READABILITY_CONFIG
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_BINARIES():
|
||||
from .binaries import READABILITY_BINARY
|
||||
|
||||
return {
|
||||
'readability': READABILITY_BINARY,
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_EXTRACTORS():
|
||||
from .extractors import READABILITY_EXTRACTOR
|
||||
|
||||
return {
|
||||
'readability': READABILITY_EXTRACTOR,
|
||||
}
|
27
packages/abx-plugin-readability-extractor/binaries.py
Normal file
27
packages/abx-plugin-readability-extractor/binaries.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
__package__ = 'plugins_extractor.readability'
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import InstanceOf
|
||||
from pydantic_pkgr import BinProvider, BinaryOverrides, BinName
|
||||
|
||||
from abx.archivebox.base_binary import BaseBinary, env
|
||||
|
||||
from plugins_pkg.npm.binproviders import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER
|
||||
|
||||
from .config import READABILITY_CONFIG
|
||||
|
||||
|
||||
READABILITY_PACKAGE_NAME = 'github:ArchiveBox/readability-extractor'
|
||||
|
||||
class ReadabilityBinary(BaseBinary):
|
||||
name: BinName = READABILITY_CONFIG.READABILITY_BINARY
|
||||
binproviders_supported: List[InstanceOf[BinProvider]] = [LIB_NPM_BINPROVIDER, SYS_NPM_BINPROVIDER, env]
|
||||
|
||||
overrides: BinaryOverrides = {
|
||||
LIB_NPM_BINPROVIDER.name: {"packages": [READABILITY_PACKAGE_NAME]},
|
||||
SYS_NPM_BINPROVIDER.name: {"packages": [READABILITY_PACKAGE_NAME], "install": lambda: None}, # prevent modifying system global npm packages
|
||||
}
|
||||
|
||||
|
||||
READABILITY_BINARY = ReadabilityBinary()
|
19
packages/abx-plugin-readability-extractor/config.py
Normal file
19
packages/abx-plugin-readability-extractor/config.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
__package__ = 'plugins_extractor.readability'
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from abx.archivebox.base_configset import BaseConfigSet
|
||||
|
||||
from archivebox.config.common import ARCHIVING_CONFIG
|
||||
|
||||
|
||||
class ReadabilityConfig(BaseConfigSet):
|
||||
SAVE_READABILITY: bool = Field(default=True, alias='USE_READABILITY')
|
||||
|
||||
READABILITY_TIMEOUT: int = Field(default=lambda: ARCHIVING_CONFIG.TIMEOUT)
|
||||
|
||||
READABILITY_BINARY: str = Field(default='readability-extractor')
|
||||
# READABILITY_EXTRA_ARGS: List[str] = [] # readability-extractor doesn't take any extra args
|
||||
|
||||
|
||||
READABILITY_CONFIG = ReadabilityConfig()
|
20
packages/abx-plugin-readability-extractor/extractors.py
Normal file
20
packages/abx-plugin-readability-extractor/extractors.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
__package__ = 'plugins_extractor.readability'
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic_pkgr import BinName
|
||||
|
||||
from abx.archivebox.base_extractor import BaseExtractor
|
||||
|
||||
from .binaries import READABILITY_BINARY
|
||||
|
||||
|
||||
class ReadabilityExtractor(BaseExtractor):
|
||||
name: str = 'readability'
|
||||
binary: BinName = READABILITY_BINARY.name
|
||||
|
||||
def get_output_path(self, snapshot) -> Path:
|
||||
return Path(snapshot.link_dir) / 'readability' / 'content.html'
|
||||
|
||||
|
||||
READABILITY_EXTRACTOR = ReadabilityExtractor()
|
7
packages/abx-plugin-readability-extractor/pyproject.toml
Normal file
7
packages/abx-plugin-readability-extractor/pyproject.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[project]
|
||||
name = "abx-readability-extractor"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = []
|
Loading…
Add table
Add a link
Reference in a new issue