First, I've noticed that at least one site -- UKNoVa -- sometimes lists Season and Episode number in lowercase, i.e. s03e06, which will not match the Episode regexps. What do you think about making them case-insensitive, or replacing S with [Ss] and E with [Ee] in them?
Secondly, in the link modification, it seems that there may come a time when the Torrent URL is more complicated than a simple search-replace from the source link. I was thinking about adding full Regexp support, with capturing groups, so that if say 2 areas of the URL needed to be replaced, one could specify both using the current interface. Plus, making the Link Modification fully regexp should not break most existing link modifications.
Well you already can use full Regex.
String newUrl = feed.getModLinkRegex().matcher(item.getLink()).replaceAll(feed.getModLinkReplace());
that is used to replace everything.
Here's a thought: would there be any way to build the HTTP-REFERRER from the matcher that was used to match the URL, so that the Referrer could contain back-references ($1, $2, etc) to the captured groups in the Source URL. In this way, not only could you do smart replacements on sites like Demonoid and MiniNova, but you could generate the referrer as if the torrent request was coming from the page that the RSS Feed referred to.
But I am having a problem with the mininova site. I want to replace "^http://www.mininova.org/tor/([0-9]+)$" with "http://www.mininova.org/get/\1", where the \1 should be replaced with the first matching string (the number). The replaceAll method interprets that literally, instead of replacing the "\1" with the portion in parenthesis.
Oops, forgot that Java Regex replaces are like PERL, not Python. Python uses \1 for first match, Java and PERL use $1. That was my mistake. Sorry! :(
Well in java regex there is also the back reference \1, but that only applies inside a regex. Not with replaceAll
eg "(ab)\1" would mach abab
Well for mininova it is even listed in the help you know ^^. Just replace /tor/ with /get/ :P
Please refer to http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Matcher.html#replaceAll\(java.lang.String)
as it is stated there you have to use $1 as back reference instead of \1
>> Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string.
Log in to post a comment.