Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
beetbox/beets
AndroidMarv/beets
BenningtonCollege/beets
Bitdemon/beets
Boehemyth/beets
BrainDamage/beets
DittoPardo/beets
DocPhilDuPlessis/beets
EQ4/beets
FHFard/beets
Kamalka-Fernando/beets
Klimaks/beets
Kraymer/beets
Lugoues/beets
Ma5onic/beets
MechanisM/beets
Mkey1987/beets
MusikPolice/beets
NahuelPineda/beets
Neeraj-Kashyap/beets
OceanStreamDolphin/beets
PierreRust/beets
Plecebo/beets
Rovanion/beets
SUTJael/beets
SammyZheng/beets
Smyds/beets
Tantali/beets
ThrmMasterOv/beets
Thynix/beets
Wangliang1992/beets
Wen777/beets
adamelso/beets
akiva/beets
alejandroblanco82/beets
andremiller/beets
angrygorilla/beets
asutherland/beets
awesome/beets
awjrichards-zz/beets
ayberk/beets
bertah/beets
billthornton/beets
braneed/beets
breunigs/beets
cakebread/beets
camikazegreen/beets
cconner1/beets
chiay888/beets
chriscogburn/beets
colin-scott/beets
coolkehon/beets
dajo/beets
darongE/beets
davidbrenner/beets
dcode/beets
delftswa2017/beets
djrtl/beets-dj
dokterbob/beets
domenkozar/beets
dsedivec/beets
dz0ny/beets
ebunt/beets
eddiex/beets
edlandm/beets
edmoody/beets
encukou/beets
ergatea/beets
faisalchohan/beets
feufy78/beets
filmor/beets
flz/beets
fortes/beets
giorgosg/beets
glittershark/beets
goncalopp/beets
graffias/beets
harshit98/beets
hchapman/beets
holms/beets
homertwigg/beets
iMerica/beets
idandan/beets
imenem/beets
ion1/beets
jamslevy/beets
jayme-github/beets
jbaiter/beets
jbarbuto/beets
jeffayle/beets
jenzie/beets
jeremyfrench/beets
jhawthorn/beets
jizz/beets
jmcelderry/beets
johtso/beets
joleena/beets
jvanhie/beets
jwhelan-/beets
kaptajnguldkorn/beets
kelvinhammond/beets
kljohann/beets
kousikan/beets
kpj/beets
krig/beets
ktkonrad/beets
laarmen/beets
lcharlick/beets
leagloriane/beets
lenciel/beets
leospiritlee/beets
liyinhgqw/beets
macmenot/beets
madjar/beets
maggieluo/beets
mayankgautam/beets
mdecker/beets
meesy/beets
mehulsbhatt/beets
metalspirit/beets
michl/beets
mindsocket/beets
mineo/beets
mister-walter/beets
mk-fg/beets
mook/beets
mrr0b0t1/beets
msabramo/beets
mschuerig/beets
multikatt/beets
mwhansen/beets
nateroling/beets
navap/beets
navinpai/beets
netconstructor/beets
ngokevin/beets
nidico/beets
nijotz/beets
nuox/beets
pall-valmundsson/beets
pallotron/beets
paulprovost/beets
pcaro90/beets
pedros/beets
peeyush113/beets
phaethon/beets
phmongeau/beets
pombredanne/beets
pprkut/beets
prodigeni/beets
psychoticmeow/beets
pyntel/beets
queer1/beets
rashley60/beets
razorjack/beets
rdwhynot/beets
refreshoxford/beets
rfdiazpr/beets
robshanholtz/beets
ryanakca/beets
sahandKashani/beets
sashaseifollahi/beets
sbuser/beets
scotto/beets
seongdo/beets
shaunstanislaus/beets
silky/beets
simonluijk/beets
simonwarwick/beets
sporkexec/beets
spoudell/beets
sralmai/beets
sriprasanna/beets
stchris/beets
systems-rebooter/beets
teeps47/beets
telejester/beets
terunka/beets
tezoulbr/beets
theVDude/beets
thismachinechills/beets
tiagoad/beets
tima/beets
tobim/beets
toddbot2/beets
tom--/beets
tomjaspers/beets
tompor598/beets
tonilap/beets
trbngr/beets
triplem/beets
twentyoneguns/beets
wiget/beets
wudangt/beets
xhochy/beets
yourbuddyrohan/beets
yuanyey/beets
zacharydenton/beets
zammot/beets
zunami/beets
Nothing to show
Choose a Head Repository
beetbox/beets
AndroidMarv/beets
BenningtonCollege/beets
Bitdemon/beets
Boehemyth/beets
BrainDamage/beets
DittoPardo/beets
DocPhilDuPlessis/beets
EQ4/beets
FHFard/beets
Kamalka-Fernando/beets
Klimaks/beets
Kraymer/beets
Lugoues/beets
Ma5onic/beets
MechanisM/beets
Mkey1987/beets
MusikPolice/beets
NahuelPineda/beets
Neeraj-Kashyap/beets
OceanStreamDolphin/beets
PierreRust/beets
Plecebo/beets
Rovanion/beets
SUTJael/beets
SammyZheng/beets
Smyds/beets
Tantali/beets
ThrmMasterOv/beets
Thynix/beets
Wangliang1992/beets
Wen777/beets
adamelso/beets
akiva/beets
alejandroblanco82/beets
andremiller/beets
angrygorilla/beets
asutherland/beets
awesome/beets
awjrichards-zz/beets
ayberk/beets
bertah/beets
billthornton/beets
braneed/beets
breunigs/beets
cakebread/beets
camikazegreen/beets
cconner1/beets
chiay888/beets
chriscogburn/beets
colin-scott/beets
coolkehon/beets
dajo/beets
darongE/beets
davidbrenner/beets
dcode/beets
delftswa2017/beets
djrtl/beets-dj
dokterbob/beets
domenkozar/beets
dsedivec/beets
dz0ny/beets
ebunt/beets
eddiex/beets
edlandm/beets
edmoody/beets
encukou/beets
ergatea/beets
faisalchohan/beets
feufy78/beets
filmor/beets
flz/beets
fortes/beets
giorgosg/beets
glittershark/beets
goncalopp/beets
graffias/beets
harshit98/beets
hchapman/beets
holms/beets
homertwigg/beets
iMerica/beets
idandan/beets
imenem/beets
ion1/beets
jamslevy/beets
jayme-github/beets
jbaiter/beets
jbarbuto/beets
jeffayle/beets
jenzie/beets
jeremyfrench/beets
jhawthorn/beets
jizz/beets
jmcelderry/beets
johtso/beets
joleena/beets
jvanhie/beets
jwhelan-/beets
kaptajnguldkorn/beets
kelvinhammond/beets
kljohann/beets
kousikan/beets
kpj/beets
krig/beets
ktkonrad/beets
laarmen/beets
lcharlick/beets
leagloriane/beets
lenciel/beets
leospiritlee/beets
liyinhgqw/beets
macmenot/beets
madjar/beets
maggieluo/beets
mayankgautam/beets
mdecker/beets
meesy/beets
mehulsbhatt/beets
metalspirit/beets
michl/beets
mindsocket/beets
mineo/beets
mister-walter/beets
mk-fg/beets
mook/beets
mrr0b0t1/beets
msabramo/beets
mschuerig/beets
multikatt/beets
mwhansen/beets
nateroling/beets
navap/beets
navinpai/beets
netconstructor/beets
ngokevin/beets
nidico/beets
nijotz/beets
nuox/beets
pall-valmundsson/beets
pallotron/beets
paulprovost/beets
pcaro90/beets
pedros/beets
peeyush113/beets
phaethon/beets
phmongeau/beets
pombredanne/beets
pprkut/beets
prodigeni/beets
psychoticmeow/beets
pyntel/beets
queer1/beets
rashley60/beets
razorjack/beets
rdwhynot/beets
refreshoxford/beets
rfdiazpr/beets
robshanholtz/beets
ryanakca/beets
sahandKashani/beets
sashaseifollahi/beets
sbuser/beets
scotto/beets
seongdo/beets
shaunstanislaus/beets
silky/beets
simonluijk/beets
simonwarwick/beets
sporkexec/beets
spoudell/beets
sralmai/beets
sriprasanna/beets
stchris/beets
systems-rebooter/beets
teeps47/beets
telejester/beets
terunka/beets
tezoulbr/beets
theVDude/beets
thismachinechills/beets
tiagoad/beets
tima/beets
tobim/beets
toddbot2/beets
tom--/beets
tomjaspers/beets
tompor598/beets
tonilap/beets
trbngr/beets
triplem/beets
twentyoneguns/beets
wiget/beets
wudangt/beets
xhochy/beets
yourbuddyrohan/beets
yuanyey/beets
zacharydenton/beets
zammot/beets
zunami/beets
Nothing to show
  • 17 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 28, 2016
