diff options
author | Yorhel <git@yorhel.nl> | 2018-10-02 12:54:41 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2018-10-02 12:56:38 +0200 |
commit | 6bd0b0cd1f3892253d881f71533940f0cf07c13d (patch) | |
tree | 852ffd40f3aaa4aea6c04245e71a45ef73a7e372 /lib/VNDB/Util | |
parent | 815f9b1496c75026c9e3ea57bac2f5d5348085ba (diff) |
DB: Convert resolution into an enum
Been wanting to do this for a long time - using an integer index into an
array that changes once in a while is way too fragile. Doubly so when
said indices are also used in filters and URLs that can't be updated
every time a new resolution is added.
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r-- | lib/VNDB/Util/Misc.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm index 660818a2..ee7e8875 100644 --- a/lib/VNDB/Util/Misc.pm +++ b/lib/VNDB/Util/Misc.pm @@ -40,8 +40,9 @@ sub filFetchDB { my $filters = fil_parse $overwrite // $pref, @{$filfields{$type}}; # compatibility - $self->authPref($prefname => fil_serialize $filters) - if $type eq 'vn' && _fil_vn_compat($self, $filters) && !defined $overwrite; + my $compat = ($type eq 'vn' && _fil_vn_compat($self, $filters)) + || ($type eq 'release' && _fil_release_compat($self, $filters)); + $self->authPref($prefname => fil_serialize $filters) if $compat && !defined $overwrite; # write the definite filter string in $overwrite $_[2] = fil_serialize({map +( @@ -100,6 +101,17 @@ sub _fil_vn_compat { } +sub _fil_release_compat { + my($self, $fil) = @_; + if($fil->{resolution} && $fil->{resolution} =~ /^[0-9]+$/) { + $fil->{resolution} = (keys %{$self->{resolutions}})[$fil->{resolution}] || 'unknown'; + return 1; + } + return 0; +} + + + sub bbSubstLinks { my ($self, $msg) = @_; |