• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonrubyphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Commit MetaInfo

Revisão0704aeb551aa2f53c1b054ddb356c5655ed0bbff (tree)
Hora2017-12-26 20:49:35
AutorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Mensagem de Log

Fix song path type on python 3

Mudança Sumário

Diff

diff -r ebe378b053c5 -r 0704aeb551aa beetsplug/playersync.py
--- a/beetsplug/playersync.py Sat Oct 14 17:30:14 2017 +0200
+++ b/beetsplug/playersync.py Tue Dec 26 12:49:35 2017 +0100
@@ -1,11 +1,14 @@
11 from __future__ import unicode_literals
22
3+import sys
34 import os.path
45 import os
56 import sqlite3
67 import shutil
78 import datetime
89
10+IS_PY3 = sys.version_info[0] >= 3
11+
912 from beets.plugins import BeetsPlugin
1013 from beets.ui import Subcommand
1114 from beets.util import prune_dirs, bytestring_path
@@ -140,6 +143,8 @@
140143 item_id = item['id']
141144 fullpath = item['path']
142145 copy_path = os.path.relpath(fullpath, lib.directory)
146+ if IS_PY3 and isinstance(copy_path, bytes):
147+ copy_path = copy_path.decode()
143148 if not db.execute('SELECT * FROM song WHERE idSong=?', (item_id,)).fetchall():
144149 with db:
145150 db.execute('INSERT INTO song (idSong, filename) VALUES (?,?)', (item_id, copy_path))