mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-31 23:08:25 -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-singlefile-extractor/README.md
Normal file
0
packages/abx-plugin-singlefile-extractor/README.md
Normal file
51
packages/abx-plugin-singlefile-extractor/__init__.py
Normal file
51
packages/abx-plugin-singlefile-extractor/__init__.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
__package__ = 'plugins_extractor.singlefile'
|
||||
__label__ = 'singlefile'
|
||||
__version__ = '2024.10.14'
|
||||
__author__ = 'ArchiveBox'
|
||||
__homepage__ = 'https://github.com/gildas-lormeau/singlefile'
|
||||
__dependencies__ = ['npm']
|
||||
|
||||
import abx
|
||||
|
||||
|
||||
@abx.hookimpl
|
||||
def get_PLUGIN():
|
||||
return {
|
||||
'singlefile': {
|
||||
'PACKAGE': __package__,
|
||||
'LABEL': __label__,
|
||||
'VERSION': __version__,
|
||||
'AUTHOR': __author__,
|
||||
'HOMEPAGE': __homepage__,
|
||||
'DEPENDENCIES': __dependencies__,
|
||||
}
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_CONFIG():
|
||||
from .config import SINGLEFILE_CONFIG
|
||||
|
||||
return {
|
||||
'singlefile': SINGLEFILE_CONFIG
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_BINARIES():
|
||||
from .binaries import SINGLEFILE_BINARY
|
||||
|
||||
return {
|
||||
'singlefile': SINGLEFILE_BINARY,
|
||||
}
|
||||
|
||||
@abx.hookimpl
|
||||
def get_EXTRACTORS():
|
||||
from .extractors import SINGLEFILE_EXTRACTOR
|
||||
|
||||
return {
|
||||
'singlefile': SINGLEFILE_EXTRACTOR,
|
||||
}
|
||||
|
||||
# @abx.hookimpl
|
||||
# def get_INSTALLED_APPS():
|
||||
# # needed to load ./models.py
|
||||
# return [__package__]
|
48
packages/abx-plugin-singlefile-extractor/binaries.py
Normal file
48
packages/abx-plugin-singlefile-extractor/binaries.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
__package__ = 'plugins_extractor.singlefile'
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import InstanceOf
|
||||
from pydantic_pkgr import BinProvider, BinaryOverrides, BinName, bin_abspath
|
||||
|
||||
from abx.archivebox.base_binary import BaseBinary, env
|
||||
|
||||
from plugins_pkg.npm.binproviders import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER
|
||||
|
||||
from .config import SINGLEFILE_CONFIG
|
||||
|
||||
|
||||
SINGLEFILE_MIN_VERSION = '1.1.54'
|
||||
SINGLEFILE_MAX_VERSION = '1.1.60'
|
||||
|
||||
|
||||
class SinglefileBinary(BaseBinary):
|
||||
name: BinName = SINGLEFILE_CONFIG.SINGLEFILE_BINARY
|
||||
binproviders_supported: List[InstanceOf[BinProvider]] = [LIB_NPM_BINPROVIDER, SYS_NPM_BINPROVIDER, env]
|
||||
|
||||
overrides: BinaryOverrides = {
|
||||
LIB_NPM_BINPROVIDER.name: {
|
||||
"abspath": lambda:
|
||||
bin_abspath(SINGLEFILE_CONFIG.SINGLEFILE_BINARY, PATH=LIB_NPM_BINPROVIDER.PATH)
|
||||
or bin_abspath("single-file", PATH=LIB_NPM_BINPROVIDER.PATH)
|
||||
or bin_abspath("single-file-node.js", PATH=LIB_NPM_BINPROVIDER.PATH),
|
||||
"packages": [f"single-file-cli@>={SINGLEFILE_MIN_VERSION} <{SINGLEFILE_MAX_VERSION}"],
|
||||
},
|
||||
SYS_NPM_BINPROVIDER.name: {
|
||||
"abspath": lambda:
|
||||
bin_abspath(SINGLEFILE_CONFIG.SINGLEFILE_BINARY, PATH=SYS_NPM_BINPROVIDER.PATH)
|
||||
or bin_abspath("single-file", PATH=SYS_NPM_BINPROVIDER.PATH)
|
||||
or bin_abspath("single-file-node.js", PATH=SYS_NPM_BINPROVIDER.PATH),
|
||||
"packages": [f"single-file-cli@>={SINGLEFILE_MIN_VERSION} <{SINGLEFILE_MAX_VERSION}"],
|
||||
"install": lambda: None,
|
||||
},
|
||||
env.name: {
|
||||
'abspath': lambda:
|
||||
bin_abspath(SINGLEFILE_CONFIG.SINGLEFILE_BINARY, PATH=env.PATH)
|
||||
or bin_abspath('single-file', PATH=env.PATH)
|
||||
or bin_abspath('single-file-node.js', PATH=env.PATH),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
SINGLEFILE_BINARY = SinglefileBinary()
|
25
packages/abx-plugin-singlefile-extractor/config.py
Normal file
25
packages/abx-plugin-singlefile-extractor/config.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
__package__ = 'plugins_extractor.singlefile'
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from abx.archivebox.base_configset import BaseConfigSet
|
||||
|
||||
from archivebox.config.common import ARCHIVING_CONFIG
|
||||
|
||||
|
||||
class SinglefileConfig(BaseConfigSet):
|
||||
SAVE_SINGLEFILE: bool = True
|
||||
|
||||
SINGLEFILE_USER_AGENT: str = Field(default=lambda: ARCHIVING_CONFIG.USER_AGENT)
|
||||
SINGLEFILE_TIMEOUT: int = Field(default=lambda: ARCHIVING_CONFIG.TIMEOUT)
|
||||
SINGLEFILE_CHECK_SSL_VALIDITY: bool = Field(default=lambda: ARCHIVING_CONFIG.CHECK_SSL_VALIDITY)
|
||||
SINGLEFILE_COOKIES_FILE: Optional[Path] = Field(default=lambda: ARCHIVING_CONFIG.COOKIES_FILE)
|
||||
|
||||
SINGLEFILE_BINARY: str = Field(default='single-file')
|
||||
SINGLEFILE_EXTRA_ARGS: List[str] = []
|
||||
|
||||
|
||||
SINGLEFILE_CONFIG = SinglefileConfig()
|
19
packages/abx-plugin-singlefile-extractor/extractors.py
Normal file
19
packages/abx-plugin-singlefile-extractor/extractors.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
__package__ = 'plugins_extractor.singlefile'
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic_pkgr import BinName
|
||||
from abx.archivebox.base_extractor import BaseExtractor
|
||||
|
||||
from .binaries import SINGLEFILE_BINARY
|
||||
|
||||
|
||||
class SinglefileExtractor(BaseExtractor):
|
||||
name: str = 'singlefile'
|
||||
binary: BinName = SINGLEFILE_BINARY.name
|
||||
|
||||
def get_output_path(self, snapshot) -> Path:
|
||||
return Path(snapshot.link_dir) / 'singlefile.html'
|
||||
|
||||
|
||||
SINGLEFILE_EXTRACTOR = SinglefileExtractor()
|
14
packages/abx-plugin-singlefile-extractor/models.py
Normal file
14
packages/abx-plugin-singlefile-extractor/models.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from django.db import models
|
||||
|
||||
from core.models import ArchiveResult
|
||||
|
||||
class SinglefileResultManager(models.Manager):
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(extractor='singlefile')
|
||||
|
||||
|
||||
class SinglefileResult(ArchiveResult):
|
||||
objects = SinglefileResultManager()
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
7
packages/abx-plugin-singlefile-extractor/pyproject.toml
Normal file
7
packages/abx-plugin-singlefile-extractor/pyproject.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[project]
|
||||
name = "abx-singlefile-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