Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Getting duration from embed episode with ID

Solved!

Getting duration from embed episode with ID

I'm using spotify podcast to be hosted by a website. I need to get the podcast duration from embed link. Something like this "https://open.spotify.com/embed/episode/26CbyH3PccV573LrPKmmcb"

What API exactely should call? note that I'm using node.js

Thanks in advacne.

Reply

Accepted Solutions
Marked as solution

Hey @Ximazend,

I'm happy to share with you that I managed to run the script successfully. For a further documentation of "how to", then this is my snippet code.

https://codepen.io/Ahmed_B_Hameed/pen/YzdmgPK?editors=1112

Thank you once more.
Ahmed.

View solution in original post

10 Replies

If you have the Client Credentials flow set up, you can use the Get Episode endpoint to get the duration in milliseconds using the episode id.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Thank you for your kind respond.

It seems that the Spotify using ID different from the embed:embed:ID . I tried the following:

If I use this link

"https://open.spotify.com/embed/episode/26CbyH3PccV573LrPKmmcb"

and it runs in the browser but as soon I use the ID like this:

Content-Type: application/json
Authorization: Bearer XXX

I get error:

{ "error": { "status": 404, "message": "Non existing id: 'spotify:episode:26CbyH3PccV573LrPKmmcb'" } }

What do I miss here ?

 


Because you are using Client Credentials, you'll need to specify the market.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Hmm, did not know about that!

May you support me please providing me with some links to read more about what to do in specific ?

Thank you so much for your kind support.

Okay I see the missing parameter of market. I will check how to grab this variable. Thank you for your kind support.

I wrote a code to embed "market=XX" for all markets coming from the API https://api.spotify.com/v1/markets
All failed unfortunately? Any alternative idea?

XX must be replaced with one country code such as US. Spotify isn't available in XX.

Maybe I understood your last message.

What have you already made?

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Hey @Ximazend,

Here are the things I did in steps:

- Fetch a token from client ID and secret ID.

- Fetch markets from https://api.spotify.com/v1/markets

That returns me the following response:

{ "markets": [ "AD", "AE", "AG", "AL", "AM", "AO", "AR", "AT", "AU", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BN", "BO", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CD", "CG", "CH", "CI", "CL", "CM", "CO", "CR", "CV", "CW", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "ET", "FI", "FJ", "FM", "FR", "GA", "GB", "GD", "GE", "GH", "GM", "GN", "GQ", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MH", "MK", "ML", "MN", "MO", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NP", "NR", "NZ", "OM", "PA", "PE", "PG", "PH", "PK", "PL", "PS", "PT", "PW", "PY", "QA", "RO", "RS", "RW", "SA", "SB", "SC", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TD", "TG", "TH", "TJ", "TL", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VC", "VE", "VN", "VU", "WS", "XK", "ZA", "ZM", "ZW" ] }

- I wrote a script to loop through those values and attach them like this GET https://api.spotify.com/v1/episodes/{id}?
market=${market} including auth Bearer <TOKEN>

And they failed all of them 😞

If you need to see some code, let me know so I can post some links for the it.
Thank you so much and looking forward for your support.

Yes, some code will be helpful. Just specifying one market should be sufficient normally.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.
Marked as solution

Hey @Ximazend,

I'm happy to share with you that I managed to run the script successfully. For a further documentation of "how to", then this is my snippet code.

https://codepen.io/Ahmed_B_Hameed/pen/YzdmgPK?editors=1112

Thank you once more.
Ahmed.

Suggested posts