#1
|
|||
|
|||
Specific regex version to use for linkcrawler?
I'm new with the whole regex thing and is trying to figure out how to use the REWRITE crawler rules but I'm pulling my hair since I can't get it to work.
In your knowledge base you link to regex101 for checking your code. So I create something that works there but when trying to use it in JD I just get this error Code:
is not valid 'java.util.List<jd.controlling.linkcrawler.LinkCrawlerRuleStorable>' What settings should I use on regex101 so it's compatible with JD? Where can I find a reference to the regex that's used in your examples because the links you provide in the knowledgebase and sites I found myself doesn't seem to cover whatever version is used in JD or I'm missreading something completely. |
#2
|
||||
|
||||
@inzzzomnia: The rules are JSON strings and therefore must be encoded properly.
Most important is to escape the \ and " character. On regex101, you should change to java flavor. Just post example/your rule here and we will explain/help with JSON escaping, eg freeformatter.com/json-escape.html
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 17.06.2021 at 18:28. |
#3
|
|||
|
|||
The double backslashes is was confuses me the most in your examples, can't figure out what purpose they serve since there's no single backslash to escape at that place in the URL.
This gets a green light with java 8 selected on regex101 (https:\/\/img.nbc.com\/sites\/[a-z]*\/files\/images\/\d*\/\d*\/\d*\/NUP_\d*_\d*.JPG)\?impolicy=.*&imwidth=\d*&imdensity=\d* and match what I try to fix **External links are only visible to Support Staff****External links are only visible to Support Staff** But JD still wont accept Code:
[{ "enabled": true, "name": "nbc", "pattern": "(https:\/\/img.nbc.com\/sites\/[a-z]*\/files\/images\/\d*\/\d*\/\d*\/NUP_\d*_\d*.JPG)\?impolicy=.*&imwidth=\d*&imdensity=\d*", "rule": "REWRITE", "rewriteReplaceWith": "$1" }] |
#4
|
||||
|
||||
Stop escaping single normal (forward) slashes in JD
-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download Last edited by pspzockerscene; 17.06.2021 at 18:27. |
#5
|
||||
|
||||
see pastebin.com/PxQYAW13
You don't have to escape /, you have to make sure to proper json escaping see freeformatter.com/json-escape.html jsonformatter.org/json-pretty-print
__________________
JD-Dev & Server-Admin Last edited by pspzockerscene; 18.06.2021 at 13:04. Reason: fixed reeformatter.com --> freeformatter.com |
#6
|
||||
|
||||
Also you should escape dots (see the meaning of a dot in regex101.com) though in this case no escaping them will still do the job.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#7
|
|||
|
|||
Quote:
Quote:
Quote:
The check on regex101 was marking the slashes red in my first attempts at this but with escaping they was marked OK so I went with it. So with that said regex101 really can't be used since it OKs versions that isn't working in JD, even with the "proper" java setting. Any other tool that has the same explaining thingy but actually help you with a proper version that will work with JD? Last edited by pspzockerscene; 18.06.2021 at 13:04. Reason: fixed reeformatter.com --> freeformatter.com |
#8
|
||||
|
||||
Quote:
Quote:
Quote:
Really the only thing that bothers me is the double backslash escaping but as said you can easily fix this via search and replace. You could probably easily make a macro/script for an advanced text editor such as "Notepad++" that can auto-handle these replacements. -psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#9
|
|||
|
|||
Pattern generated on that site with 'java 8' flavor should work just fine directly in packagizer, linkfilter etc. Additional escaping is required only for settings like linkcrawler/domain rules which are stored in JSON format. You can run the 'Code Generator' found at the bottom on the same page on that site and copy just the escaped pattern (final String regex) from the generated code and use it directly in JSON objects in JD.
|
Thread Tools | |
Display Modes | |
|
|