Introduce a new Proposal type for tag results
tag_album and tag_item now return a Proposal. The idea is that plugin actions
should also be able to return Proposal values, just like the built-in actions.
Refactor extra choice return value
The `choose_candidate` function now returns the `PromptChoice` object instead
of a short letter that selects the `PromptChoice`.
Refactor manual search options to use Proposal
This is the first step to making them behave like plugin actions.
Refactor search options to ordinary choices
`PromptChoice`s can now return `Proposal` values, which makes these two
options just "normal" actions that could be provided by plugins.
Revert "Fix tests for new prompt order"
This reverts commit a357cc4.

We no longer need the tests to change---I was able to fix the order by
bringing the "abort" action into the standard list of options.
Use declarative style for ALBUMS/TRACKS choices
This unifies the set of choices that are shown at each prompt variant in
`choose_candidate`, making its code much shorter. Declarative programming FTW.
Move as-is and skip choices to declarative choices
That's all the standard choices that don't depend on which prompt you're
looking at! Woohoo!
Rename some choice-related variables
These are no longer "extra"---they're *all* the choices that will be used.
Showing with 145 additions and 206 deletions.
  1. +1 −1 beets/autotag/__init__.py
  2. +20 −12 beets/autotag/match.py
  3. +7 −10 beets/importer.py
  4. +111 −162 beets/ui/commands.py
  5. +1 −1 beetsplug/acousticbrainz.py
  6. +2 −0 docs/changelog.rst
  7. +3 −5 docs/dev/plugins.rst
  8. +0 −15 test/test_ui.py
