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

fix: changes in Spotify embeds #96

Merged
merged 6 commits into from
Sep 2, 2022

Conversation

Eithoo
Copy link
Contributor

@Eithoo Eithoo commented Aug 31, 2022

image
(Closes #94)

@fmsidoe
Copy link

fmsidoe commented Sep 1, 2022

Good job Eithoo, only I do not get the album name of the track when using getDetails.

@Eithoo
Copy link
Contributor Author

Eithoo commented Sep 1, 2022

I don't know what's going on. I ran the test again a few minutes ago and it showed 3 tests failed
image
Now I did it again without changing anything in the code and it's working normally:
image

@Eithoo
Copy link
Contributor Author

Eithoo commented Sep 1, 2022

Good job Eithoo, only I do not get the album name of the track when using getDetails.

@fmsidoe I don't think new embeds return information about the track's album
They now look like that:
image and there's also no album name

JSON data grabbed from embed's code (Song: Hotel Lobby - Pop Smoke)
{
    "data": {
        "entity": {
            "type": "track",
            "name": "Hotel Lobby",
            "uri": "spotify:track:5xKXcU8tpSYz7C7wrMMYec",
            "id": "5xKXcU8tpSYz7C7wrMMYec",
            "title": "Hotel Lobby",
            "artists": [
                {
                    "name": "Pop Smoke",
                    "uri": "spotify:artist:0eDvMgVFoNV3TpwtrVCoTj"
                }
            ],
            "coverArt": {
                "extractedColors": {
                    "colorDark": {
                        "hex": "#535353"
                    },
                    "colorLight": {
                        "hex": "#7F7F7F"
                    }
                },
                "sources": [
                    {
                        "url": "https://i.scdn.co/image/ab67616d0000b27346e1307c35579c3483ea7b03",
                        "width": 640,
                        "height": 640
                    },
                    {
                        "url": "https://i.scdn.co/image/ab67616d00001e0246e1307c35579c3483ea7b03",
                        "width": 300,
                        "height": 300
                    },
                    {
                        "url": "https://i.scdn.co/image/ab67616d0000485146e1307c35579c3483ea7b03",
                        "width": 64,
                        "height": 64
                    }
                ]
            },
            "releaseDate": {
                "isoString": "2020-07-20T00:00:00Z"
            },
            "duration": 151011,
            "maxDuration": 151011,
            "isPlayable": true,
            "isExplicit": true,
            "audioPreview": {
                "url": "https://p.scdn.co/mp3-preview/9eefa150fc29b0dca744c567e5fdcada154fd553",
                "fileId": "9eefa150fc29b0dca744c567e5fdcada154fd553",
                "externallyHosted": false,
                "format": "MP3_96"
            },
            "audio": null,
            "hasVideo": false,
            "relatedEntityUri": "spotify:artist:0eDvMgVFoNV3TpwtrVCoTj"
        },
        "embeded_entity_uri": "spotify:track:5xKXcU8tpSYz7C7wrMMYec",
        "saved": false,
        "passthrough": "NONE",
        "backgroundColor": "#535353"
    },
    "settings": {
        "rtl": false,
        "session": {
            "clientId": "1866a",
            "accessToken": "BQAf1_B7K3iBQx3PsrwvfCABGjbTFXr64LXUqsjegtD7ipq3INFR-oF1DiiivGhaIbO4G9Q_39nBCuMa1-g_GTXyZQJ6ykfxHXo0X0kvdAawIKBMlsA",
            "accessTokenExpirationTimestampMs": 1662044954810,
            "isAnonymous": true
        },
        "clientId": "dad378e085084decb8b91b987321866a",
        "entityContext": "track",
        "features": {
            "enableShows": true,
            "isTracingEnabled": false,
            "upgradeButton": "control",
            "useEnhancedChromeOSPWACallout": true,
            "mwp": false,
            "isMWPErrorCodeEnabled": false,
            "isMWPQualarooEnabled": false,
            "isMwpRadioEntity": true,
            "isMWPAndPlaybackCapable": false,
            "preauthRecaptcha": false,
            "isEqualizerABEnabled": false,
            "isRichAlbumPagesEnabledViaServerOverride": false,
            "isPodcastEnabled": true,
            "isPodcastSeoEnabled": false,
            "enableI18nLocales": false,
            "enableLanguageSelection": false,
            "isAudiobooksOnMWPEnabled": false,
            "isNewNPVEnabled": false,
            "isSearchChipsEnabled": false,
            "isPathfinderBrowseCardsEnabled": false,
            "upgradeOverApp": false,
            "upgradeOverSignupBanner": false,
            "upgradeOverSignupBannerTwo": false,
            "musicClips": "0"
        },
        "isMobile": false,
        "isTablet": false,
        "isIOS": false,
        "isSafari": false,
        "isVideoEmbed": false
    },
    "machineState": {
        "initialized": false,
        "showOverflowMenu": false,
        "showUpsell": false,
        "playbackMode": "unknown"
    },
    "playback": null
}

@fmsidoe
Copy link

fmsidoe commented Sep 1, 2022

The embeds never showed album information, but spotify-url-info did showed album information when you use getTracks function. I was able to retrieve the album.name and album.release_date. Now it does not return any album fields

also removed hydrateScript since there is not any test using it
@Kikobeats
Copy link
Member

Thanks for this great PR, some slightly changes:

  • use .find over .filter to exit from the loop as soon as possible.
  • dropped the hydration script since there aren't a test using it (probably Spotify is not using this way anymore)
  • call normalizeData even that is not strictly necessary, it will be help us to detect new data types added by Spotify in the future.

How it looks to you? 🙂

@Eithoo
Copy link
Contributor Author

Eithoo commented Sep 1, 2022

I wanted to edit things while keeping original code style (not refactoring), that's why filter was used.
About hydration - I thought it was for some legacy style of embeds, so I left it there.

Nevertheless, your changes are great, LGTM 🙂

@Daviddavidov98

This comment was marked as off-topic.

src/index.js Outdated Show resolved Hide resolved
@Kikobeats Kikobeats force-pushed the fix-for-new-embed branch 4 times, most recently from ca308b7 to c1b2b2c Compare September 2, 2022 09:05
@Kikobeats Kikobeats merged commit 1cbee73 into microlinkhq:master Sep 2, 2022
@fmsidoe
Copy link

fmsidoe commented Sep 2, 2022

too bad i cannot retrieve the album name from a track like it did before this issue. This fix does not help me unfortunately. spotify-url-info was very easy as I did not have to create code myself to retrieve info from the Spotify API. Now I need to search for another solution or create my own.
Thanks anyways guys!

@Kikobeats
Copy link
Member

@fmsidoe the problem with the album name is it isn't available in the web version:

CleanShot 2022-09-02 at 11 56 24@2x

You can just show it if you use the Spotify app.

If you find a way, please share with us 🙏

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.

Doesn't work anymore - Spotify changed their embeds.
4 participants