beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.92k stars 1.82k forks source link

`beet modify` in select mode should observe `sort_item` setting #3051

Closed discopatrick closed 6 years ago

discopatrick commented 6 years ago

Problem

Running this command in verbose (-vv) mode:

$ beet -vv modify air moon safari dj=True

Led to this problem:

Modifying 10 items.
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:05/10 - Talisman - 4:16 - FLAC - 825kbps - CD - dj:$dj
  dj: True
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:06/10 - Remember - 2:34 - FLAC - 879kbps - CD - dj:$dj
  dj: True
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:07/10 - You Make It Easy - 4:01 - FLAC - 862kbps - CD - dj:$dj
  dj: True
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:08/10 - Ce matin-là - 3:38 - FLAC - 852kbps - CD - dj:$dj
  dj: True
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:09/10 - New Star in the Sky (Chanson pour Solal) - 5:40 - FLAC - 766kbps - CD - dj:$dj
  dj: True
2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:10/10 - Le Voyage de Pénélope - 3:11 - FLAC - 768kbps - CD - dj:$dj
  dj: True
Really modify, move and write tags? (Yes/no/select) s

2017-09-28 20:04:08 - Air - Moon Safari - d:01/01--t:09/10 - New Star in the Sky (Chanson pour Solal) - 5:40 - FLAC - 766kbps - CD - dj:$dj
  dj: True
Really modify, move and write tags? (yes/no)

As you can see, the tracks are initially sorted according to my sort_item setting of albumartist+ album+ disc+ track+. (The first 4 tracks from this album are not listed because I already modified them earlier!) However, when I move into "select" mode, the first track it asks me to confirm is not the first track from the original list.

Setup

My configuration (output of beet config) is:

---

directory: "/Volumes/2TB Iomega Data/Users/patrick/Music/beets/collection"
library: "/Volumes/2TB Iomega Data/Users/patrick/Music/beets/library/musiclibrary.blb"

plugins:
  - fetchart
  - chroma
  - discogs
  - fromfilename
  # - beatport
  - convert
  - alternatives
  - info
  - types
  - web
  # - fuzzy

import:
  move: yes
  log: "/Volumes/2TB Iomega Data/Users/patrick/Music/beets/log/beets.log"

format_item: $added - $artist - $album - d:$disc/$disctotal--t:$track/$tracktotal - $title - $length - $format - $bitrate - $import_source - dj:$dj # - $path

sort_item: albumartist+ album+ disc+ track+

acoustid:
  apikey: xxxxx

convert:
  dest: ~/Music/beets-convert-test
  format: alac

alternatives:
  macbookpro:
    directory: /Volumes/live/Music/beets
    formats: alac mp3
    query: "import_source:vinyl , import_source:beatport , dj:True"
    removable: true
  plex:
    directory: "/Volumes/2TB Iomega Data/Users/patrick/Music/plex"
    formats: flac aac alac mp3
    query: ""

types:
  dj: bool

# match:
#   preferred:
#     media: ['Vinyl']
sampsyo commented 6 years ago

Thanks! Yes, this seems to be a problem with modify. The root problem is that changed is built up as a set: https://github.com/beetbox/beets/blob/1828114528e0459d5c60ed93a42bf4f165d054e4/beets/ui/commands.py#L1379

And then is directly used in the prompt: https://github.com/beetbox/beets/blob/1828114528e0459d5c60ed93a42bf4f165d054e4/beets/ui/commands.py#L1400-L1403

To preserve the order, the easiest fix might be just to make changed into a list instead (and append the objects in the order they're iterated over in the first loop).