|
@@ -333,7 +333,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
- console.log(4443311, err);
|
|
|
|
reject(err);
|
|
reject(err);
|
|
});
|
|
});
|
|
})
|
|
})
|
|
@@ -524,21 +523,15 @@ class _SpotifyModule extends CoreClass {
|
|
async GET_ALBUMS_FROM_IDS(payload) {
|
|
async GET_ALBUMS_FROM_IDS(payload) {
|
|
const { albumIds } = payload;
|
|
const { albumIds } = payload;
|
|
|
|
|
|
- console.log(albumIds);
|
|
|
|
-
|
|
|
|
const existingAlbums = (await SpotifyModule.spotifyAlbumModel.find({ albumId: albumIds })).map(
|
|
const existingAlbums = (await SpotifyModule.spotifyAlbumModel.find({ albumId: albumIds })).map(
|
|
album => album._doc
|
|
album => album._doc
|
|
);
|
|
);
|
|
const existingAlbumIds = existingAlbums.map(existingAlbum => existingAlbum.albumId);
|
|
const existingAlbumIds = existingAlbums.map(existingAlbum => existingAlbum.albumId);
|
|
|
|
|
|
- console.log(existingAlbums);
|
|
|
|
-
|
|
|
|
const missingAlbumIds = albumIds.filter(albumId => existingAlbumIds.indexOf(albumId) === -1);
|
|
const missingAlbumIds = albumIds.filter(albumId => existingAlbumIds.indexOf(albumId) === -1);
|
|
|
|
|
|
if (missingAlbumIds.length === 0) return existingAlbums;
|
|
if (missingAlbumIds.length === 0) return existingAlbums;
|
|
|
|
|
|
- console.log(missingAlbumIds);
|
|
|
|
-
|
|
|
|
const jobsToRun = [];
|
|
const jobsToRun = [];
|
|
|
|
|
|
const chunkSize = 2;
|
|
const chunkSize = 2;
|
|
@@ -550,8 +543,6 @@ class _SpotifyModule extends CoreClass {
|
|
|
|
|
|
const jobResponses = await Promise.all(jobsToRun);
|
|
const jobResponses = await Promise.all(jobsToRun);
|
|
|
|
|
|
- console.log(jobResponses);
|
|
|
|
-
|
|
|
|
const newAlbums = jobResponses
|
|
const newAlbums = jobResponses
|
|
.map(jobResponse => jobResponse.response.data.albums)
|
|
.map(jobResponse => jobResponse.response.data.albums)
|
|
.flat()
|
|
.flat()
|
|
@@ -560,8 +551,6 @@ class _SpotifyModule extends CoreClass {
|
|
rawData: album
|
|
rawData: album
|
|
}));
|
|
}));
|
|
|
|
|
|
- console.log(newAlbums);
|
|
|
|
-
|
|
|
|
await SpotifyModule.runJob("CREATE_ALBUMS", { spotifyAlbums: newAlbums }, this);
|
|
await SpotifyModule.runJob("CREATE_ALBUMS", { spotifyAlbums: newAlbums }, this);
|
|
|
|
|
|
return existingAlbums.concat(newAlbums);
|
|
return existingAlbums.concat(newAlbums);
|
|
@@ -577,21 +566,15 @@ class _SpotifyModule extends CoreClass {
|
|
async GET_ARTISTS_FROM_IDS(payload) {
|
|
async GET_ARTISTS_FROM_IDS(payload) {
|
|
const { artistIds } = payload;
|
|
const { artistIds } = payload;
|
|
|
|
|
|
- console.log(artistIds);
|
|
|
|
-
|
|
|
|
const existingArtists = (await SpotifyModule.spotifyArtistModel.find({ artistId: artistIds })).map(
|
|
const existingArtists = (await SpotifyModule.spotifyArtistModel.find({ artistId: artistIds })).map(
|
|
artist => artist._doc
|
|
artist => artist._doc
|
|
);
|
|
);
|
|
const existingArtistIds = existingArtists.map(existingArtist => existingArtist.artistId);
|
|
const existingArtistIds = existingArtists.map(existingArtist => existingArtist.artistId);
|
|
|
|
|
|
- console.log(existingArtists);
|
|
|
|
-
|
|
|
|
const missingArtistIds = artistIds.filter(artistId => existingArtistIds.indexOf(artistId) === -1);
|
|
const missingArtistIds = artistIds.filter(artistId => existingArtistIds.indexOf(artistId) === -1);
|
|
|
|
|
|
if (missingArtistIds.length === 0) return existingArtists;
|
|
if (missingArtistIds.length === 0) return existingArtists;
|
|
|
|
|
|
- console.log(missingArtistIds);
|
|
|
|
-
|
|
|
|
const jobsToRun = [];
|
|
const jobsToRun = [];
|
|
|
|
|
|
const chunkSize = 50;
|
|
const chunkSize = 50;
|
|
@@ -603,8 +586,6 @@ class _SpotifyModule extends CoreClass {
|
|
|
|
|
|
const jobResponses = await Promise.all(jobsToRun);
|
|
const jobResponses = await Promise.all(jobsToRun);
|
|
|
|
|
|
- console.log(jobResponses);
|
|
|
|
-
|
|
|
|
const newArtists = jobResponses
|
|
const newArtists = jobResponses
|
|
.map(jobResponse => jobResponse.response.data.artists)
|
|
.map(jobResponse => jobResponse.response.data.artists)
|
|
.flat()
|
|
.flat()
|
|
@@ -613,8 +594,6 @@ class _SpotifyModule extends CoreClass {
|
|
rawData: artist
|
|
rawData: artist
|
|
}));
|
|
}));
|
|
|
|
|
|
- console.log(newArtists);
|
|
|
|
-
|
|
|
|
await SpotifyModule.runJob("CREATE_ARTISTS", { spotifyArtists: newArtists }, this);
|
|
await SpotifyModule.runJob("CREATE_ARTISTS", { spotifyArtists: newArtists }, this);
|
|
|
|
|
|
return existingArtists.concat(newArtists);
|
|
return existingArtists.concat(newArtists);
|
|
@@ -821,7 +800,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- console.log("ERROR", err);
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "working",
|
|
status: "working",
|
|
message: `Failed to get alternative artist source for ${artistId}`,
|
|
message: `Failed to get alternative artist source for ${artistId}`,
|
|
@@ -833,8 +811,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- console.log("Done!");
|
|
|
|
-
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "finished",
|
|
status: "finished",
|
|
message: `Finished getting alternative artist sources`
|
|
message: `Finished getting alternative artist sources`
|
|
@@ -876,25 +852,21 @@ class _SpotifyModule extends CoreClass {
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
|
|
- const soundcloudIds = Array.from(
|
|
|
|
- new Set(
|
|
|
|
- wikiDataResponse.results.bindings
|
|
|
|
- .filter(binding => !!binding.SoundCloud_ID)
|
|
|
|
- .map(binding => binding.SoundCloud_ID.value)
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- const musicbrainzArtistIds = Array.from(
|
|
|
|
- new Set(
|
|
|
|
- wikiDataResponse.results.bindings
|
|
|
|
- .filter(binding => !!binding.MusicBrainz_artist_ID)
|
|
|
|
- .map(binding => binding.MusicBrainz_artist_ID.value)
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
+ // const soundcloudIds = Array.from(
|
|
|
|
+ // new Set(
|
|
|
|
+ // wikiDataResponse.results.bindings
|
|
|
|
+ // .filter(binding => !!binding.SoundCloud_ID)
|
|
|
|
+ // .map(binding => binding.SoundCloud_ID.value)
|
|
|
|
+ // )
|
|
|
|
+ // );
|
|
|
|
|
|
- console.log("Youtube channel ids", youtubeChannelIds);
|
|
|
|
- console.log("Soundcloud ids", soundcloudIds);
|
|
|
|
- console.log("Musicbrainz artist ids", musicbrainzArtistIds);
|
|
|
|
|
|
+ // const musicbrainzArtistIds = Array.from(
|
|
|
|
+ // new Set(
|
|
|
|
+ // wikiDataResponse.results.bindings
|
|
|
|
+ // .filter(binding => !!binding.MusicBrainz_artist_ID)
|
|
|
|
+ // .map(binding => binding.MusicBrainz_artist_ID.value)
|
|
|
|
+ // )
|
|
|
|
+ // );
|
|
|
|
|
|
return youtubeChannelIds;
|
|
return youtubeChannelIds;
|
|
}
|
|
}
|
|
@@ -927,7 +899,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- console.log("ERROR", err);
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "working",
|
|
status: "working",
|
|
message: `Failed to get alternative album source for ${albumId}`,
|
|
message: `Failed to get alternative album source for ${albumId}`,
|
|
@@ -939,8 +910,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- console.log("Done!");
|
|
|
|
-
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "finished",
|
|
status: "finished",
|
|
message: `Finished getting alternative album sources`
|
|
message: `Finished getting alternative album sources`
|
|
@@ -996,10 +965,6 @@ class _SpotifyModule extends CoreClass {
|
|
async GET_ALTERNATIVE_MEDIA_SOURCES_FOR_TRACKS(payload) {
|
|
async GET_ALTERNATIVE_MEDIA_SOURCES_FOR_TRACKS(payload) {
|
|
const { mediaSources, collectAlternativeMediaSourcesOrigins } = payload;
|
|
const { mediaSources, collectAlternativeMediaSourcesOrigins } = payload;
|
|
|
|
|
|
- // console.log("KR*S94955", mediaSources);
|
|
|
|
-
|
|
|
|
- // this.pub
|
|
|
|
-
|
|
|
|
await async.eachLimit(mediaSources, 1, async mediaSource => {
|
|
await async.eachLimit(mediaSources, 1, async mediaSource => {
|
|
try {
|
|
try {
|
|
const result = await SpotifyModule.runJob(
|
|
const result = await SpotifyModule.runJob(
|
|
@@ -1017,7 +982,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- console.log("ERROR", err);
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "working",
|
|
status: "working",
|
|
message: `Failed to get alternative media for ${mediaSource}`,
|
|
message: `Failed to get alternative media for ${mediaSource}`,
|
|
@@ -1029,8 +993,6 @@ class _SpotifyModule extends CoreClass {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- console.log("Done!");
|
|
|
|
-
|
|
|
|
this.publishProgress({
|
|
this.publishProgress({
|
|
status: "finished",
|
|
status: "finished",
|
|
message: `Finished getting alternative media`
|
|
message: `Finished getting alternative media`
|
|
@@ -1332,7 +1294,7 @@ class _SpotifyModule extends CoreClass {
|
|
Promise.allSettled(promisesToRun2).then(resolve);
|
|
Promise.allSettled(promisesToRun2).then(resolve);
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
- console.log("KRISWORKERR", err);
|
|
|
|
|
|
+ console.log(err);
|
|
resolve();
|
|
resolve();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -1546,7 +1508,7 @@ class _SpotifyModule extends CoreClass {
|
|
Promise.allSettled(promisesToRun2).then(resolve);
|
|
Promise.allSettled(promisesToRun2).then(resolve);
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
- console.log("KRISWORKERR", err);
|
|
|
|
|
|
+ console.log(err);
|
|
resolve();
|
|
resolve();
|
|
});
|
|
});
|
|
});
|
|
});
|