[GH-ISSUE #428] 'charmap' codec can't encode characters #321

Closed
opened 2026-02-27 23:00:10 +03:00 by kerem · 2 comments
Owner

Originally created by @periip on GitHub (Aug 25, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/428

Hello and thanks for using ytmusicapi! Please fill out the issue template below. Issues not following this template will be closed without comment. If you have a question only, please use GitHub discussions or gitter (linked in README).

**Describe the bug**
A clear and concise description of what the bug is.

I get the exception when calling get_playlist() on playlists with Japanese or Chinese song names:
'charmap' codec can't encode characters in position 2249-2253: character maps to <undefined>

**To Reproduce**
Steps to reproduce the behavior:
PlaylistIDs with Japanese in song titles don't work: PLPK7133-0ahmzknIfvNUMNJglX-O1rTd2
Only English song titles appear to work: PL3-sRm8xAzY8LhlTyJ2uf-EcQSm_vzSqw

If there is a workaround to this, please let me know as I am new to Python.

Thanks

Originally created by @periip on GitHub (Aug 25, 2023). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/428 # Hello and thanks for using ytmusicapi! Please fill out the issue template below. Issues not following this template will be closed without comment. If you have a question only, please use GitHub discussions or gitter (linked in README). ~~~~~~~~~~~~~ **Describe the bug** A clear and concise description of what the bug is. I get the exception when calling get_playlist() on playlists with Japanese or Chinese song names: 'charmap' codec can't encode characters in position 2249-2253: character maps to <undefined> **To Reproduce** Steps to reproduce the behavior: PlaylistIDs with Japanese in song titles don't work: PLPK7133-0ahmzknIfvNUMNJglX-O1rTd2 Only English song titles appear to work: PL3-sRm8xAzY8LhlTyJ2uf-EcQSm_vzSqw If there is a workaround to this, please let me know as I am new to Python. Thanks
kerem 2026-02-27 23:00:10 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@sigma67 commented on GitHub (Aug 25, 2023):

I cannot reproduce this, the playlist you posted works just fine. Must be some issue with your local setup.

What Python version are you running? What is your code?

<!-- gh-comment-id:1693851787 --> @sigma67 commented on GitHub (Aug 25, 2023): I cannot reproduce this, the playlist you posted works just fine. Must be some issue with your local setup. What Python version are you running? What is your code?
Author
Owner

@periip commented on GitHub (Aug 25, 2023):

Thanks for the quick reply!
I did some testing in a different folder and it indeed was local. It has something to do with the Node,js child process misreading it. It wasn't any issue with the actual API itself.

const spawn = require("child_process").spawn;

const child = spawn("python", ["test.py"]);

child.stdout.on("data", (data) => {
  console.log(`stdout: ${data}`);
});

child.stderr.on("data", (data) => {
  console.error(`stderr: ${data}`);
});

child.on("close", (code) => {
  console.log(`child process exited with code ${code}`);
});

child.stdin.write("PLPK7133-0ahmzknIfvNUMNJglX-O1rTd2"); 
child.stdin.end();
from ytmusicapi import YTMusic
import json
# import pafy

url = input()

yt = YTMusic()
try:
    songs = yt.get_playlist(url)
    print(songs)
except Exception as e:
    print("Error:", e)
<!-- gh-comment-id:1693916825 --> @periip commented on GitHub (Aug 25, 2023): Thanks for the quick reply! I did some testing in a different folder and it indeed was local. It has something to do with the Node,js child process misreading it. It wasn't any issue with the actual API itself. ```javascript const spawn = require("child_process").spawn; const child = spawn("python", ["test.py"]); child.stdout.on("data", (data) => { console.log(`stdout: ${data}`); }); child.stderr.on("data", (data) => { console.error(`stderr: ${data}`); }); child.on("close", (code) => { console.log(`child process exited with code ${code}`); }); child.stdin.write("PLPK7133-0ahmzknIfvNUMNJglX-O1rTd2"); child.stdin.end(); ``` ```python from ytmusicapi import YTMusic import json # import pafy url = input() yt = YTMusic() try: songs = yt.get_playlist(url) print(songs) except Exception as e: print("Error:", e) ```
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/ytmusicapi#321
No description provided.