Skip to content

Commit

Permalink
Merge pull request #3112 from reosarevok/MBS-13388
Browse files Browse the repository at this point in the history
MBS-13388: Handle vk.gy links
  • Loading branch information
reosarevok authored Dec 5, 2023
2 parents 6eb76d2 + 9d8ed8a commit f5731d5
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Data/URL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ my %URL_SPECIALIZATIONS = (
'VimeoOnDemand' => qr{^https?://(?:www\.)?vimeo\.com/ondemand}i,
'VK' => qr{^https?://(?:www\.)?vk\.com/}i,
'Vkdb' => qr{^https?://(?:www\.)?vkdb\.jp/}i,
'Vkgy' => qr{^https?://(?:www\.)?vk\.gy/}i,
'VNDB' => qr{^https?://(?:www\.)?vndb\.org/}i,
'VocaDB' => qr{^https?://(?:www\.)?vocadb\.net/}i,
'Weibo' => qr{^https?://(?:www\.)?weibo\.com/}i,
Expand Down
22 changes: 22 additions & 0 deletions lib/MusicBrainz/Server/Entity/URL/Vkgy.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package MusicBrainz::Server::Entity::URL::Vkgy;

use Moose;

extends 'MusicBrainz::Server::Entity::URL';
with 'MusicBrainz::Server::Entity::URL::Sidebar';

sub sidebar_name { 'vkgy' }

__PACKAGE__->meta->make_immutable;
no Moose;
1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2023 MetaBrainz Foundation
This file is part of MusicBrainz, the open internet music database,
and is licensed under the GPL version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl-2.0.txt
=cut
Binary file added root/static/images/external-favicons/vkgy-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions root/static/scripts/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const FAVICON_CLASSES = {
'mainlynorfolk.info': 'mainlynorfolk',
'melon.com': 'melon',
'metal-archives.com': 'metalarchives',
'metalmusicarchives.com': 'metalmusicarchives',
'mixcloud.com': 'mixcloud',
'mobygames.com': 'mobygames',
'mora.jp': 'mora',
Expand Down Expand Up @@ -248,6 +249,7 @@ export const FAVICON_CLASSES = {
'vimeo.com': 'vimeo',
'vk.com': 'vk',
'vkdb.jp': 'vkdb',
'vk.gy': 'vkgy',
'vndb.org': 'vndb',
'vocadb.net': 'vocadb',
'weibo.com': 'weibo',
Expand Down
47 changes: 47 additions & 0 deletions root/static/scripts/edit/URLCleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6074,6 +6074,53 @@ const CLEANUPS: CleanupEntries = {
return url.replace(/^(?:https?:\/\/)?(?:[^\/]+\.)?vk\.com/, 'https://vk.com');
},
},
'vkgy': {
match: [new RegExp('^(https?://)?(www\\.)?vk\\.gy', 'i')],
restrict: [LINK_TYPES.otherdatabases],
clean: function (url) {
return url.replace(/^(?:https?:\/\/)?(?:www\.)?vk\.gy\/(.*)$/, 'https://vk.gy/$1');
},
validate: function (url, id) {
const m = /^https:\/\/vk\.gy\/(\w+)\/((?:[\w-]+\/){0,2}[\w-]+)\/$/.exec(url);
if (m) {
const type = m[1];
const ending = m[2];
switch (id) {
case LINK_TYPES.otherdatabases.artist:
return {
result: (
(type === 'artists' && /^[\w-]+$/.test(ending)) ||
(type === 'musicians' && /^[\d]+\/[\w-]+$/.test(ending))
),
target: ERROR_TARGETS.ENTITY,
};
case LINK_TYPES.otherdatabases.event:
return {
result: type === 'lives' && /^[\d]+\/[\w-]+$/.test(ending),
target: ERROR_TARGETS.ENTITY,
};
case LINK_TYPES.otherdatabases.label:
return {
result: type === 'labels' && /^[\w-]+$/.test(ending),
target: ERROR_TARGETS.ENTITY,
};
case LINK_TYPES.otherdatabases.place:
return {
result: type === 'livehouses' && /^[\w-]+$/.test(ending),
target: ERROR_TARGETS.ENTITY,
};
case LINK_TYPES.otherdatabases.release:
return {
result: type === 'releases' &&
/^[\w-]+\/[\d]+\/[\w-]+$/.test(ending),
target: ERROR_TARGETS.ENTITY,
};
}
return {result: false, target: ERROR_TARGETS.ENTITY};
}
return {result: false, target: ERROR_TARGETS.URL};
},
},
'vndb': {
match: [new RegExp('^(https?://)?(www\\.)?vndb\\.org/', 'i')],
restrict: [LINK_TYPES.otherdatabases],
Expand Down
38 changes: 38 additions & 0 deletions root/static/scripts/tests/Control/URLCleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6070,6 +6070,44 @@ limited_link_type_combinations: [
expected_relationship_type: 'socialnetwork',
expected_clean_url: 'https://vk.com/tin_sontsya',
},
// vkgy
{
input_url: 'http://www.vk.gy/artists/skull/',
input_entity_type: 'artist',
expected_relationship_type: 'otherdatabases',
expected_clean_url: 'https://vk.gy/artists/skull/',
only_valid_entity_types: ['artist'],
},
{
input_url: 'https://vk.gy/musicians/1199/akira/',
input_entity_type: 'artist',
expected_relationship_type: 'otherdatabases',
only_valid_entity_types: ['artist'],
},
{
input_url: 'https://vk.gy/lives/121191/2023-12-10-shinsaibashi-big-twin-diner-panhead-groove/',
input_entity_type: 'event',
expected_relationship_type: 'otherdatabases',
only_valid_entity_types: ['event'],
},
{
input_url: 'https://vk.gy/labels/speed-disk/',
input_entity_type: 'label',
expected_relationship_type: 'otherdatabases',
only_valid_entity_types: ['label'],
},
{
input_url: 'https://vk.gy/livehouses/shinsaibashi-big-twin-diner-panhead-groove/',
input_entity_type: 'place',
expected_relationship_type: 'otherdatabases',
only_valid_entity_types: ['place'],
},
{
input_url: 'https://vk.gy/releases/skull/9559/hysteric-media-zone/',
input_entity_type: 'release',
expected_relationship_type: 'otherdatabases',
only_valid_entity_types: ['release'],
},
// VNDB
{
input_url: 'http://www.vndb.org/s5406/hist',
Expand Down
1 change: 1 addition & 0 deletions root/static/styles/favicons.less
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
.favicon("vimeoondemand", 32);
.favicon("vk", 32);
.favicon("vkdb");
.favicon("vkgy", 32);
.favicon("vndb");
.favicon("vocadb");
.favicon("weibo", 32);
Expand Down

0 comments on commit f5731d5

Please sign in to comment.