summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/docs/11141
-rw-r--r--lib/Multi/API.pm75
2 files changed, 216 insertions, 0 deletions
diff --git a/data/docs/11 b/data/docs/11
index 56246d05..e9b41299 100644
--- a/data/docs/11
+++ b/data/docs/11
@@ -479,6 +479,21 @@ however still required.<br />
"width", integer, width of the full-size screenshot
</td>
</tr>
+ <tr class="odd">
+ <td>staff</td>
+ <td>staff</td>
+ <td>array of objects</td>
+ <td>no</td>
+ <td>
+ (Possibly empty) list of staff related to the VN, each object has the following members:<br />
+ "sid", integer, staff ID<br />
+ "aid", integer, alias ID<br />
+ "name", string<br />
+ "original", string, possibly null<br />
+ "role", string<br />
+ "note", string, possibly null
+ </td>
+ </tr>
</table>
<p>Sorting is possible on the following fields: id, title, released, popularity, rating, votecount.</p><br />
@@ -1147,6 +1162,126 @@ however still required.<br />
</table>
+:SUBSUB:get staff
+<p>
+Unlike other database entries, staff have more than one unique identifier.<br />
+There is the main 'staff ID', which uniquely identifies a person and is what
+the staff pages on the site represent.<br />
+Additionally, every staff name and alias also has its own unique identifier,
+which is referenced from other database entries to identify which alias was
+used. This identifier is generally hidden on the site and aliases do not have
+their own page, but the IDs are exposed in this API in order to facilitate
+linking between VNs/characters and staff.<br />
+<br />
+Returned members:</p>
+<table style="margin: 5px 2%; width: 95%">
+ <thead><tr>
+ <td style="width: 80px">Member</td>
+ <td style="width: 50px">Flag</td>
+ <td style="width: 90px">Type</td>
+ <td style="width: 40px">null</td>
+ <td>Description</td>
+ </tr></thead>
+ <tr class="odd">
+ <td>id</td>
+ <td>-</td>
+ <td>integer</td>
+ <td>no</td>
+ <td>Staff ID</td>
+ </tr>
+ <tr>
+ <td>name</td>
+ <td>basic</td>
+ <td>string</td>
+ <td>no</td>
+ <td>Primary (romaji) staff name</td>
+ </tr>
+ <tr class="odd">
+ <td>original</td>
+ <td>basic</td>
+ <td>string</td>
+ <td>yes</td>
+ <td>Primary original name</td>
+ </tr>
+ <tr>
+ <td>gender</td>
+ <td>basic</td>
+ <td>string</td>
+ <td>yes</td>
+ <td></td>
+ </tr>
+ <tr class="odd">
+ <td>language</td>
+ <td>basic</td>
+ <td>string</td>
+ <td>no</td>
+ <td>Primary language</td>
+ </tr>
+ <tr>
+ <td>links</td>
+ <td>details</td>
+ <td>object</td>
+ <td>no</td>
+ <td>
+ External links, object has the following members:<br />
+ "homepage", official homepage,<br />
+ "wikipedia", title of the related article on the English wikipedia.<br />
+ "twitter", name of the twitter account.<br />
+ "anidb", <a href="http://anidb.net/">AniDB</a> creator ID.<br />
+ All values can be <b>null</b>.
+ </td>
+ </tr>
+ <tr class="odd">
+ <td>description</td>
+ <td>details</td>
+ <td>string</td>
+ <td>yes</td>
+ <td>Description/notes of the staff, can contain formatting codes as described in <a href="/d9.3">d9.3</a></td>
+ </tr>
+ <tr>
+ <td>aliases</td>
+ <td>aliases</td>
+ <td>array of arrays</td>
+ <td>no</td>
+ <td>
+ List of names and aliases. Each name is represented as an array with the
+ following elements: Alias ID, name (romaji) and the original name.<br />
+ This list also includes the "primary" name.
+ </td>
+ </tr>
+ <tr class="odd">
+ <td>main_alias</td>
+ <td>aliases</td>
+ <td>integer</td>
+ <td>no</td>
+ <td>ID of the alias that is the "primary" name of the entry</td>
+ </tr>
+</table>
+<p>Sorting is possible on the 'id' field.</p><br />
+
+<p>The following filters are recognised:</p>
+<table style="margin: 5px 2%; width: 95%">
+ <thead><tr>
+ <td style="width: 80px">Field</td>
+ <td style="width: 90px">Value</td>
+ <td style="width: 90px">Operators</td>
+ <td>&nbsp;</td>
+ </tr></thead>
+ <tr class="odd">
+ <td>id</td>
+ <td>integer<br />array of integers</td>
+ <td>= != &gt; &gt;= &lt; &lt;=<br />= !=</td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>aid</td>
+ <td>integer<br />array of integers</td>
+ <td>=<br />=</td>
+ <td>&nbsp;</td>
+ </tr>
+</table>
+
+
:SUBSUB:get user
<p>Returned members:</p>
<table style="margin: 5px 2%; width: 95%">
@@ -1526,7 +1661,13 @@ however still required.<br />
<p>
This section lists the changes made in each version of the VNDB code.
Check out the <a href="/t/an">announcements board</a> for more information about updates.
+ <br /><br />
</p>
+<b>2017-04-28</b> <b class="grayedout">because screw version numbers</b>
+<ul>
+ <li>Add "get staff" command</li>
+ <li>Add "staff" flag to "get vn" command</li>
+</ul>
<b>2.27</b>
<ul>
<li>Add "username" filter to "get user"</li>
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 807e72f8..d4732d57 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -496,6 +496,23 @@ my %GET_VN = (
},
]]
},
+ staff => {
+ fetch => [[ 'id', 'SELECT vs.id, vs.aid, vs.role, vs.note, sa.id AS sid, sa.name, sa.original
+ FROM vn_staff vs JOIN staff_alias sa ON sa.aid = vs.aid WHERE vs.id IN(%s)',
+ sub { my($r, $n) = @_;
+ for my $i (@$r) {
+ $i->{staff} = [ grep $i->{id} == $_->{id}, @$n ];
+ }
+ for (@$n) {
+ $_->{aid} *= 1;
+ $_->{sid} *= 1;
+ $_->{original} ||= undef;
+ $_->{note} ||= undef;
+ delete $_->{id};
+ }
+ }
+ ]],
+ },
},
filters => {
id => [
@@ -835,6 +852,63 @@ my %GET_CHARACTER = (
);
+my %GET_STAFF = (
+ sql => 'SELECT %s FROM staff s JOIN staff_alias sa ON sa.aid = s.aid WHERE NOT s.hidden AND (%s) %s',
+ select => 's.id',
+ proc => sub {
+ $_[0]{id} *= 1
+ },
+ sortdef => 'id',
+ sorts => {
+ id => 's.id %s'
+ },
+ flags => {
+ basic => {
+ select => 'sa.name, sa.original, s.gender, s.lang AS language',
+ proc => sub {
+ $_[0]{original} ||= undef;
+ $_[0]{gender} = undef if $_[0]{gender} eq 'unknown';
+ },
+ },
+ details => {
+ select => 's."desc" AS description, s.l_wp, s.l_site, s.l_twitter, s.l_anidb',
+ proc => sub {
+ $_[0]{description} ||= undef;
+ $_[0]{links} = {
+ wikipedia => delete($_[0]{l_wp}) ||undef,
+ homepage => delete($_[0]{l_site}) ||undef,
+ twitter => delete($_[0]{l_twitter})||undef,
+ anidb => (delete($_[0]{l_anidb})||0)*1||undef
+ };
+ },
+ },
+ aliases => {
+ select => 's.aid',
+ proc => sub {
+ $_[0]{main_alias} = delete($_[0]{aid})*1;
+ },
+ fetch => [[ 'id', 'SELECT id, aid, name, original FROM staff_alias WHERE id IN(%s)',
+ sub { my($n, $r) = @_;
+ for my $i (@$n) {
+ $i->{aliases} = [ map [ $_->{aid}*1, $_->{name}, $_->{original}||undef ], grep $i->{id} == $_->{id}, @$r ];
+ }
+ },
+ ]],
+ },
+ },
+ filters => {
+ id => [
+ [ 'int' => 's.id :op: :value:', {qw|= = != <> > > < < <= <= >= >=|}, range => [1,1e6] ],
+ [ inta => 's.id :op:(:value:)', {'=' => 'IN', '!=' => 'NOT IN'}, range => [1,1e6], join => ',' ],
+ ],
+ aid => [
+ [ 'int' => 's.id IN(SELECT sa.id FROM staff_alias sa WHERE sa.aid = :value:)', {'=',1}, range => [1,1e6] ],
+ [ inta => 's.id IN(SELECT sa.id FROM staff_alias sa WHERE sa.aid IN(:value:))', {'=',1}, range => [1,1e6], join => ',' ],
+ ],
+ },
+);
+
+
# All user ID filters consider uid=0 to be the logged in user. Needs a special processing function to handle that.
sub subst_user_id { my($id, $c) = @_; !$id && !$c->{uid} ? \'Not logged in.' : $id || $c->{uid} }
@@ -919,6 +993,7 @@ my %GET = (
release => \%GET_RELEASE,
producer => \%GET_PRODUCER,
character => \%GET_CHARACTER,
+ staff => \%GET_STAFF,
user => \%GET_USER,
votelist => \%GET_VOTELIST,
vnlist => \%GET_VNLIST,