prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  mbsubmit: cleanup and completion
  Glad to see a new release has been made!
  
  I'm getting back to work on beets after a few days away from the computer, hopefully bringing issue #1689 to a close eventually. As hinted on the previous discussion, this pull request is intended to take care of the `mbsubmit` plugin cleanup, now that the underlying pieces are in place.
  
  I have modified a bit the behaviour, making the decision of appending the `"Print tracks"` choice depend solely on `task.rec`. The default behaviour is to only append the choice to matches where the recommendation is equal or lower than `Recommendation.medium`, which hopefully covers the most obvious choices (albums with no matches, albums with weak-ish matches) and the original request by @awesomer, and also avoids polluting the prompt in the cases where the match is strong. A config option has been added that allows the user to modify this settings (extra-picky users might find it useful to always be able to print tracks for fixing spelling mistakes, other users might only want it on albums with no matches, etc).
  
  Other than that, a configuration option for setting the format string has been added as well - I can't think of a case where this might come in handy currently, but maybe more creative users might find it useful.
  
  A couple of notes:
  - currently, the plugin makes no effort of nicely formatting items that might be lacking some of the required fields. Would it be useful to add some extra checks and fall back to printing the filename (or something more advanced with the help of `fromfilename`, etc) in those cases?
  - there might be some problems on some combination on options: for example, if the user sets the threshold to `strong`, but launches the importer in non-timid mode, the prompt will not actually be displayed. Would a note on the (upcoming) documentation suffice, as handling this case probably requires some changes that seem to be a bit out of the scope of the plugin?
  
  As usual, any comments and input are more than welcome!
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `beetsplug/mbsubmit.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # This file is part of beets.
  3 # Copyright 2016, Adrian Sampson and Diego Moreda.
  4 #
  5 # Permission is hereby granted, free of charge, to any person obtaining
  6 # a copy of this software and associated documentation files (the
  7 # "Software"), to deal in the Software without restriction, including
  8 # without limitation the rights to use, copy, modify, merge, publish,
  9 # distribute, sublicense, and/or sell copies of the Software, and to
  10 # permit persons to whom the Software is furnished to do so, subject to
  11 # the following conditions:
  12 #
  13 # The above copyright notice and this permission notice shall be
  14 # included in all copies or substantial portions of the Software.
  15 
  16 """Aid in submitting information to MusicBrainz.
  17 
  18 This plugin allows the user to print track information in a format that is
  19 parseable by the MusicBrainz track parser. Programmatic submitting is not
  20 implemented by MusicBrainz yet.
  21 """
  22 
  23 from __future__ import (division, absolute_import, print_function,
  24                         unicode_literals)
  25 
  26 
  27 from beets.autotag import Recommendation
  28 from beets.importer import action
  29 from beets.plugins import BeetsPlugin
  30 from beets.ui.commands import PromptChoice
  31 from beetsplug.info import print_data
  32 
  33 
  34 class MBSubmitPlugin(BeetsPlugin):
  35     def __init__(self):
  36         super(MBSubmitPlugin, self).__init__()
  37 
  38         self.register_listener('before_choose_candidate',
  39                                self.before_choose_candidate_event)
  40 
  41     def before_choose_candidate_event(self, session, task):
  42         if not task.candidates or task.rec == Recommendation.none:
  43             return [PromptChoice('p', 'Print tracks', self.print_tracks),
  44                     PromptChoice('k', 'print tracks and sKip',
  45                                  self.print_tracks_and_skip)]
  46 
  47     # Callbacks for choices.
  48     def print_tracks(self, session, task):
  49         for i in task.items:
  50             print_data(None, i, '$track. $artist - $title ($length)')
  51 
  52     def print_tracks_and_skip(self, session, task):
  53         for i in task.items:
  54             print_data(None, i, '$track. $artist - $title ($length)')
  55         return action.SKIP
  56
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/beetsplug/mbsubmit.py b/beetsplug/mbsubmit.py
  --- a/beetsplug/mbsubmit.py
  +++ b/beetsplug/mbsubmit.py
  @@ -16,8 +16,10 @@
   """Aid in submitting information to MusicBrainz.
   
   This plugin allows the user to print track information in a format that is
  -parseable by the MusicBrainz track parser. Programmatic submitting is not
  +parseable by the MusicBrainz track parser [1]. Programmatic submitting is not
   implemented by MusicBrainz yet.
  +
  +[1] http://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings
   """
   
   from __future__ import (division, absolute_import, print_function,
  @@ -25,7 +27,6 @@
   
   
   from beets.autotag import Recommendation
  -from beets.importer import action
   from beets.plugins import BeetsPlugin
   from beets.ui.commands import PromptChoice
   from beetsplug.info import print_data
  @@ -35,21 +36,26 @@
       def __init__(self):
           super(MBSubmitPlugin, self).__init__()
   
  +        self.config.add({
  +            'format': '$track. $title - $artist ($length)',
  +            'threshold': 'medium',
  +        })
  +
  +        # Validate and store threshold.
  +        self.threshold = self.config['threshold'].as_choice({
  +            'none': Recommendation.none,
  +            'low': Recommendation.low,
  +            'medium': Recommendation.medium,
  +            'strong': Recommendation.strong
  +        })
  +
           self.register_listener('before_choose_candidate',
                                  self.before_choose_candidate_event)
   
       def before_choose_candidate_event(self, session, task):
  -        if not task.candidates or task.rec == Recommendation.none:
  -            return [PromptChoice('p', 'Print tracks', self.print_tracks),
  -                    PromptChoice('k', 'print tracks and sKip',
  -                                 self.print_tracks_and_skip)]
  +        if task.rec <= self.threshold:
  +            return [PromptChoice('p', 'Print tracks', self.print_tracks)]
   
  -    # Callbacks for choices.
       def print_tracks(self, session, task):
           for i in task.items:
  -            print_data(None, i, '$track. $artist - $title ($length)')
  -
  -    def print_tracks_and_skip(self, session, task):
  -        for i in task.items:
  -            print_data(None, i, '$track. $artist - $title ($length)')
  -        return action.SKIP
  +            print_data(None, i, self.config['format'].get())
  
verification_info: {"golden_diff": "diff --git a/beetsplug/mbsubmit.py b/beetsplug/mbsubmit.py\n--- a/beetsplug/mbsubmit.py\n+++ b/beetsplug/mbsubmit.py\n@@ -16,8 +16,10 @@\n \"\"\"Aid in submitting information to MusicBrainz.\n \n This plugin allows the user to print track information in a format that is\n-parseable by the MusicBrainz track parser. Programmatic submitting is not\n+parseable by the MusicBrainz track parser [1]. Programmatic submitting is not\n implemented by MusicBrainz yet.\n+\n+[1] http://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings\n \"\"\"\n \n from __future__ import (division, absolute_import, print_function,\n@@ -25,7 +27,6 @@\n \n \n from beets.autotag import Recommendation\n-from beets.importer import action\n from beets.plugins import BeetsPlugin\n from beets.ui.commands import PromptChoice\n from beetsplug.info import print_data\n@@ -35,21 +36,26 @@\n     def __init__(self):\n         super(MBSubmitPlugin, self).__init__()\n \n+        self.config.add({\n+            'format': '$track. $title - $artist ($length)',\n+            'threshold': 'medium',\n+        })\n+\n+        # Validate and store threshold.\n+        self.threshold = self.config['threshold'].as_choice({\n+            'none': Recommendation.none,\n+            'low': Recommendation.low,\n+            'medium': Recommendation.medium,\n+            'strong': Recommendation.strong\n+        })\n+\n         self.register_listener('before_choose_candidate',\n                                self.before_choose_candidate_event)\n \n     def before_choose_candidate_event(self, session, task):\n-        if not task.candidates or task.rec == Recommendation.none:\n-            return [PromptChoice('p', 'Print tracks', self.print_tracks),\n-                    PromptChoice('k', 'print tracks and sKip',\n-                                 self.print_tracks_and_skip)]\n+        if task.rec <= self.threshold:\n+            return [PromptChoice('p', 'Print tracks', self.print_tracks)]\n \n-    # Callbacks for choices.\n     def print_tracks(self, session, task):\n         for i in task.items:\n-            print_data(None, i, '$track. $artist - $title ($length)')\n-\n-    def print_tracks_and_skip(self, session, task):\n-        for i in task.items:\n-            print_data(None, i, '$track. $artist - $title ($length)')\n-        return action.SKIP\n+            print_data(None, i, self.config['format'].get())\n", "issue": "mbsubmit: cleanup and completion\nGlad to see a new release has been made!\n\nI'm getting back to work on beets after a few days away from the computer, hopefully bringing issue #1689 to a close eventually. As hinted on the previous discussion, this pull request is intended to take care of the `mbsubmit` plugin cleanup, now that the underlying pieces are in place.\n\nI have modified a bit the behaviour, making the decision of appending the `\"Print tracks\"` choice depend solely on `task.rec`. The default behaviour is to only append the choice to matches where the recommendation is equal or lower than `Recommendation.medium`, which hopefully covers the most obvious choices (albums with no matches, albums with weak-ish matches) and the original request by @awesomer, and also avoids polluting the prompt in the cases where the match is strong. A config option has been added that allows the user to modify this settings (extra-picky users might find it useful to always be able to print tracks for fixing spelling mistakes, other users might only want it on albums with no matches, etc).\n\nOther than that, a configuration option for setting the format string has been added as well - I can't think of a case where this might come in handy currently, but maybe more creative users might find it useful.\n\nA couple of notes:\n- currently, the plugin makes no effort of nicely formatting items that might be lacking some of the required fields. Would it be useful to add some extra checks and fall back to printing the filename (or something more advanced with the help of `fromfilename`, etc) in those cases?\n- there might be some problems on some combination on options: for example, if the user sets the threshold to `strong`, but launches the importer in non-timid mode, the prompt will not actually be displayed. Would a note on the (upcoming) documentation suffice, as handling this case probably requires some changes that seem to be a bit out of the scope of the plugin?\n\nAs usual, any comments and input are more than welcome!\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# This file is part of beets.\n# Copyright 2016, Adrian Sampson and Diego Moreda.\n#\n# Permission is hereby granted, free of charge, to any person obtaining\n# a copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n#\n# The above copyright notice and this permission notice shall be\n# included in all copies or substantial portions of the Software.\n\n\"\"\"Aid in submitting information to MusicBrainz.\n\nThis plugin allows the user to print track information in a format that is\nparseable by the MusicBrainz track parser. Programmatic submitting is not\nimplemented by MusicBrainz yet.\n\"\"\"\n\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\n\nfrom beets.autotag import Recommendation\nfrom beets.importer import action\nfrom beets.plugins import BeetsPlugin\nfrom beets.ui.commands import PromptChoice\nfrom beetsplug.info import print_data\n\n\nclass MBSubmitPlugin(BeetsPlugin):\n    def __init__(self):\n        super(MBSubmitPlugin, self).__init__()\n\n        self.register_listener('before_choose_candidate',\n                               self.before_choose_candidate_event)\n\n    def before_choose_candidate_event(self, session, task):\n        if not task.candidates or task.rec == Recommendation.none:\n            return [PromptChoice('p', 'Print tracks', self.print_tracks),\n                    PromptChoice('k', 'print tracks and sKip',\n                                 self.print_tracks_and_skip)]\n\n    # Callbacks for choices.\n    def print_tracks(self, session, task):\n        for i in task.items:\n            print_data(None, i, '$track. $artist - $title ($length)')\n\n    def print_tracks_and_skip(self, session, task):\n        for i in task.items:\n            print_data(None, i, '$track. $artist - $title ($length)')\n        return action.SKIP\n", "path": "beetsplug/mbsubmit.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# This file is part of beets.\n# Copyright 2016, Adrian Sampson and Diego Moreda.\n#\n# Permission is hereby granted, free of charge, to any person obtaining\n# a copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n#\n# The above copyright notice and this permission notice shall be\n# included in all copies or substantial portions of the Software.\n\n\"\"\"Aid in submitting information to MusicBrainz.\n\nThis plugin allows the user to print track information in a format that is\nparseable by the MusicBrainz track parser [1]. Programmatic submitting is not\nimplemented by MusicBrainz yet.\n\n[1] http://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings\n\"\"\"\n\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\n\nfrom beets.autotag import Recommendation\nfrom beets.plugins import BeetsPlugin\nfrom beets.ui.commands import PromptChoice\nfrom beetsplug.info import print_data\n\n\nclass MBSubmitPlugin(BeetsPlugin):\n    def __init__(self):\n        super(MBSubmitPlugin, self).__init__()\n\n        self.config.add({\n            'format': '$track. $title - $artist ($length)',\n            'threshold': 'medium',\n        })\n\n        # Validate and store threshold.\n        self.threshold = self.config['threshold'].as_choice({\n            'none': Recommendation.none,\n            'low': Recommendation.low,\n            'medium': Recommendation.medium,\n            'strong': Recommendation.strong\n        })\n\n        self.register_listener('before_choose_candidate',\n                               self.before_choose_candidate_event)\n\n    def before_choose_candidate_event(self, session, task):\n        if task.rec <= self.threshold:\n            return [PromptChoice('p', 'Print tracks', self.print_tracks)]\n\n    def print_tracks(self, session, task):\n        for i in task.items:\n            print_data(None, i, self.config['format'].get())\n", "path": "beetsplug/mbsubmit.py"}]}