From 1da919bc40aa430e4f85b71975c1d4a0d021d059 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Sun, 17 Jul 2016 05:57:52 -0400 Subject: [PATCH] open lastgenre genres file with codecs.open() This should fix an error when decoding the file on Windows. It defaults to using the code page there and not utf-8 as intended for yaml. --- beetsplug/lastgenre/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index bc3155b94..f901bdaac 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -25,6 +25,7 @@ The scraper script used is available here: https://gist.github.com/1241307 """ import pylast +import codecs import os import yaml import traceback @@ -140,7 +141,8 @@ class LastGenrePlugin(plugins.BeetsPlugin): c14n_filename = C14N_TREE if c14n_filename: c14n_filename = normpath(c14n_filename) - genres_tree = yaml.load(open(c14n_filename, 'r')) + genres_file = codecs.open(c14n_filename, 'r', encoding='utf-8') + genres_tree = yaml.load(genres_file) flatten_tree(genres_tree, [], self.c14n_branches) @property