Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isrc links #77

Merged
merged 12 commits into from
Dec 15, 2024
29 changes: 23 additions & 6 deletions server/components/ISRC.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
import { ProviderIcon } from './ProviderIcon.tsx';
import { SpriteIcon } from './SpriteIcon.tsx';
import { join } from 'std/url/join.ts';

const isrcPattern = /^([A-Z]{2})-?([A-Z0-9]{3})-?(\d{2})-?(\d{5})$/i;

export function ISRC({ code }: { code: string }) {
const codeMatch = code.trim().match(isrcPattern);

return codeMatch
? (
<code class='isrc'>
<span class='country'>{codeMatch[1]}</span>
<span class='registrant'>{codeMatch[2]}</span>
<span class='year'>{codeMatch[3]}</span>
<span class='designation'>{codeMatch[4]}</span>
</code>
<>
<span class='entity-links'>
<a
title='ifpi ISRC search'
href={'https://isrcsearch.ifpi.org/?tab="code"&itemsPerPage=100&showReleases=true&isrcCode=' + code}
>
<SpriteIcon size={18} name='brand-ifpi' stroke={1.5} />
</a>
<a href={join('https://musicbrainz.org/isrc/', code).href}>
<ProviderIcon providerName='MusicBrainz' size={18} stroke={1.5} />
</a>
</span>
<code class='isrc'>
<span class='country'>{codeMatch[1]}</span>
<span class='registrant'>{codeMatch[2]}</span>
<span class='year'>{codeMatch[3]}</span>
<span class='designation'>{codeMatch[4]}</span>
</code>
</>
)
: <code class='invalid-isrc'>{code}</code>;
}
28 changes: 28 additions & 0 deletions server/icons/BrandIfpi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default function IconBrandIfpi({
size = 24,
color = 'currentColor',
stroke = 2.,
...props
}) {
return (
<svg
xmlns='http://www.w3.org/2000/svg'
class='icon icon-tabler icon-tabler-brand-ifpi'
width={size}
height={size}
viewBox='0 0 24 24'
stroke-width={stroke}
stroke={color}
fill='none'
{...props}
>
<g transform='translate(-343.3 -311.3)' stroke-linecap='butt' stroke-linejoin='butt'>
kellnerd marked this conversation as resolved.
Show resolved Hide resolved
<path d='m345.8 315.8v14.25' />
<path d='m364.7 315.8v14.25' />
<path d='m354.5 316.9h-4.875v13.12' />
<path d='m349.3 323h4.5' />
<path d='m356.8 330v-13.12h3l1.125 1.125v4.5l-1.125 1.125h-3' />
</g>
</svg>
);
}
74 changes: 74 additions & 0 deletions server/icons/ifpi.svg
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 server/routes/icon-sprite.svg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import IconBrandBeatport from '@/server/icons/BrandBeatport.tsx';
import IconBrandIfpi from '@/server/icons/BrandIfpi.tsx';
import IconBrandMetaBrainz from '@/server/icons/BrandMetaBrainz.tsx';
import IconBrandApple from 'tabler-icons/brand-apple.tsx';
import IconBrandBandcamp from 'tabler-icons/brand-bandcamp.tsx';
Expand Down Expand Up @@ -48,6 +49,7 @@ const icons: Icon[] = [
IconBrandBeatport,
IconBrandDeezer,
IconBrandGit,
IconBrandIfpi,
IconBrandMetaBrainz,
IconBrandSpotify,
IconBrandTidal,
Expand Down
Loading