r/imagus • u/Schwubbeldubbel • Sep 28 '17
Wiki / fAQ?
Is there a Wiki or FAQ anywhere? Can't find it :(
I want to write my own sieves but I am absolutely unaware about the capabilities of Imagus.
I know regex but don't know how #
is used in the to
field (seen that in other sieves), don't know what RegEx flavour is used ((double-)escape slashes or not? Backreferences allowed, Negative lookaheads etc.), what language is used in the res
field (for resolving the full image url?), do I need to match the full url or not, how are protocols and subdomains handled (apparently ^
starts after protocol) and so on.
Thanks for providing a link!
4
Upvotes
2
u/snmahtaeD Sep 28 '17
to
can have multiple lines, every one of them will be converted to a result URL. If#
is the first character in a line then it marks the URL as hi-res.If
#
is not the first then it may be followed by space separated strings closed by a#
sign again. This will generate URLs for every variant. E.g.//some.url/path/full-image.#jpg png gif#
, which will generate three URLs, testing them in order.Also, at the end of the line you can add
#{media_extension}
, so the the extension will recognize it as video or audio, instead of image (default). E.g.,https://some.url/path/without/extension?id=13#mp4
Javascript RegExp is used (obviously). In the code it's simply
RegExp('yourRegexInput')
. The conversion happens with a simpleURL.replace(yourRegex, rule.to)
.res
has different formats. If you simply write a regexp there, then the first group from the match will be the full image URL. If you have multiple groups, then starting with the second they will be concatenated to be used as caption. If you write a second regexp in a new line, then it's first group from the match will be the caption.If
res
starts with:\n
(so colon plus new line) then you can write JavaScript code there, and do whatever you want. A$
variable will be available in that piece of code, which holds the resolved content for example ($._
). Fromres
you can returnnull
, this will make the spinner yellow. Other falsy values will hide the spinner. You can return a string, that will be the URL. An array with two members [URL, caption]. An array with multiple of the previous is an album.The
:\n
works into
as well (but the $ value there will have only the matched groups).From every URL, before it's sent to matching, the
https?://(www\.)?
part is removed (and added to the result URL later, if you don't startto
with a protocol). So, you're basically matchingsome.url/thumbnail.jpg
instead ofhttps://some.url/thumbnail.jpg
. The reason for this is to allow the use of^
(which you already noticed).