@@ -23,7 +23,7 @@
# Parts of external interface.
from .hooks import AlbumInfo, TrackInfo, AlbumMatch, TrackMatch # noqa
from .match import tag_item, tag_album # noqa
from .match import tag_item, tag_album, Proposal # noqa
from .match import Recommendation # noqa
# Global logger.
View
@@ -22,6 +22,7 @@
import datetime
import re
from munkres import Munkres
from collections import namedtuple
from beets import logging
from beets import plugins
@@ -52,6 +53,13 @@ class Recommendation(OrderedEnum):
strong = 3
# A structure for holding a set of possible matches to choose between. This
# consists of a list of possible candidates (i.e., AlbumInfo or TrackInfo
# objects) and a recommendation value.
Proposal = namedtuple('Proposal', ('candidates', 'recommendation'))
# Primary matching functionality.
def current_metadata(items):
@@ -379,9 +387,8 @@ def _add_candidate(items, results, info):
def tag_album(items, search_artist=None, search_album=None,
search_ids=[]):
"""Return a tuple of a artist name, an album name, a list of
`AlbumMatch` candidates from the metadata backend, and a
`Recommendation`.
"""Return a tuple of the current artist name, the current album
name, and a `Proposal` containing `AlbumMatch` candidates.
The artist and album are the most common values of these fields
among `items`.
@@ -429,7 +436,7 @@ def tag_album(items, search_artist=None, search_album=None,
if rec == Recommendation.strong:
log.debug(u'ID match.')
return cur_artist, cur_album, \
list(candidates.values()), rec
Proposal(list(candidates.values()), rec)
# Search terms.
if not (search_artist and search_album):
@@ -454,14 +461,15 @@ def tag_album(items, search_artist=None, search_album=None,
# Sort and get the recommendation.
candidates = _sort_candidates(candidates.values())
rec = _recommendation(candidates)
return cur_artist, cur_album, candidates, rec
return cur_artist, cur_album, Proposal(candidates, rec)
def tag_item(item, search_artist=None, search_title=None,
search_ids=[]):
"""Attempts to find metadata for a single track. Returns a
`(candidates, recommendation)` pair where `candidates` is a list of
TrackMatch objects. `search_artist` and `search_title` may be used
"""Find metadata for a single track. Return a `Proposal` consisting
of `TrackMatch` objects.
`search_artist` and `search_title` may be used
to override the current metadata for the purposes of the MusicBrainz
title. `search_ids` may be used for restricting the search to a list
of metadata backend IDs.
@@ -484,14 +492,14 @@ def tag_item(item, search_artist=None, search_title=None,
if rec == Recommendation.strong and \
not config['import']['timid']:
log.debug(u'Track ID match.')
return _sort_candidates(candidates.values()), rec
return Proposal(_sort_candidates(candidates.values()), rec)
# If we're searching by ID, don't proceed.
if search_ids:
if candidates:
return _sort_candidates(candidates.values()), rec
return Proposal(_sort_candidates(candidates.values()), rec)
else:
return [], Recommendation.none
return Proposal([], Recommendation.none)
# Search terms.
if not (search_artist and search_title):
@@ -507,4 +515,4 @@ def tag_item(item, search_artist=None, search_title=None,
log.debug(u'Found {0} candidates.', len(candidates))
candidates = _sort_candidates(candidates.values())
rec = _recommendation(candidates)
return candidates, rec
return Proposal(candidates, rec)
View
@@ -43,8 +43,7 @@
from beets import mediafile
action = Enum('action',
['SKIP', 'ASIS', 'TRACKS', 'MANUAL', 'APPLY', 'MANUAL_ID',
'ALBUMS', 'RETAG'])
['SKIP', 'ASIS', 'TRACKS', 'APPLY', 'ALBUMS', 'RETAG'])
# The RETAG action represents "don't apply any match, but do record
# new metadata". It's not reachable via the standard command prompt but
# can be used by plugins.
@@ -443,7 +442,6 @@ def set_choice(self, choice):
indicates that an action has been selected for this task.
"""
# Not part of the task structure:
assert choice not in (action.MANUAL, action.MANUAL_ID)
assert choice != action.APPLY # Only used internally.
if choice in (action.SKIP, action.ASIS, action.TRACKS, action.ALBUMS,
action.RETAG):
@@ -587,12 +585,12 @@ def lookup_candidates(self):
candidate IDs are stored in self.search_ids: if present, the
initial lookup is restricted to only those IDs.
"""
artist, album, candidates, recommendation = \
artist, album, prop = \
autotag.tag_album(self.items, search_ids=self.search_ids)
self.cur_artist = artist
self.cur_album = album
self.candidates = candidates
self.rec = recommendation
self.candidates = prop.candidates
self.rec = prop.recommendation
def find_duplicates(self, lib):
"""Return a list of albums from `lib` with the same artist and
@@ -830,10 +828,9 @@ def _emit_imported(self, lib):
plugins.send('item_imported', lib=lib, item=item)
def lookup_candidates(self):
candidates, recommendation = autotag.tag_item(
self.item, search_ids=self.search_ids)
self.candidates = candidates
self.rec = recommendation
prop = autotag.tag_item(self.item, search_ids=self.search_ids)
self.candidates = prop.candidates
self.rec = prop.recommendation
def find_duplicates(self, lib):
"""Return a list of items from `lib` that have the same artist
Oops, something went wrong.

No commit comments for this range