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

Invalid \escape on channels with special characters in name #8

Closed
christianboyle opened this issue May 20, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@christianboyle
Copy link

Things seem to work as expected in testing on this channel: https://www.youtube.com/@CodexCommunity/videos

But trying this channel results in an error: https://www.youtube.com/@PerfectGuyLife/videos

json.decoder.JSONDecodeError: Invalid \escape: line 1 column 212 (char 211)

My guess is that the 2nd channel uses emoji in some of their titles, like 🔴 Fishtank is LIVE 🐟 50% OFF Weekend

Any thoughts on this?

@NotJoeMartinez
Copy link
Owner

NotJoeMartinez commented May 21, 2023

Problem on is on line 210 in the get_channel_name function.

script = soup.find('script', type='application/ld+json')
data = json.loads(script.string)

for some reason json.loads() is breaking when it tries to read the channel name from the string:

"name": "Sam \x26 Nick\x27s Perfect Clips"

A quick fix would be to remove the escapes but that still leaves the rest of the special character in the channel name
and will probably make it harder to display the real channel name in the future.

script = soup.find('script', type='application/ld+json')
script = script.string.replace('\\', '')
data = json.loads(script)

We can also escape the escapes but I'm not sure how that will effect other things

script = script.string.replace('\\', '\\\\')

@NotJoeMartinez NotJoeMartinez changed the title Invalid \escape Invalid \escape on channels with special characters in name May 21, 2023
@NotJoeMartinez NotJoeMartinez added the bug Something isn't working label May 21, 2023
@NotJoeMartinez
Copy link
Owner

Fixed with 29e0f11

@christianboyle
Copy link
Author

christianboyle commented May 21, 2023

@NotJoeMartinez Nice, thanks for the quick fix!

Things are working now. The only thing I noticed (which you alluded to) is that list doesn't show the special characters, but curiously search does show them.

2023-05-21_07-40-44AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants