• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

Commit MetaInfo

Revisionfa5c6134b5236a25e431c9a498f94cd08e88d799 (tree)
Zeit2019-08-30 04:50:30
AutorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Log Message

Use the convert plugin

Ändern Zusammenfassung

Diff

diff -r 4d513a0808fa -r fa5c6134b523 beetsplug/playersync.py
--- a/beetsplug/playersync.py Fri Feb 16 21:48:53 2018 +0100
+++ b/beetsplug/playersync.py Thu Aug 29 21:50:30 2019 +0200
@@ -6,16 +6,15 @@
66 import sqlite3
77 import shutil
88 import datetime
9-import subprocess
10-import tempfile
119
1210 IS_PY3 = sys.version_info[0] >= 3
1311
1412 from beets.plugins import BeetsPlugin
1513 from beets.ui import Subcommand
16-from beets.util import prune_dirs, bytestring_path, command_output
14+from beets.util import prune_dirs, bytestring_path
1715 from beets.dbcore import OrQuery
1816 from beets.library import parse_query_parts, Item
17+from beetsplug.convert import get_format, ConvertPlugin
1918
2019 _CREATE_DATABASE_SCRIPT='''
2120 CREATE TABLE song(idSong INTEGER PRIMARY KEY, filename TEXT NOT NULL, date TIMESTAMP, synced BOOL);
@@ -137,15 +136,10 @@
137136 else:
138137 fmt = _format_from_ext(new_ext.lstrip('.'))
139138 self.info('Converting to {0}: {1}', fmt, item)
140- args = sys.argv[:sys.argv.index('sync')]
141- temp_dir = tempfile.mkdtemp()
142- try:
143- args.extend(['convert', '--yes', '--format', fmt, '--dest', temp_dir, 'id:' + str(item_id)])
144- out = subprocess.check_call(args)
145- temp_path = os.path.join(temp_dir, song_path)
146- shutil.copyfile(temp_path, copy_path)
147- finally:
148- shutil.rmtree(temp_dir)
139+ convert_command, _ = get_format(fmt)
140+ self.config['quiet'] = False
141+ ConvertPlugin.encode(self, convert_command, item['path'],
142+ copy_path.encode() if (IS_PY3 and isinstance(copy_path, str)) else copy_path)
149143 db.execute('UPDATE song SET synced=1,date=? WHERE idSong=?', (datetime.datetime.now(), item_id))
150144
151145 for item_id, song_path in db.execute('''