View Single Post
Old 10-02-2010, 09:22 AM   #218
AtomicDryad
Member
AtomicDryad began at the beginning.
 
AtomicDryad's Avatar
 
Posts: 14
Karma: 10
Join Date: Sep 2010
Device: psp, htc g1
Regarding modules and commandline, there's also the question about what to do with url arguments. As is, for a new source plugin one must edit arg.inc.php and add a regexp. The following way of doing it would remove that need...the idea is real modularity; being able to drop in any valid .php in the source directory without editing the base program.
args.inc would process things like this:
parse $argc/$argv/parameters, setting non module specific options (which can include disabling a module etc)
stuff everything else into $arr['extra'] or ['moduleopts']
determine what modules to load, do so, and call the modules 'getinfo' function. One of the things that would do would be to add to an $argspec (or somesuch) array, which is a nested hash of regex strings and other info like this:
Spoiler:

$argspec=array(
array(regex=>"!(fanfiction\.net/s/([0-9]+)|^([0-9]+)$)!i",
site=>"ffnet",
type=>"story"),
array(regex=>"!(fanfiction\.net/u/([0-9]+))!i",
site=>"ffnet",
type=>"list"),
array(regex=>"!(fanfiction\.net/community/[^/]+/([0-9]+))!i",
site=>"ffnet",
type=>"list"),
array(regex=>"!archiveofourown\.org/works/([0-9]+)!i",
site=>"aooo",
type=>"story"),
);

Next, any ambiguous non-options like urls or files are processed to populate a 'downloads' nested hash. I've got a working example of this.
fflag -D http://archiveofourown.org/works/00000000 http://www.fanfiction.net/s/3748479/1/A_Very_Big_Weapon imjustaguy_-_A_Very_Big_Weapon.html http://fanfiction.net/u/12345
results in:
Spoiler:

[downloads] => Array
(
[story] => Array
(
[1] => Array
(
[site] => aooo
[id] => 00000000
[arg] => http://archiveofourown.org/works/00000000
)

[2] => Array
(
[site] => ffnet
[id] => fanfiction.net/s/3748479
[arg] => http://www.fanfiction.net/s/3748479/1/A_Very_Big_Weapon
)

)

[file] => Array
(
[3] => Array
(
[arg] => imjustaguy_-_A_Very_Big_Weapon.html
[site] => ffnet
[filename] => imjustaguy_-_A_Very_Big_Weapon.html
)

)
[list] => Array
(
[4] => Array
(
[site] => ffnet
[id] => fanfiction.net/u/12345
[arg] => http://fanfiction.net/u/12345
)

)

)


When fflag starts to process it's downloads:
* It first checks $opt['downloads']['file'] to determine what the file's site/story is, then:
* $opt['downloads']['list'], calling the appropriate source module's _get_storylist function, adding what it finds to:
* $opt['downloads']['story'], which is processed last, fflag selecting sites on a per entry basis, and output filenames where specified.

Last edited by AtomicDryad; 10-02-2010 at 09:29 AM.
AtomicDryad is offline   Reply With Quote