Skip to content

Commit

Permalink
Merge pull request #17 from adamjakab/devel
Browse files Browse the repository at this point in the history
enable multithreading during import
  • Loading branch information
adamjakab authored May 11, 2024
2 parents 7b43927 + fcf1bcd commit 6855612
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bpmanalyser:
quiet: no
```
By setting the `auto` option to `yes`, the plugin will be run automatically on each new item during import. In this case, the `threads` option is ignored (beets import is already multithreaded).
By setting the `auto` option to `yes`, the plugin will be run automatically on each new item during import.

The other configuration options can also be set from the command line when running the plugin.
Here are the options explained:
Expand All @@ -53,7 +53,7 @@ _-f, --force_ : By default only songs with no bpm value (bpm:0) are analysed. Us

_-w, --write_ : Write the bpm values directly to the media files.

_-t THREADS, --threads=THREADS_: Set the number of processes that can run in parallel. By default it is set to AUTO (`threads: AUTO`) and it will use half of the number of cores of your processor(s) have. You can set this to any number to specify how many concurrent threads you want to run.
_-t THREADS, --threads=THREADS_: Set the number of processes to run in parallel. By default it is set to AUTO (`threads: AUTO`) and it will use half of the number of cores of your processor(s) have. You can set this to any number to specify how many concurrent threads you want to run.

_-q, --quiet_ : Do not display any output from the command.

Expand Down
16 changes: 7 additions & 9 deletions beetsplug/bpmanalyser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# License: See LICENSE.txt

import logging
import os

from beets.plugins import BeetsPlugin
from beetsplug.bpmanalyser.command import BpmAnalyserCommand
Expand Down Expand Up @@ -33,12 +34,9 @@ def commands(self):
return [BpmAnalyserCommand(self.config)]

def imported(self, session, task):
cmd = BpmAnalyserCommand(self.config)
# Add BPM for imported items.
for item in task.imported_items():
if not self.config['force'] and item['bpm'] != 0:
item_path = item.get("path").decode("utf-8")
log.debug("Skipped. Item({}) has already got BPM: {}".format(item_path, item['bpm']))
return
else:
cmd.runAnalyser(item)
BpmAnalyserCommand(self.config).execute_task_on_items(task.imported_items())

# Because of this pydub issue(https://github.com/jiaaro/pydub/issues/503) the below is necessary for now
# to regain console input (can also use reset) - not sure if Windows is affected
if os.name != 'nt':
os.system('stty echo')
2 changes: 1 addition & 1 deletion beetsplug/bpmanalyser/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Created: 2/24/20, 12:09 AM
# License: See LICENSE.txt

__version__ = '1.5.7'
__version__ = '1.5.8'

0 comments on commit 6855612

Please sign in to comment.