Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
feat: add support for Spotify show and episode type (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbo authored Nov 13, 2024
1 parent fbdda59 commit 379f88d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
56 changes: 56 additions & 0 deletions domains/grid/platform-parser/__tests__/spotifyParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,62 @@ describe('SPOTIFY Input Parser', () => {
width: '100%',
},
],
[
'Show URL',
GRID_WIDGET_TYPE.enum.SPOTIFY,
'https://open.spotify.com/show/34UHUOMlsMBf85aNOBhztV?si=5963aa1c2e8b4eef',
{
widgetType: 'IFRAME',
src: 'https://open.spotify.com/embed/show/34UHUOMlsMBf85aNOBhztV?si=5963aa1c2e8b4eef',
allow:
'clipboard-write; encrypted-media; fullscreen; picture-in-picture',
},
],
[
'Show Embed Code',
GRID_WIDGET_TYPE.enum.SPOTIFY,
'<iframe style="border-radius:12px" src="https://open.spotify.com/embed/show/34UHUOMlsMBf85aNOBhztV?utm_source=generator" width="100%" height="352" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>',
{
widgetType: 'IFRAME',
src: 'https://open.spotify.com/embed/show/34UHUOMlsMBf85aNOBhztV?utm_source=generator',
allow:
'autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture',
allowfullscreen: true,
frameBorder: 0,
height: '352',
loading: 'lazy',
style: 'border-radius:12px',
width: '100%',
},
],
[
'Episode URL',
GRID_WIDGET_TYPE.enum.SPOTIFY,
'https://open.spotify.com/episode/1D7C6aliI9UjZVstdH69TH?si=ca07d31decff4d29',
{
widgetType: 'IFRAME',
src: 'https://open.spotify.com/embed/episode/1D7C6aliI9UjZVstdH69TH?si=ca07d31decff4d29',
allow:
'clipboard-write; encrypted-media; fullscreen; picture-in-picture',
},
],
[
'Show Embed Code',
GRID_WIDGET_TYPE.enum.SPOTIFY,
'<iframe style="border-radius:12px" src="https://open.spotify.com/embed/episode/1D7C6aliI9UjZVstdH69TH?utm_source=generator" width="100%" height="352" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>',
{
widgetType: 'IFRAME',
src: 'https://open.spotify.com/embed/episode/1D7C6aliI9UjZVstdH69TH?utm_source=generator',
allow:
'autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture',
allowfullscreen: true,
frameBorder: 0,
height: '352',
loading: 'lazy',
style: 'border-radius:12px',
width: '100%',
},
],
])('correctly parses %s', async (_description, platform, input, expected) => {
const result = await parsePlatformInput(platform, input)
expect(result).toEqual(expected)
Expand Down
2 changes: 1 addition & 1 deletion domains/grid/platform-parser/spotifyParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const PLATFORM_PARSING_PARAMETERS_SPOTIFY: PlatformParsingParameters = {
regexWithCallbacks: [
{
regex: createIframeRegex(
'https?:\\/\\/open\\.spotify\\.com\\/(?:embed\\/)?(?<type>track|album|playlist|artist)\\/(?<id>[^?"]+)(?:\\?(?<params>[^"\'\\s]*))?'
'https?:\\/\\/open\\.spotify\\.com\\/(?:embed\\/)?(?<type>track|album|playlist|artist|show|episode)\\/(?<id>[^?"]+)(?:\\?(?<params>[^"\'\\s]*))?'
),
callback: async (matches: RegExpMatchArray[]) => {
return processIframeAttributes(matches, {
Expand Down

0 comments on commit 379f88d

Please sign in to comment.