Improve approved museum URL normalizing

This commit is contained in:
Alex Cabal 2024-01-12 20:22:26 -06:00
parent 16df5b29fe
commit 620826f3c8

View file

@ -22,10 +22,13 @@ class Museum extends PropertiesBase{
throw new Exceptions\InvalidUrlException($url); throw new Exceptions\InvalidUrlException($url);
} }
if(stripos($parsedUrl['host'], 'rijksmuseum.nl') !== false){ // We can't match on TLD because extracting the TLD for double-barrel TLDs, like .gov.uk, requires a whitelist.
if(preg_match('/\brijksmuseum\.nl$/ius', $parsedUrl['host'])){
// Rijksmuseum has several URL variants we want to resolve // Rijksmuseum has several URL variants we want to resolve
// https://www.rijksmuseum.nl/en/search/objects?q=hals&p=6&ps=12&st=Objects&ii=2#/SK-A-1246,59 // https://www.rijksmuseum.nl/en/search/objects?q=hals&p=6&ps=12&st=Objects&ii=2#/SK-A-1246,59
// https://www.rijksmuseum.nl/nl/collectie/SK-A-1246 // https://www.rijksmuseum.nl/nl/collectie/SK-A-1246
// https://www.rijksmuseum.nl/en/rijksstudio/artists/jean-baptiste-vanmour/objects#/SK-A-1998,8
$exampleUrl = 'https://www.rijksmuseum.nl/en/collection/SK-A-1246'; $exampleUrl = 'https://www.rijksmuseum.nl/en/collection/SK-A-1246';
@ -33,8 +36,23 @@ class Museum extends PropertiesBase{
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
if(preg_match('|^/en/search/objects$|ius', $parsedUrl['path']) && isset($parsedUrl['fragment'])){ if( (
$outputUrl = 'https://' . $parsedUrl['host'] . '/en/collection/' . preg_replace('/,+$/ius', '', $parsedUrl['fragment']); preg_match('|^/en/search/objects$|ius', $parsedUrl['path'])
||
preg_match('|^/en/rijksstudio/[^/]+/[^/]+/objects$|ius', $parsedUrl['path'])
)
&&
isset($parsedUrl['fragment'])
){
$id = preg_replace('/,.+$/ius', '', $parsedUrl['fragment']);
$id = preg_replace('|^/|ius', '', $id);
$outputUrl = 'https://' . $parsedUrl['host'] . '/en/collection/' . $id;
}
if(preg_match('|^en/rijksstudio/[^/]+/[^/]+/objects$|ius', $parsedUrl['path']) && isset($parsedUrl['fragment'])){
$id = preg_replace('/,.+$/ius', '', $parsedUrl['fragment']);
$id = preg_replace('|^/|ius', '', $id);
$outputUrl = 'https://' . $parsedUrl['host'] . '/en/collection/' . $id;
} }
if(preg_match('|^/nl/collectie/[^/]+$|ius', $parsedUrl['path'])){ if(preg_match('|^/nl/collectie/[^/]+$|ius', $parsedUrl['path'])){
@ -51,24 +69,23 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bmetmuseum\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'metmuseum.org') !== false){
$exampleUrl = 'https://www.metmuseum.org/art/collection/search/13180'; $exampleUrl = 'https://www.metmuseum.org/art/collection/search/13180';
if($parsedUrl['host'] != 'www.metmuseum.org'){ $host = preg_replace('|^metmuseum.org|ius', 'www.metmuseum.org', $parsedUrl['host']);
if($host != 'www.metmuseum.org'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
if(!preg_match('|^/art/collection/search/\d+$|ius', $parsedUrl['path'])){ if(!preg_match('|^/art/collection/search/[\d]+$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path']; $outputUrl = 'https://' . $host . $parsedUrl['path'];
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bnationalmuseum\.se$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'nationalmuseum.se') !== false){
$exampleUrl = 'https://collection.nationalmuseum.se/eMP/eMuseumPlus?objectId=18217'; $exampleUrl = 'https://collection.nationalmuseum.se/eMP/eMuseumPlus?objectId=18217';
if($parsedUrl['host'] != 'collection.nationalmuseum.se'){ if($parsedUrl['host'] != 'collection.nationalmuseum.se'){
@ -93,8 +110,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bartsmia\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'artsmia.org') !== false){
$exampleUrl = 'https://collections.artsmia.org/art/3729/castle-and-watermill-by-a-river-jacob-van-ruisdael'; $exampleUrl = 'https://collections.artsmia.org/art/3729/castle-and-watermill-by-a-river-jacob-van-ruisdael';
if($parsedUrl['host'] != 'collections.artsmia.org'){ if($parsedUrl['host'] != 'collections.artsmia.org'){
@ -109,8 +125,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bthewalters\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'thewalters.org') !== false){
$exampleUrl = 'https://art.thewalters.org/detail/4695/boston-street-scene-boston-common/'; $exampleUrl = 'https://art.thewalters.org/detail/4695/boston-street-scene-boston-common/';
if($parsedUrl['host'] != 'art.thewalters.org'){ if($parsedUrl['host'] != 'art.thewalters.org'){
@ -125,8 +140,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bartic\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'artic.edu') !== false){
$exampleUrl = 'https://www.artic.edu/artworks/133864/the-defense-of-paris'; $exampleUrl = 'https://www.artic.edu/artworks/133864/the-defense-of-paris';
if($parsedUrl['host'] != 'www.artic.edu'){ if($parsedUrl['host'] != 'www.artic.edu'){
@ -141,8 +155,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bclevelandart\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'clevelandart.org') !== false){
$exampleUrl = 'https://www.clevelandart.org/art/1969.54'; $exampleUrl = 'https://www.clevelandart.org/art/1969.54';
if($parsedUrl['host'] != 'www.clevelandart.org'){ if($parsedUrl['host'] != 'www.clevelandart.org'){
@ -157,13 +170,13 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bparis\.fr$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'paris.fr') !== false){
// Variant: https://www.parismuseescollections.paris.fr/en/musee-carnavalet/oeuvres/portrait-del-singer-simon-chenard-1758-1832-wearing-the-clothes-of-a-sans // Variant: https://www.parismuseescollections.paris.fr/en/musee-carnavalet/oeuvres/portrait-del-singer-simon-chenard-1758-1832-wearing-the-clothes-of-a-sans
// May also be missing www.
$exampleUrl = 'https://www.parismuseescollections.paris.fr/en/node/226154'; $exampleUrl = 'https://www.parismuseescollections.paris.fr/en/node/226154';
if($parsedUrl['host'] != 'www.parismuseescollections.paris.fr'){ if(!preg_match('|^(www\.)?parismuseescollections\.paris\.fr$|ius', $parsedUrl['host'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
@ -171,34 +184,27 @@ class Museum extends PropertiesBase{
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path']; $outputUrl = 'https://' . preg_replace('|^(www\.)?parismuseescollections\.paris\.fr$|ius', 'www.parismuseescollections.paris.fr', $parsedUrl['host']) . $parsedUrl['path'];
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bwww\.si\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'www.si.edu') !== false){
// URLs can look like <https://www.si.edu/object/cave-scene:saam_XX98H> in which the text before : is for SEO and can be cut // URLs can look like <https://www.si.edu/object/cave-scene:saam_XX98H> in which the text before : is for SEO and can be cut
$exampleUrl = 'https://www.si.edu/object/saam_1983.95.90'; $exampleUrl = 'https://www.si.edu/object/saam_1983.95.90';
if(!preg_match('|/object/[^/]+?:[^/:]+$|ius', $parsedUrl['path'])){ if(!preg_match('|^/object/[^/]+?(:[^/:]+)?$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$path = preg_replace('^|/object/[^/]+:([^/:]+)$|ius', '/object/\1', $parsedUrl['path']); $path = preg_replace('|^/object/[^/]+:([^/:]+)$|ius', '/object/\1', $parsedUrl['path']);
$outputUrl = 'https://' . $parsedUrl['host'] . $path; $outputUrl = 'https://' . $parsedUrl['host'] . $path;
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bamericanart\.si\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'americanart.si.edu') !== false){
$exampleUrl = 'https://americanart.si.edu/artwork/study-apotheosis-washington-rotunda-united-states-capitol-building-84517'; $exampleUrl = 'https://americanart.si.edu/artwork/study-apotheosis-washington-rotunda-united-states-capitol-building-84517';
$path = $parsedUrl['path'];
if(!preg_match('|/object/[^/]+?:[^/:]+$|ius', $path)){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
if(!preg_match('|^/artwork/[^/]+$|ius', $parsedUrl['path'])){ if(!preg_match('|^/artwork/[^/]+$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
@ -207,8 +213,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bcollections\.si\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'collections.si.edu') !== false){
// These URLs can actually be normalized to a www.si.edu URL by pulling out the object ID // These URLs can actually be normalized to a www.si.edu URL by pulling out the object ID
$exampleUrl = 'https://collections.si.edu/search/detail/edanmdm:saam_1981.146.1'; $exampleUrl = 'https://collections.si.edu/search/detail/edanmdm:saam_1981.146.1';
@ -223,8 +228,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bnpg\.si\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'npg.si.edu') !== false){
// These URLs can actually be normalized to a www.si.edu URL by pulling out the object ID // These URLs can actually be normalized to a www.si.edu URL by pulling out the object ID
$exampleUrl = 'https://npg.si.edu/object/npg_NPG.2008.5'; $exampleUrl = 'https://npg.si.edu/object/npg_NPG.2008.5';
@ -237,8 +241,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bbirminghammuseums\.org\.uk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'birminghammuseums.org.uk') !== false){
$exampleUrl = 'https://dams.birminghammuseums.org.uk/asset-bank/action/viewAsset?id=6726'; $exampleUrl = 'https://dams.birminghammuseums.org.uk/asset-bank/action/viewAsset?id=6726';
if($parsedUrl['host'] != 'dams.birminghammuseums.org.uk'){ if($parsedUrl['host'] != 'dams.birminghammuseums.org.uk'){
@ -259,56 +262,60 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bmnk\.pl$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'mnk.pl') !== false){ $exampleUrl = 'https://zbiory.mnk.pl/en/catalog/333584';
$exampleUrl = 'https://zbiory.mnk.pl/en/search-result/catalog/333584';
if($parsedUrl['host'] != 'zbiory.mnk.pl'){ if($parsedUrl['host'] != 'zbiory.mnk.pl'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
if(!preg_match('|^/en/search-result/catalog/[^/]+$|ius', $parsedUrl['path'])){ // Somtimes the path may have '/search-result/advance' or '/search-result' in it, cut that here
$path = preg_replace('~^/en(/search-result/advance|/search-result)?~ius', '/en', $parsedUrl['path']);
if(!preg_match('|^/en/catalog/[^/]+$|ius', $path)){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path']; $outputUrl = 'https://' . $parsedUrl['host'] . $path;
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bsmk\.dk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'smk.dk') !== false){
$exampleUrl = 'https://open.smk.dk/artwork/image/KMS1884'; $exampleUrl = 'https://open.smk.dk/artwork/image/KMS1884';
if($parsedUrl['host'] != 'open.smk.dk'){ if($parsedUrl['host'] != 'open.smk.dk'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
if(!preg_match('|^/artwork/image/[^/]+$|ius', $parsedUrl['path'])){ // Somtimes the path may have 'en' in it, cut that here
$path = preg_replace('|^/en/|ius', '/', $parsedUrl['path']);
if(!preg_match('|^/artwork/image/[^/]+$|ius', $path)){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path']; $outputUrl = 'https://' . $parsedUrl['host'] . $path;
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bkansallisgalleria\.fi$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'kansallisgalleria.fi') !== false){
$exampleUrl = 'https://www.kansallisgalleria.fi/en/object/429609'; $exampleUrl = 'https://www.kansallisgalleria.fi/en/object/429609';
if($parsedUrl['host'] != 'www.kansallisgalleria.fi'){ if($parsedUrl['host'] != 'www.kansallisgalleria.fi'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
if(!preg_match('|^/en/object/[^/]+$|ius', $parsedUrl['path'])){ $path = preg_replace('|^/fi/|ius', '/en/', $parsedUrl['path']);
if(!preg_match('|^/en/object/[^/]+$|ius', $path)){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl); throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
} }
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path']; $outputUrl = 'https://' . $parsedUrl['host'] . $path;
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bnga\.gov$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'nga.gov') !== false){
$exampleUrl = 'https://www.nga.gov/collection/art-object-page.46522.html'; $exampleUrl = 'https://www.nga.gov/collection/art-object-page.46522.html';
if($parsedUrl['host'] != 'www.nga.gov'){ if($parsedUrl['host'] != 'www.nga.gov'){
@ -323,8 +330,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bnivaagaard\.dk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'nivaagaard.dk') !== false){
$exampleUrl = 'https://www.nivaagaard.dk/en/vare/lundstroem-vilhelm/'; $exampleUrl = 'https://www.nivaagaard.dk/en/vare/lundstroem-vilhelm/';
if($parsedUrl['host'] != 'www.nivaagaard.dk'){ if($parsedUrl['host'] != 'www.nivaagaard.dk'){
@ -339,8 +345,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\brisdmuseum\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'risdmuseum.org') !== false){
$exampleUrl = 'https://risdmuseum.org/art-design/collection/portrait-christiana-carteaux-bannister-2016381'; $exampleUrl = 'https://risdmuseum.org/art-design/collection/portrait-christiana-carteaux-bannister-2016381';
if($parsedUrl['host'] != 'risdmuseum.org'){ if($parsedUrl['host'] != 'risdmuseum.org'){
@ -355,8 +360,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\baberdeencity\.gov\.uk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'aberdeencity.gov.uk') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://emuseum.aberdeencity.gov.uk/objects/3215/james-cromar-watt-lld'; $exampleUrl = 'https://emuseum.aberdeencity.gov.uk/objects/3215/james-cromar-watt-lld';
@ -374,8 +378,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bbrightonmuseums\.org\.uk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'brightonmuseums.org.uk') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://collections.brightonmuseums.org.uk/records/63caa90083d50a00184b8e90'; $exampleUrl = 'https://collections.brightonmuseums.org.uk/records/63caa90083d50a00184b8e90';
@ -391,8 +394,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bgrpmcollections\.org$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'grpmcollections.org') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://www.grpmcollections.org/Detail/objects/130684'; $exampleUrl = 'https://www.grpmcollections.org/Detail/objects/130684';
@ -408,8 +410,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bthorvaldsensmuseum\.dk$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'thorvaldsensmuseum.dk') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://kataloget.thorvaldsensmuseum.dk/en/B122'; $exampleUrl = 'https://kataloget.thorvaldsensmuseum.dk/en/B122';
@ -425,8 +426,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bmuseabrugge\.be$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'museabrugge.be') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://collectie.museabrugge.be/en/collection/work/id/2013_GRO0013_I'; $exampleUrl = 'https://collectie.museabrugge.be/en/collection/work/id/2013_GRO0013_I';
@ -442,8 +442,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bbritishart\.yale\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'britishart.yale.edu') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://collections.britishart.yale.edu/catalog/tms:1010'; $exampleUrl = 'https://collections.britishart.yale.edu/catalog/tms:1010';
@ -459,8 +458,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bkunsthalle-karlsruhe\.de$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'kunsthalle-karlsruhe.de') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://www.kunsthalle-karlsruhe.de/kunstwerke/Ferdinand-Keller/K%C3%BCstenlandschaft-bei-Rio-de-Janeiro/C066F030484D7D09148891B0E70524B8/'; $exampleUrl = 'https://www.kunsthalle-karlsruhe.de/kunstwerke/Ferdinand-Keller/K%C3%BCstenlandschaft-bei-Rio-de-Janeiro/C066F030484D7D09148891B0E70524B8/';
@ -476,8 +474,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bgetty\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'getty.edu') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://www.getty.edu/art/collection/object/103RG0'; $exampleUrl = 'https://www.getty.edu/art/collection/object/103RG0';
@ -493,8 +490,7 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bartgallery\.yale\.edu$/ius', $parsedUrl['host'])){
if(stripos($parsedUrl['host'], 'artgallery.yale.edu') !== false){
// All we need is the int object ID, the last slug is SEO // All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://artgallery.yale.edu/collections/objects/44306'; $exampleUrl = 'https://artgallery.yale.edu/collections/objects/44306';
@ -510,6 +506,52 @@ class Museum extends PropertiesBase{
return $outputUrl; return $outputUrl;
} }
elseif(preg_match('/\bwebumenia\.sk$/ius', $parsedUrl['host'])){
// All we need is the int object ID, the last slug is SEO
$exampleUrl = 'https://www.webumenia.sk/en/dielo/SVK:SNG.O_85';
if($parsedUrl['host'] != 'www.webumenia.sk'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
if(!preg_match('|^/en/dielo/[^/]+?$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path'];
return $outputUrl;
}
elseif(preg_match('/\bdigitaltmuseum\.no$/ius', $parsedUrl['host'])){
$exampleUrl = 'https://digitaltmuseum.no/021048495118/fra-saxegardsgaten-maleri';
if($parsedUrl['host'] != 'digitaltmuseum.no'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
if(!preg_match('|^/[^/]+?/[^/]+?$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path'];
return $outputUrl;
}
elseif(preg_match('/\bart\.pl$/ius', $parsedUrl['host'])){
$exampleUrl = 'https://cyfrowe.mnw.art.pl/en/catalog/445066';
if($parsedUrl['host'] != 'cyfrowe.mnw.art.pl'){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
if(!preg_match('|^/en/catalog/[^/]+?$|ius', $parsedUrl['path'])){
throw new Exceptions\InvalidMuseumUrlException($url, $exampleUrl);
}
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path'];
return $outputUrl;
}
return $outputUrl; return $outputUrl;
} }