-
Notifications
You must be signed in to change notification settings - Fork 210
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
Implement clear errors or sanitize requests with >
or <
in the playlist title.
#642
Comments
Funny enough, this doesn't work on the Web either. Neither do they have a good error message for it. Not sure it's the task of this project to figure something out that YouTube's not doing |
I'd prefer to raise in that case. Not sure if this is just a temporary issue. PR welcome |
Cool, it would help to return the response object within your Otherwise, would this be an appropriate change to make? def create_playlist():
#...
try:
response = self._send_request(endpoint, body)
except YTMusicServerError as error:
if ("400" in error): # Checks if it's 400 [Bad Request]
"""
Implemented to counter an undocumented error with no proper response
Refers to issue https://github.com/sigma67/ytmusicapi/issues/642
"""
invalid_characters = self._check_has_invalid_playlist_title_characters( title )
if (invalid_characters): raise YTMusicServerError(error + f"Invalid characters in playlist title: {", ".join(invalid_characters)}")
raise error
def _check_has_invalid_playlist_title_characters(self, title: str) -> list:
"""
Checks if the playlist title has characters that youtube does not like.
:param title: Playlist title
:return: Boolean if playlist title has valid characters or not
"""
invalid_characters = [">", "<"]
found_invalid_characters = [char for char in title if char in invalid_characters]
return found_invalid_characters |
Silly me, I closed the issue. |
Is your feature request related to a problem? Please describe.
This is related to a problem.
Using
>
and<
in playlists will cause it to error with400 Bad Request
.Originally found in linsomniac/spotify_to_ytmusic#93
I could not find other characters affected by this. The error it returns does not make perfect sense either.
To reproduce:
This is what is returned:
Describe the solution you'd like
Might help to sanitize the request or return a more concise error. It's difficult to determine that it's related to this.
The text was updated successfully, but these errors were encountered: