mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.12k stars 642 forks source link

UnicodeEncodeError with latin-1 encoding #843

Open JervisTetch opened 6 years ago

JervisTetch commented 6 years ago

When playing/enqueuing all search results by entering "all" an error occurs when hitting ">" or "<" or just by waiting for the next title to start.

Traceback:

--wL5jKuoFAE;

 webm 160k; 3 Mb; 00:00:00 [0%]   [>                                                                                                                               ]   

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/mps_youtube/main.py", line 65, in matchfunction
    func(*matches)
  File "/usr/lib64/python3.6/site-packages/mps_youtube/commands/play.py", line 119, in play_all
    play(options, "1-" + str(len(g.model)))
  File "/usr/lib64/python3.6/site-packages/mps_youtube/commands/play.py", line 100, in play
    play_range(songlist, shuffle, repeat, override)
  File "/usr/lib64/python3.6/site-packages/mps_youtube/player.py", line 50, in play_range
    returncode = _playsong(song, stream, video, override=override, softrepeat=softrepeat)
  File "/usr/lib64/python3.6/site-packages/mps_youtube/player.py", line 251, in _playsong
    history.add(song)
  File "/usr/lib64/python3.6/site-packages/mps_youtube/history.py", line 17, in add
    save()
  File "/usr/lib64/python3.6/site-packages/mps_youtube/history.py", line 39, in save
    hf.write('#EXTINF:%d,%s\n' % (song.length, song.title))
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 42: ordinal not in range(256)

Problem playing last item: 'latin-1' codec can't encode character '\u2013' in position 42: ordinal not in range(256)                                    [1/10>
> q
--

Environment:

mpsyt version      : 0.2.8
   notes           : released 17 February 2018
pafy version       : 0.5.4 (youtube-dl backend)
youtube-dl version : 2018.06.02
Python version     : 3.6.5 (default, Jun  2 2018, 17:38:48) 
[GCC 5.5.0]
Processor          : Intel(R) Core(TM) i3 CPU         530  @ 2.93GHz
Machine type       : x86_64
Architecture       : 64bit, ELF
Platform           : Linux-4.4.118-x86_64-Intel-R-_Core-TM-_i3_CPU_________530__@_2.93GHz-with-slackware-14.2
sys.stdout.enc     : ISO-8859-1
default enc        : utf-8
Config dir         : /home/jervis/.config/mps-youtube
env:TERM           : xterm
env:SHELL          : /bin/bash
env:LANG           : en_US

I'm going to supply a fix right now.

MGlolenstine commented 5 years ago

This is still a persisting problem... I've contacted people over IRC, but apparently IRC is not being checked regardless there being 22 people online. Problem playing last item: 'latin-1' codec can't encode character '\u201c' in position 21: ordinal not in range(256)Problem playing last item: 'latin-1' codec can't encode character '\u201c' in position 21: ordinal not in range(256) this is my problem and it's present if there's " in the title. I've tried export PYTHONIOENCODING=iso-8859-2 and export PYTHONIOENCODING=unicode, but none of those work. I'm also using the latest dev build.

MGlolenstine commented 5 years ago

This is still a persisting problem... I've contacted people over IRC, but apparently IRC is not being checked regardless there being 22 people online. Problem playing last item: 'latin-1' codec can't encode character '\u201c' in position 21: ordinal not in range(256)Problem playing last item: 'latin-1' codec can't encode character '\u201c' in position 21: ordinal not in range(256) this is my problem and it's present if there's " in the title. I've tried export PYTHONIOENCODING=iso-8859-2 and export PYTHONIOENCODING=unicode, but none of those work. I'm also using the latest dev build.