Browse Source

Unicode used in other audiogens

boyska 7 years ago
parent
commit
ff48437a15
3 changed files with 4 additions and 2 deletions
  1. 1 1
      larigira/audiogen_randomdir.py
  2. 2 0
      larigira/audiogen_script.py
  3. 1 1
      larigira/audiogen_static.py

+ 1 - 1
larigira/audiogen_randomdir.py

@@ -46,4 +46,4 @@ def generate(spec):
                       prefix='audiogen-randomdir-')
         os.close(tmp[0])
         shutil.copy(path, tmp[1])
-        yield 'file://' + tmp[1]
+        yield u'file://{}'.format(tmp[1])

+ 2 - 0
larigira/audiogen_script.py

@@ -10,6 +10,7 @@ security reasons).
 The script should assume a minimal environment, and being run from /.  It must
 output one URI per line; please remember that URI must be understood from mpd,
 so file paths are not valid; file:///file/path.ogg is a valid URI instead.
+The output MUST be UTF-8-encoded.
 Empty lines will be skipped.  stderr will be logged, so please be careful.  any
 non-zero exit code will result in no files being added.and an exception being
 logged.
@@ -65,6 +66,7 @@ def generate(spec):
                   (exc.returncode, spec['name']))
         return []
 
+    out = out.decode('utf-8')
     out = [p for p in out.split('\n') if p]
     logging.debug('Script %s produced %d files' % (spec['name'], len(out)))
     return out

+ 1 - 1
larigira/audiogen_static.py

@@ -21,4 +21,4 @@ def generate(spec):
                       prefix='audiogen-static-')
         os.close(tmp[0])
         shutil.copy(path, tmp[1])
-        yield 'file://' + tmp[1]
+        yield u'file://{}'.format(tmp[1])