-
Notifications
You must be signed in to change notification settings - Fork 20
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
36 tidal integration #38
base: master
Are you sure you want to change the base?
Conversation
ADMIN_NAME: 'Admin' | ||
ADMIN_API_KEY: 'E7gWaEu8JOIGKR/jTmOOgbmBCup2h48jmux2YvIzpxk=' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dummy or prod keys?
export enum Adapter { | ||
Spotify = StreamingService.Spotify, | ||
YouTube = StreamingService.YouTube, | ||
AppleMusic = StreamingService.AppleMusic, | ||
Deezer = StreamingService.Deezer, | ||
SoundCloud = StreamingService.SoundCloud, | ||
Tidal = StreamingService.Tidal, | ||
} | ||
|
||
export enum Parser { | ||
Spotify = 'spotify', | ||
YouTube = 'youTube', | ||
AppleMusic = 'appleMusic', | ||
Deezer = 'deezer', | ||
SoundCloud = 'soundCloud', | ||
Spotify = StreamingService.Spotify, | ||
YouTube = StreamingService.YouTube, | ||
AppleMusic = StreamingService.AppleMusic, | ||
Deezer = StreamingService.Deezer, | ||
SoundCloud = StreamingService.SoundCloud, | ||
Tidal = StreamingService.Tidal, | ||
} | ||
|
||
export type StreamingServiceType = Adapter & Parser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Parser
and Adapter
are basically the same enum
, you could remove one of them to keep one source of truth
if (metadata.type === MetadataType.Song) { | ||
const [, artist] = metadata.description.match(/^([^·]+) · Song · \d+$/) ?? []; | ||
query = artist ? `${query} ${artist}` : query; | ||
} | ||
|
||
if (metadata.type === MetadataType.Album) { | ||
const [, artist] = metadata.description.match(/(.+?) · Album ·/) ?? []; | ||
|
||
query = artist ? `${query} ${artist}` : query; | ||
} | ||
|
||
if (metadata.type === MetadataType.Playlist) { | ||
query = `${query.replace(/This is /, '')} Playlist`; | ||
[, artist] = metadata.description.match(/^([^·]+)\s+·/) ?? []; | ||
} else if (metadata.type === MetadataType.Album) { | ||
[, artist] = metadata.description.match(/^([^·]+)\s+·/) ?? []; | ||
} else if (metadata.type === MetadataType.Podcast) { | ||
[, artist] = metadata.description.match(/from\s(.+?)\son\sSpotify\./) ?? []; | ||
} | ||
|
||
if (metadata.type === MetadataType.Podcast) { | ||
const [, artist] = metadata.description.match(/from (.+?) on Spotify\./) ?? []; | ||
|
||
query = artist ? `${query} ${artist}` : query; | ||
} | ||
const query = artist ? `${parsedTitle} ${artist.trim()}` : parsedTitle; | ||
|
||
return query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, mani!
const metadataFetchers = { | ||
[Parser.Spotify]: getSpotifyMetadata, | ||
[Parser.YouTube]: getYouTubeMetadata, | ||
[Parser.AppleMusic]: getAppleMusicMetadata, | ||
[Parser.Deezer]: getDeezerMetadata, | ||
[Parser.SoundCloud]: getSoundCloudMetadata, | ||
[Parser.Tidal]: getTidalMetadata, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chef kiss
await page.setUserAgent( | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0' | ||
); | ||
try { | ||
await page.setUserAgent( | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For scrapping, I would recommend to randomize User Agent to bypass some anti-scrapping rules (scrapper would fail less)
WIP: replace bun test with
vitest
+ add missing fixtures and casescloses #36