summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-11-05 23:01:55 +0100
committerYorhel <git@yorhel.nl>2009-11-05 23:01:55 +0100
commited8192a652bc8c2b18c1cd9a52412faf0234966b (patch)
tree8cc7cd490982903d32a6e432cde09161c8076958
parent1ff074a56239fbd8e847010ba21e00067103afac (diff)
API: Added 'details' info flag to the get vn command
-rw-r--r--data/docs/1114
-rw-r--r--lib/Multi/API.pm27
2 files changed, 34 insertions, 7 deletions
diff --git a/data/docs/11 b/data/docs/11
index 4f735ff6..84a9f97f 100644
--- a/data/docs/11
+++ b/data/docs/11
@@ -236,11 +236,23 @@ however still required.<br />
array of strings. Can be an empty array when nothing has been released yet.
</dd><dt>platforms (basic)</dt><dd>
array of strings. Can be an empty array when unknown or nothing has been released yet.
+ </dd><dt>aliases (details)</dt><dd>
+ string, comma-separated list of aliases. Can be <b>null</b>.
+ </dd><dt>length (details)</dt><dd>
+ integer between 1 and 5, length of the game. <b>null</b> when unknown.
+ </dd><dt>description (details)</dt><dd>
+ string, description of the VN. Note that this description can include formatting codes as described in d9.3.
+ <b>null</b> when whe don't have a description.
+ </dd><dt>links (details)</dt><dd>
+ object. Contains the following members:<br />
+ "wikipedia", string, name of the related article on the English Wikipedia.<br />
+ "encubed", string, the URL-encoded tag used on <a href="http://novelnews.net/">encubed</a>.<br />
+ "renai", string, the name part of the url on <a href="http://renai.us/">renai.us</a>.<br />
+ All members can be <b>null</b> when no links are available or known to us.
</dd>
</dl>
<br />
-
<b>Filters:</b>
<dl>
<dt>id</dt><dd>
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 53bb640a..c94c120b 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -294,9 +294,11 @@ sub login_res { # num, res, [ c, arg ]
sub get_vn {
my($c, $info, $filters) = @_[ARG0..$#_];
- return cerr $c, getinfo => "Unkown info flag '$_'", flag => $_ for (grep $_ ne 'basic', @$info);
+ return cerr $c, getinfo => "Unkown info flag '$_'", flag => $_ for (grep !/^(basic|details)$/, @$info);
- my $select = 'v.id, vr.title, vr.original, v.c_released, v.c_languages, v.c_platforms';
+ my $select = 'v.id';
+ $select .= ', vr.title, vr.original, v.c_released, v.c_languages, v.c_platforms' if grep /basic/, @$info;
+ $select .= ', vr.alias AS aliases, vr.length, vr.desc AS description, vr.l_wp, vr.l_encubed, vr.l_renai' if grep /details/, @$info;
my @placeholders;
my $where = encode_filters $filters, \&filtertosql, $c, \@placeholders, [
@@ -340,10 +342,23 @@ sub get_vn_res {
for (@$res) {
$_->{id}*=1;
- $_->{original} ||= undef;
- $_->{platforms} = [ split /\//, delete $_->{c_platforms} ];
- $_->{languages} = [ split /\//, delete $_->{c_languages} ];
- $_->{released} = formatdate delete $_->{c_released};
+ if(grep /basic/, @$info) {
+ $_->{original} ||= undef;
+ $_->{platforms} = [ split /\//, delete $_->{c_platforms} ];
+ $_->{languages} = [ split /\//, delete $_->{c_languages} ];
+ $_->{released} = formatdate delete $_->{c_released};
+ }
+ if(grep /details/, @$info) {
+ $_->{aliases} ||= undef;
+ $_->{length} *= 1;
+ $_->{length} ||= undef;
+ $_->{description} ||= undef;
+ $_->{links} = {
+ wikipedia => delete($_->{l_wp}) ||undef,
+ encubed => delete($_->{l_encubed})||undef,
+ renai => delete($_->{l_renai}) ||undef
+ };
+ }
}
$c->{wheel}->put([ results => { num => $#$res+1, items => $res }]);