pnbt / youtube-explore

Finding YouTube's top recommendations from any query
211 stars 54 forks source link

Script can't handle non-ASCII characters in video titles #10

Open robroc opened 5 years ago

robroc commented 5 years ago

I usually use Python 3+, which handles unicode natively. I created a 2.7 virtualenv, and it's failing when video titles have accented characters.

The error happens on line 234, when video title is printed:

File "follow-youtube-recommendations.py", line 234, in get_recommendations
    print(video_id + ': ' + video['title'] + ' [' + channel + ']{' + repr(key) +'} ' + str(video['views']
  File "...\envs\py27\lib\encodings\cp850.py", line 12, in
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 25: character maps to <u