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

36 tidal integration #38

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

36 tidal integration #38

wants to merge 17 commits into from

Conversation

sjdonado
Copy link
Owner

@sjdonado sjdonado commented Nov 24, 2024

WIP: replace bun test with vitest + add missing fixtures and cases

closes #36

@sjdonado sjdonado marked this pull request as draft November 24, 2024 17:39
Comment on lines +16 to +17
ADMIN_NAME: 'Admin'
ADMIN_API_KEY: 'E7gWaEu8JOIGKR/jTmOOgbmBCup2h48jmux2YvIzpxk='

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dummy or prod keys?

Comment on lines +10 to +28
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;

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

Comment on lines 104 to 114
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, mani!

Comment on lines +76 to +83
const metadataFetchers = {
[Parser.Spotify]: getSpotifyMetadata,
[Parser.YouTube]: getYouTubeMetadata,
[Parser.AppleMusic]: getAppleMusicMetadata,
[Parser.Deezer]: getDeezerMetadata,
[Parser.SoundCloud]: getSoundCloudMetadata,
[Parser.Tidal]: getTidalMetadata,
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chef kiss

Comment on lines -21 to +34
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'
);

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tidal integration
2 participants