shawn Posted October 3, 2010 Report Share Posted October 3, 2010 I needed the ability to randomly select a source from a site the other day, in order to not fixate the download to one specific source and overburden it (not that that's very likely), but it would have been easier if there were a "random" function within Ketarin. I imagine it would operate in several different syntaxes, based on the source and parameters fed to it. Here's simplest form: {varname:random} This would parse and return one of the lines from the {varname} variable. Parsing would be performed by default at carriage returns. Another: {varname:random:delimiter} This one parses {varname} in the same fashion, but at the delimiter specified, instead of at carriage returns. Another: {random:list:var1:var2:var3:var4:var5:var6} This syntax would randomly return one of the variables named within it (note the lack of a 'varname' prefix). Another: {random:range:3000:3006} Would randomly choose a value, inclusively, between 3000 and 3006. Another: {random:varname} This is the one that would be most applicable to me immediately. This one changes the behavior of a RegEx or Start/End variable to instead parse for multiple results of the RegEx or Start/End combo and return a RANDOM result from the matches. Yes, I understand this would be freaky and probably require a large rewrite of the variable handling stuff, but it would let us use a truly random source when available - instead of the first result. Imagine using it with this regex, for example: <option value="([^"]+)"> Link to comment Share on other sites More sharing options...
floele Posted October 3, 2010 Report Share Posted October 3, 2010 {random:varname} Indeed, this is not quite doable. Instead, I could offer a function "regexrandom" which works like "regex", but if multiple matches are found, it randomly returns a match. Link to comment Share on other sites More sharing options...
CybTekSol Posted October 3, 2010 Report Share Posted October 3, 2010 This would be useful indeed for me! Link to comment Share on other sites More sharing options...
shawn Posted October 6, 2010 Author Report Share Posted October 6, 2010 That would satisfy most of my needs. Link to comment Share on other sites More sharing options...
Gozi Posted October 7, 2010 Report Share Posted October 7, 2010 (edited) Hi Shawn, only another dirty idea...... ;-) if you can parse the content for {varname} the random function can be done over Ketarin command and a simple batch Set /a Randomized=%random% This will give you a number between 1-32767 Combined with some If-...Else Commands you could generate any number or Char you like and with wget.exe (as I use in my Softpedia template) you can download the source. BUT you need a dummy Download link with alterating content for ketarin to initialize the download. EDIT: This could be the dummy with alterating content. It changes every 5 min. http://www.wetteronline.de/daten/sat/2010/10/07/eurf1900.jpg?1286478000 Edited October 7, 2010 by Gozi Link to comment Share on other sites More sharing options...
shawn Posted October 12, 2010 Author Report Share Posted October 12, 2010 Thanks, Gozi, but I'm actually more interested in obtaining a random source link from a regex-matching pattern from an HTML result. Such as the download source lists on MySQL, IrfanView, and similar sites where the list uses something much different than an appended number to identify the different sources. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now