Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit 87cb22c

Browse files
fix(soundcloud): Content without artwork no longer breaks
Closes #216
1 parent e452914 commit 87cb22c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

integrations/soundcloud/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ module.exports = function(params) {
167167
};
168168

169169
function user_to_account(user) {
170-
var user_artwork_url = _.result(user, 'avatar_url', '');
170+
var user_artwork_url = _.result(user, 'avatar_url') || '';
171171
return !_.isEmpty(user) && _.pick({ api: 'soundcloud', type: 'account', id: _.result(user, 'permalink'), name: _.result(user, 'username'), image: !_.isEmpty(user_artwork_url) && !user_artwork_url.match(/default_avatar_large/) && { small: user_artwork_url, medium: user_artwork_url.replace('-large', '-t300x300'), large: user_artwork_url.replace('-large', '-t500x500') } }, _.negate(_.isEmpty));
172172
}
173173

174174
function post_to_content(post) {
175-
var artwork_url = _.result(post, 'artwork_url', '');
175+
var artwork_url = _.result(post, 'artwork_url') || '';
176176
return !_.isEmpty(post) && _.pick({ api: 'soundcloud', type: 'content', id: _.result(post, 'permalink'), as: (_.result(post, 'kind') === 'playlist') && 'playlist', name: _.result(post, 'title'), date: Date.parse(_.result(post, 'created_at')), stats: _.result(post, 'kind') === 'playlist' ? { content: Number(_.result(post, 'track_count')) } : { likes: Number(_.result(post, 'favoritings_count')), views: Number(_.result(post, 'playback_count')), comments: Number(_.result(post, 'comment_count')) }, image: !artwork_url.match(/default_avatar_large/) && { small: artwork_url, medium: artwork_url.replace('-large', '-t300x300'), large: artwork_url.replace('-large', '-t500x500') }, account: user_to_account(post.user) }, _.somePredicate(_.isNumber, _.negate(_.isEmpty)));
177177
}

0 commit comments

Comments
 (0)