add xpath extractor

This commit is contained in:
Robin Appelman 2025-11-03 21:21:25 +01:00
commit b423323473
8 changed files with 1198 additions and 57 deletions

View file

@ -41,8 +41,12 @@ And two action options:
- `move`: directory to move the file into, will be created if necessary
- `rename`: rename the file
Action options can refer to capture groups from the match options and the file
mtime to dynamically set the target directory and name.
Actions options can refer to the following data extracted from the rule to
dynamically set the target directory and name.
- Any named regex capture group
- `mtime`: unix timestamp of the downloaded file
- `xpath('....')` an xpath expression to match on the download file
Multiple rule sections can be configured, the first matching rule will be used.
@ -73,6 +77,15 @@ url = "https://www.paypal.com"
move = "~/Downloads/Paypal Statements/$mtime.csv" # $mtime is set to the unix timestamp
```
Rename based on an XPath expression
```toml
[[rule]]
name = ".+\\.(lss)"
move = "~/Livesplits/${xpath('//GameName/text()')}"
rename = "${xpath('//CategoryName/text()')} - ${xpath('//Metadata/Variables/Variable[contains(@name, \"Subcategory\")]/text()')}.lss"
```
### Url and referrer
Galton uses the standard `user.xdg.origin.url` and `user.xdg.referrer.url`
@ -92,7 +105,7 @@ to automatically create a symlink to the new location of the file.
symlink = "~/Downloads/last"
```
## Lastest download symlink
## Remove duplicate downloads
Galton can also be used to clean up duplicate downloads, when enabled, it will
check for any existing file with the same contents in the target directory and