Skip to content

Commit

Permalink
fix #642: create_playlist: raise error when invalid characters are pa…
Browse files Browse the repository at this point in the history
…rt of playlist title
  • Loading branch information
sigma67 committed Oct 5, 2024
1 parent e433b22 commit c931954
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ytmusicapi/mixins/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ def create_playlist(
:return: ID of the YouTube playlist or full response if there was an error
"""
self._check_auth()

invalid_characters = ["<", ">"] # ytmusic will crash if these are part of the title
invalid_characters_found = [invalid for invalid in invalid_characters if invalid in title]
if invalid_characters_found:
msg = f"{title} contains invalid characters: {', '.join(invalid_characters_found)}"
raise YTMusicUserError(msg)

body = {
"title": title,
"description": html_to_txt(description), # YT does not allow HTML tags
Expand Down

0 comments on commit c931954

Please sign in to comment.