summaryrefslogtreecommitdiff
path: root/lib/Multi/API.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-02-20 14:55:33 +0100
committerYorhel <git@yorhel.nl>2021-02-20 14:55:35 +0100
commit506f8470c57feeefb27869a29d4193d9fd33ad31 (patch)
tree363d1c7c29e9715a1103a75c93143b248d280a1a /lib/Multi/API.pm
parent1e140e05f578bedf840d35b29a3e544e27f02abe (diff)
cleanup: Merge VNDBUtil into VNDB::Func
Something I was planning to do in the v2rw rewrite. VNDB::Func used to be a module intended for use inside TUWF (i.e. the web backend) while VNDBUtil was for utility functions that could also be used outside of that. Now that the web backend has moved to the VNWeb::* namespace, the VNDB::Func module has taken over the role of VNDBUtil. Also updated the API code to make use of the 'imgurl' function, which is a nice additional cleanup.
Diffstat (limited to 'lib/Multi/API.pm')
-rw-r--r--lib/Multi/API.pm14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 287a7a53..c41e9873 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -15,7 +15,7 @@ use POE::Filter::VNDBAPI 'encode_filters';
use Encode 'encode_utf8', 'decode_utf8';
use Crypt::URandom 'urandom';
use Crypt::ScryptKDF 'scrypt_raw';;
-use VNDBUtil 'normalize_query', 'norm_ip', 'resolution';
+use VNDB::Func 'imgurl', 'normalize_query', 'norm_ip', 'resolution';
use VNDB::Types;
use VNDB::Config;
use JSON::XS;
@@ -433,7 +433,7 @@ my %GET_VN = (
},
},
details => {
- select => 'vndbid_num(v.image) as image, i.c_sexual_avg, i.c_violence_avg, i.c_votecount, v.alias AS aliases, v.length, v.desc AS description, v.l_wp, v.l_encubed, v.l_renai, l_wikidata',
+ select => 'v.image, i.c_sexual_avg, i.c_violence_avg, i.c_votecount, v.alias AS aliases, v.length, v.desc AS description, v.l_wp, v.l_encubed, v.l_renai, l_wikidata',
proc => sub {
$_[0]{aliases} ||= undef;
$_[0]{length} *= 1;
@@ -445,7 +445,7 @@ my %GET_VN = (
renai => delete($_[0]{l_renai}) ||undef,
wikidata => formatwd(delete $_[0]{l_wikidata}),
};
- $_[0]{image} = $_[0]{image} ? sprintf '%s/cv/%02d/%d.jpg', config->{url_static}, $_[0]{image}%100, $_[0]{image} : undef;
+ $_[0]{image} = $_[0]{image} ? imgurl $_[0]{image} : undef;
$_[0]{image_nsfw} = !$_[0]{image} ? FALSE : !$_[0]{c_votecount} || $_[0]{c_sexual_avg} > 0.4 || $_[0]{c_violence_avg} > 0.4 ? TRUE : FALSE;
$_[0]{image_flagging} = image_flagging $_[0]{image}, $_[0];
},
@@ -507,14 +507,14 @@ my %GET_VN = (
]],
},
screens => {
- fetch => [[ 'id', 'SELECT vs.id AS vid, vndbid_num(vs.scr) AS image, vs.rid, s.width, s.height, s.c_sexual_avg, s.c_violence_avg, s.c_votecount
+ fetch => [[ 'id', 'SELECT vs.id AS vid, vs.scr, vs.rid, s.width, s.height, s.c_sexual_avg, s.c_violence_avg, s.c_votecount
FROM vn_screenshots vs JOIN images s ON s.id = vs.scr WHERE vs.id IN(%s)',
sub { my($r, $n) = @_;
for my $i (@$r) {
$i->{screens} = [ grep $i->{id} == $_->{vid}, @$n ];
}
for (@$n) {
- $_->{image} = sprintf '%s/sf/%02d/%d.jpg', config->{url_static}, $_->{image}%100, $_->{image};
+ $_->{image} = imgurl delete $_->{scr};
$_->{rid} *= 1;
$_->{nsfw} = !$_->{c_votecount} || $_->{c_sexual_avg} > 0.4 || $_->{c_violence_avg} > 0.4 ? TRUE : FALSE;
$_->{width} *= 1;
@@ -837,11 +837,11 @@ my %GET_CHARACTER = (
},
},
details => {
- select => 'c.alias AS aliases, vndbid_num(c.image) as image, i.c_sexual_avg, i.c_violence_avg, i.c_votecount, c."desc" AS description, c.age',
+ select => 'c.alias AS aliases, c.image, i.c_sexual_avg, i.c_violence_avg, i.c_votecount, c."desc" AS description, c.age',
proc => sub {
$_[0]{aliases} ||= undef;
$_[0]{description} ||= undef;
- $_[0]{image} = $_[0]{image} ? sprintf '%s/ch/%02d/%d.jpg', config->{url_static}, $_[0]{image}%100, $_[0]{image} : undef;
+ $_[0]{image} = $_[0]{image} ? imgurl $_[0]{image} : undef;
$_[0]{image_flagging} = image_flagging $_[0]{image}, $_[0];
$_[0]{age}*=1 if defined $_[0]{age};
},