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

UnicodeEncodeError when --extract-audio with title having Chinese #332

Closed
ads901119 opened this issue Apr 13, 2012 · 4 comments
Closed

UnicodeEncodeError when --extract-audio with title having Chinese #332

ads901119 opened this issue Apr 13, 2012 · 4 comments

Comments

@ads901119
Copy link

@ads901119 ads901119 commented Apr 13, 2012

platform: Win7 x64
youtube-dl --version: 2012.02.27
python --version: 2.7.2

C:\Users\Alan\test>youtube-dl.py -l --extract-audio --audio-format mp3 http://www.youtube.com/watch?v=kgLf9VOe5V0
[youtube] Setting language
[youtube] kgLf9VOe5V0: Downloading video webpage
[youtube] kgLf9VOe5V0: Downloading video info webpage
[youtube] kgLf9VOe5V0: Extracting video information
[download] Destination: 你走了-李聖傑-kgLf9VOe5V0.mp4
[download] 100.0% of 8.25M at 69.98k/s ETA 00:00
Traceback (most recent call last):
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 46
45, in
main()
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 46
36, in main
_real_main()
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 46
20, in _real_main
retcode = fd.download(all_urls)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 86
9, in download
ie.extract(url)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 11
35, in extract
return self._real_extract(url)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 14
63, in _real_extract
'player_url': player_url,
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 84
8, in process_info
self.post_process(filename, info_dict)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 88
4, in post_process
info = pp.run(info)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 41
10, in run
filecodec = self.get_audio_codec(path)
File "C:\Users\Alan\Dropbox\Alan\PyCharmWorkspace\test\youtube-dl.py", line 40
73, in get_audio_codec
handle = subprocess.Popen(cmd, stderr=file(os.path.devnull, 'w'), stdout=sub
process.PIPE)
File "C:\Python27\lib\subprocess.py", line 679, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 893, in _execute_child
startupinfo)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 25-27: ord
inal not in range(128)

@FiloSottile
Copy link
Collaborator

@FiloSottile FiloSottile commented Apr 14, 2012

Windows only issue. We really need smart standard functions to handle encoding (in and) out.

@grawity
Copy link
Contributor

@grawity grawity commented Apr 14, 2012

It would be better to force subprocess to use Unicode for command lines in Windows (or everywhere). The following might work, but I currently don't have any system to test it on:

cmd = [u'ffmpeg', u'-y', u'-i', path, u'-vn'] ...

(Does subprocess.list2cmdline([u"foo", u"bar"]) return a str or unicode object on Windows with Python 2?)

@ads901119
Copy link
Author

@ads901119 ads901119 commented Apr 15, 2012

@grawity
This does not resolve the problem...
The list2cmdline returns an unicode object in Windows

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 2, 2016

Works fine with latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.