models
Extraction
Bases: BaseModel
Represents the extracted data from a source.
Source code in src/torah_dl/core/models.py
7 8 9 10 11 12 13 |
|
Extractor
Bases: ABC
Abstract base class for all extractors.
Source code in src/torah_dl/core/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
url_patterns
abstractmethod
property
url_patterns: Pattern | list[Pattern]
Returns the regex pattern(s) that match URLs this extractor can handle. Can return either a single compiled regex pattern or a list of patterns.
can_handle
can_handle(url: str) -> bool
Checks if this extractor can handle the given URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL to check |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this extractor can handle the URL, False otherwise |
Source code in src/torah_dl/core/models.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
extract
abstractmethod
extract(url: str) -> Extraction
Extracts data from the given URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL to extract from |
required |
Returns:
Name | Type | Description |
---|---|---|
Extraction |
Extraction
|
The extracted data |
Raises:
Type | Description |
---|---|
ValueError
|
If the URL is not supported by this extractor |
Source code in src/torah_dl/core/models.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|