23 lines
559 B
Python
23 lines
559 B
Python
|
"""
|
||
|
Filter paths found in a resource.
|
||
|
|
||
|
This plugin implements :func:`rp_filter`.
|
||
|
"""
|
||
|
|
||
|
from typing import Optional
|
||
|
|
||
|
|
||
|
def rp_filter(site, durl) -> Optional[str]:
|
||
|
"""
|
||
|
Adjust or filter found paths (may depend on site).
|
||
|
|
||
|
To filter out a path (i.e., not add it to table `site_path`)
|
||
|
return None.
|
||
|
"""
|
||
|
path = durl.pwa()
|
||
|
# skip fetching images (linked from a tags; img tags are skipped anyway)
|
||
|
if path.lower().endswith('.jpg') or path.lower().endswith('.png'):
|
||
|
return None
|
||
|
path = path.removesuffix('?amp=1')
|
||
|
return path
|