Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions root/static/scripts/edit/URLCleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3961,25 +3961,54 @@ export const CLEANUPS: CleanupEntries = {
},
},
'livenation': {
hostname: 'livenation.*',
match: [/^(https?:\/\/)?(?:(?:concerts|www)\.)?livenation\.(?:[a-z]{2,3}?\.)?[a-z]{2,4}\//i],
hostname: ['livenation.*', 'livenationtero.co.th'],
match: [/^(https?:\/\/)?(?:(?:concerts|www)\.)?livenation\.(?:[a-z]{2,3}?\.)?[a-z]{2,4}\//i, /^(https?:\/\/)?(?:www\.)?livenationtero\.co\.th\//i],
restrict: [LINK_TYPES.ticketing],
clean(url) {
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenationtero\.co\.th\//, 'https://www.livenation.co.th/');
url = url.replace(/^(?:https?:\/\/)?concerts\.livenation\.com\/(?:[\w\d-]+\/)?event\/([0-9A-F]+).*$/, 'https://concerts.livenation.com/event/$1');
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.com\/(artist|event|venue)\/([\w-]+).*$/, 'https://www.livenation.com/$1/$2');
// International sites use somewhat different formats
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.((?:[a-z]{2,3}?\.)?[a-z]{2,4})\/(show|venue)\/([\w-]+).*$/, 'https://www.livenation.$1/$2/$3');
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.((?:[a-z]{2,3}?\.)?[a-z]{2,4})\/artist-[\w\d-]+-([0-9]+).*$/, 'https://www.livenation.$1/artist-$2');

url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.co\.th\/event\/[\w\d-]*-(edp\d+).*$/, 'https://www.livenation.co.th/event/$1');
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.co\.th\/[\w\d-]*-(adp\d+).*$/, 'https://www.livenation.co.th/artist/$1');
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?livenation\.co\.th\/[\w\d-]*-(vdp\d+).*$/, 'https://www.livenation.co.th/venue/$1');
return url;
},
validate(url, id) {
let m = /^https:\/\/(concerts|www)\.livenation\.(?:[a-z]{2,3}?\.)?[a-z]{2,4}\/(artist|event|show|venue)\/[\w-]+$/.exec(url);
if (!m) {
m = /^https:\/\/(www)\.livenation\.(?:[a-z]{2,3}?\.)?[a-z]{2,4}\/(artist)-[0-9]+$/.exec(url);
}
if (!m) {
m = /^https:\/\/(www)\.livenation\.co\.th\/(artist|event|venue)\/(adp|edp|vdp)\d+$/.exec(url);
}
if (m) {
const subdomain = m[1];
const prefix = m[2];
const idType = m[3];
if (idType) {
switch (id) {
case LINK_TYPES.ticketing.artist:
if (idType === 'adp') {
return {result: true};
}
return {result: false, target: ERROR_TARGETS.ENTITY};
case LINK_TYPES.ticketing.event:
if (idType === 'edp') {
return {result: true};
}
return {result: false, target: ERROR_TARGETS.ENTITY};
case LINK_TYPES.ticketing.place:
if (idType === 'vdp') {
return {result: true};
}
return {result: false, target: ERROR_TARGETS.ENTITY};
}
return {result: false, target: ERROR_TARGETS.RELATIONSHIP};
}
switch (id) {
case LINK_TYPES.ticketing.artist:
if (prefix === 'artist' && subdomain === 'www') {
Expand Down
21 changes: 21 additions & 0 deletions root/static/scripts/tests/Control/URLCleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3942,6 +3942,27 @@ limited_link_type_combinations: [
expected_clean_url: 'https://www.livenation.ee/venue/953330',
only_valid_entity_types: ['place'],
},
{
input_url: 'https://www.livenationtero.co.th/babymonster-tickets-adp1479014',
input_entity_type: 'artist',
expected_relationship_type: 'ticketing',
expected_clean_url: 'https://www.livenation.co.th/artist/adp1479014',
only_valid_entity_types: ['artist'],
},
{
input_url: 'https://www.livenationtero.co.th/impact-arena-muang-thong-thani-tickets-vdp1043802',
input_entity_type: 'place',
expected_relationship_type: 'ticketing',
expected_clean_url: 'https://www.livenation.co.th/venue/vdp1043802',
only_valid_entity_types: ['place'],
},
{
input_url: 'https://www.livenationtero.co.th/event/tv-girl-perform-their-hits-live-bangkok-tickets-edp1606725',
input_entity_type: 'event',
expected_relationship_type: 'ticketing',
expected_clean_url: 'https://www.livenation.co.th/event/edp1606725',
only_valid_entity_types: ['event'],
},
// Loudr
{
input_url: 'https://loudr.fm/artist/kyle-landry/Z77SM?test',
Expand Down