Revisión | 0704aeb551aa2f53c1b054ddb356c5655ed0bbff (tree) |
---|---|
Tiempo | 2017-12-26 20:49:35 |
Autor | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...> |
Commiter | Jaime Marquínez Ferrándiz |
Fix song path type on python 3
@@ -1,11 +1,14 @@ | ||
1 | 1 | from __future__ import unicode_literals |
2 | 2 | |
3 | +import sys | |
3 | 4 | import os.path |
4 | 5 | import os |
5 | 6 | import sqlite3 |
6 | 7 | import shutil |
7 | 8 | import datetime |
8 | 9 | |
10 | +IS_PY3 = sys.version_info[0] >= 3 | |
11 | + | |
9 | 12 | from beets.plugins import BeetsPlugin |
10 | 13 | from beets.ui import Subcommand |
11 | 14 | from beets.util import prune_dirs, bytestring_path |
@@ -140,6 +143,8 @@ | ||
140 | 143 | item_id = item['id'] |
141 | 144 | fullpath = item['path'] |
142 | 145 | copy_path = os.path.relpath(fullpath, lib.directory) |
146 | + if IS_PY3 and isinstance(copy_path, bytes): | |
147 | + copy_path = copy_path.decode() | |
143 | 148 | if not db.execute('SELECT * FROM song WHERE idSong=?', (item_id,)).fetchall(): |
144 | 149 | with db: |
145 | 150 | db.execute('INSERT INTO song (idSong, filename) VALUES (?,?)', (item_id, copy_path)) |