From ed8192a652bc8c2b18c1cd9a52412faf0234966b Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 5 Nov 2009 23:01:55 +0100 Subject: API: Added 'details' info flag to the get vn command --- data/docs/11 | 14 +++++++++++++- lib/Multi/API.pm | 27 +++++++++++++++++++++------ 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.
array of strings. Can be an empty array when nothing has been released yet.
platforms (basic)
array of strings. Can be an empty array when unknown or nothing has been released yet. +
aliases (details)
+ string, comma-separated list of aliases. Can be null. +
length (details)
+ integer between 1 and 5, length of the game. null when unknown. +
description (details)
+ string, description of the VN. Note that this description can include formatting codes as described in d9.3. + null when whe don't have a description. +
links (details)
+ object. Contains the following members:
+ "wikipedia", string, name of the related article on the English Wikipedia.
+ "encubed", string, the URL-encoded tag used on encubed.
+ "renai", string, the name part of the url on renai.us.
+ All members can be null when no links are available or known to us.

- Filters:
id
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 }]); -- cgit v1.2.3