[GH-ISSUE #1006] Issue with Tags in Playlist Descriptions Causing HTML Rendering Problems #600

Closed
opened 2026-02-28 00:00:01 +03:00 by kerem · 3 comments
Owner

Originally created by @Kudzmat on GitHub (Jul 28, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1006

Describe the bug

The .category_playlists() method in Spotipy is returning playlists with descriptions that contain HTML tags. While some descriptions render correctly, others have embedded HTML tags, causing issues when displaying playlists on HTML documents.

Here are two examples to illustrate the problem:

  1. Good Descriptions in the R&B playlists:

The pulse of R&B music today. Cover: Mahalia
This is R&B in Canada, elevate your aura with Roy Woods.
100% British - 100% R&B. Cover: Kali Claire
A collection R&B and Afropop cuts from West Africa’s finest artists. Cover: Chike
Enjoy trendy & chill Korean R&B music. (Cover: UNE(으네))

  1. Bad Descriptions in Christian & Gospel:

The best mix of today's Christian music, all genres, worldwide. Cover: Forrest Frank and Chandler Moore of Maverick City Music
Las canciones de fe que más se escuchan en Latinoamérica. Foto: Marcos Witt
Experience the powerful messages and sounds of the current hits and classic Gospel songs. Cover: The hosts of this year's Stellar Awards , Tasha Cobbs Leonard and Jonathan McReynolds
No need to wait! Experience today's best Worship music right here, right now, on Spotify. Cover: Passion
Get lifted by the waves of faith-infused music. Cover: Stellar Award winning artist Pastor Mike Jr..

code snippet
Python code snippet:

play_list_info = playlists['playlists']['items']

    for info in play_list_info:
        # Setting our information to variables
        playlist_name = info['name']
        description = info['description']
        link = info['external_urls']['spotify']
        image = info['images'][0]['url']

        # adding our information using the playlist name as a key and a list of the other info as values
        recommendations[playlist_name] = [description, link, image]

<section>
      <div class="container">
          <br>
        <div class="row">
          {% for name,info in recommendations.items %}
          <div class="col-sm-2">
              <h3>{{ name }}</h3>
              <a href="{{ info.1 }}">
                  <img src="{{ info.2 }}" class="img-fluid">
              </a>
            <figcaption><strong>{{ info.0 }}</strong></figcaption>
          </div>
          {% endfor %}
        </div>
    </div>
    </section>

In the "bad" description, the presence of the tag results in the rendering of an anchor link that may lead to unintended behavior and disrupt the appearance of the playlist on HTML documents.

Expected Behavior
The .category_playlists() method should return playlist descriptions without any HTML tags or, alternatively, provide a sanitized version of the description suitable for direct rendering in HTML documents.

Steps to Reproduce
Call the .category_playlists() method with appropriate parameters to retrieve playlists.
Iterate through the playlist objects and access the description field.
Observe that some descriptions contain HTML tags while others do not.

Environment:

  • OS: Mac
  • Python version: Python 3.9.13
  • spotipy version: 2.22.1
  • IDE: PyCharm

In conclusion

The presence of HTML tags in playlist descriptions makes it challenging to directly render playlists on web applications or HTML-based platforms. Please let me know if any further information is needed to resolve this bug.

Originally created by @Kudzmat on GitHub (Jul 28, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1006 **Describe the bug** The .category_playlists() method in Spotipy is returning playlists with descriptions that contain HTML tags. While some descriptions render correctly, others have embedded HTML tags, causing issues when displaying playlists on HTML documents. Here are two examples to illustrate the problem: 1. Good Descriptions in the R&B playlists: The pulse of R&B music today. Cover: Mahalia This is R&B in Canada, elevate your aura with Roy Woods. 100% British - 100% R&B. Cover: Kali Claire A collection R&B and Afropop cuts from West Africa’s finest artists. Cover: Chike Enjoy trendy & chill Korean R&B music. (Cover: UNE(으네)) 2. Bad Descriptions in Christian & Gospel: The best mix of today's Christian music, all genres, worldwide. Cover: <a href="https://open.spotify.com/artist/1scVfBymTr3CeZ4imMj1QJ?si=09f41d2c8af64483">Forrest Frank</a> and <a href="https://open.spotify.com/artist/6y7frW1RUq3XBBXbYowVpk?si=eb81ee17c6974f97">Chandler Moore</a> of <a href="https://open.spotify.com/artist/58r1rB5t3VF5X6yXGPequV?si=e7329a2c54c54fea">Maverick City Music</a> Las canciones de fe que más se escuchan en Latinoamérica. Foto: <a href="https://open.spotify.com/artist/4x7kxyIgzgtrHYDQ8SCzo2?si=dcb330485ac242f6">Marcos Witt</a> Experience the powerful messages and sounds of the current hits and classic Gospel songs. Cover: The hosts of this year's <a href="https://www.thestellarawards.com/index.html">Stellar Awards</a> , <a href="https://open.spotify.com/artist/5YxebzzreNswbtYC1td4cx?si=ee37f97c830a42e7">Tasha Cobbs Leonard</a> and <a href="https://open.spotify.com/artist/5ItTHwcEtFh6DEOBheMub9?si=719b1ebceaa64e4a">Jonathan McReynolds</a> No need to wait! Experience today's best Worship music right here, right now, on Spotify. Cover: <a href="https://open.spotify.com/artist/6piIAIurGAryW5h1rqQC16?si=2da142e40d034893">Passion<a> Get lifted by the waves of faith-infused music. Cover: <a href="https://www.thestellarawards.com/index.html">Stellar Award</a> winning artist <a href="https://open.spotify.com/artist/1aNtFg4D7HdF8jOppyKpUS?si=ba40ca816da6450e">Pastor Mike Jr.</a>. **code snippet** Python code snippet: ```python play_list_info = playlists['playlists']['items'] for info in play_list_info: # Setting our information to variables playlist_name = info['name'] description = info['description'] link = info['external_urls']['spotify'] image = info['images'][0]['url'] # adding our information using the playlist name as a key and a list of the other info as values recommendations[playlist_name] = [description, link, image] ``` ```html <section> <div class="container"> <br> <div class="row"> {% for name,info in recommendations.items %} <div class="col-sm-2"> <h3>{{ name }}</h3> <a href="{{ info.1 }}"> <img src="{{ info.2 }}" class="img-fluid"> </a> <figcaption><strong>{{ info.0 }}</strong></figcaption> </div> {% endfor %} </div> </div> </section> ``` In the "bad" description, the presence of the <a> tag results in the rendering of an anchor link that may lead to unintended behavior and disrupt the appearance of the playlist on HTML documents. **Expected Behavior** The .category_playlists() method should return playlist descriptions without any HTML tags or, alternatively, provide a sanitized version of the description suitable for direct rendering in HTML documents. **Steps to Reproduce** Call the .category_playlists() method with appropriate parameters to retrieve playlists. Iterate through the playlist objects and access the description field. Observe that some descriptions contain HTML tags while others do not. **Environment:** - OS: Mac - Python version: Python 3.9.13 - spotipy version: 2.22.1 - IDE: PyCharm **In conclusion** The presence of HTML tags in playlist descriptions makes it challenging to directly render playlists on web applications or HTML-based platforms. Please let me know if any further information is needed to resolve this bug.
kerem 2026-02-28 00:00:01 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (Aug 8, 2023):

The spotipy library just returns the content received from Spotify. The only modification is to convert the text to JSON. If you have trouble with the HTML tags and just want to remove them, you might want to take a look at this neat solution: https://stackoverflow.com/a/12982689

<!-- gh-comment-id:1669430263 --> @dieser-niko commented on GitHub (Aug 8, 2023): The spotipy library just returns the content received from Spotify. The only modification is to convert the text to JSON. If you have trouble with the HTML tags and just want to remove them, you might want to take a look at this neat solution: https://stackoverflow.com/a/12982689
Author
Owner

@Kudzmat commented on GitHub (Aug 10, 2023):

Thanks, man, this looks like a great solution to the problem!

<!-- gh-comment-id:1672885405 --> @Kudzmat commented on GitHub (Aug 10, 2023): Thanks, man, this looks like a great solution to the problem!
Author
Owner

@dieser-niko commented on GitHub (May 23, 2024):

Closing as it appears that your issue has been resolved.

<!-- gh-comment-id:2126646473 --> @dieser-niko commented on GitHub (May 23, 2024): Closing as it appears that your issue has been resolved.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#600
No description provided.