Cannot read property 'children' of undefined
Kikobeats opened this issue · 3 comments
Looks like the spotify HTML markup changed a bit and trying to get the info from an episode URL throw an error:
URL
https://open.spotify.com/episode/64TORH3xleuD1wcnFsrH1E
Error
_ TypeError: Cannot read property 'children' of undefined
at /Users/kikobeats/Projects/microlink/metascraper/packages/metascraper-spotify/node_modules/spotify-url-info/index.js:40:15
This is the markup associated with the URL
https://gist.github.com/Kikobeats/a1650fbf6b9665443fba87745f5cc691
the current implementation is trying to get the data from a JSON
https://github.com/karlsander/spotify-url-info/blob/master/index.js#L40
but the current HTML markup returned by Spotify:
<script data-testid="preloaded-state">
window.__PRELOADED_STATE__ = {
data: {
audio_preview_url: "https://p.scdn.co/mp3-preview/e869a74e9a1835c8c4cd6b478f36fabd02cfd88c",
id: "64TORH3xleuD1wcnFsrH1E",
name: "Hasty Treat - Modules in Node",
uri: "spotify:episode:64TORH3xleuD1wcnFsrH1E",
description:
"In this Hasty Treat, Scott and Wes talk about modules in Node — what are they, how they’re different from browser modules, and more! Sentry - Sponsor If you want to know what’s happening with your errors, track them with Sentry. Sentry is open-source error tracking that helps developers monitor and fix crashes in real time. Cut your time on error resolution from five hours to five minutes. It works with any language and integrates with dozens of other services. Syntax listeners can get two months for free by visiting Sentry.io and using the coupon code “tastytreat”. Show Notes 3:06 - How were they done before? 5:11 - How do they work? 7:07 - How to use Modules in Node 9:57 - Gotchas 13:18 - What should you use? Links Node Node Modules Babel ESM Meteor Keystone MJS Tweet us your tasty treats! Scott’s Instagram LevelUpTutorials Instagram Wes’ Instagram Wes’ Twitter Wes’ Facebook Scott’s Twitter Make sure to include @SyntaxFM in your tweets ",
language: "en",
type: "episode",
duration_ms: 1096856,
explicit: false,
so we need to figure out a way for getting that object inside Node.js 🤔
Hey, the library can handle this new type of embed page now. Version 2.1.0 is available on npm.
@Kikobeats I think the new embed page doesn't include dominantColor anymore. You added it to the tests so I assume you are relying on it.
I removed it from the tests because IMHO we cannot guarantee any data provided by getData, only that it is the real data object from spotify. If you need dominantColor and you can find it for different media + the new embed html, we can add it to the getPreview
and then test for it.