Repository: beetbox/beets

Issue:
lastgenre: `force` config option doesn’t work
### Problem

I want to write the popular genres from Last.fm in the metatags of my music.

I have the following configuration:

```
lastgenre:
    whitelist: no
    count: 5
    fallback: nogenre
    min_weight: 20
    source: track
    force: yes
```

Now I run "beets lastgenre"

Other than what I had expected that beets would now write the 5 most popular genres into each file, it just outputs with (keep) and doesn't change anything to the genre metatag...

What could be going wrong here and how can I fix this?

Thanks a lot for any help!



Discussion:
Hello! When you report a problem, it *really* helps us if you use the issue template. I know it looks like a lot of extra information, but actually including the verbose output from running the command and your versions can help us understand what's happening.
Today I stumbled across the same problem - so I am trying to fill the issue template

### Problem

Even though I added lastgenre with `force: yes` inside my config.yaml (which should than overwrite the genreas from what I understood from the docs) running lastgenre results in `keep`.

I did re-run it for a single album and it always procudes the same output - `keep`
The album (or better each track) ist currently having the genre `metalcore` - re-running I would asume changing it to the correct `Metalcore`

Running this command in verbose (`-vv`) mode:

```sh
$ beet -vv lastgenre albumartist:"Integrity" album:"The Blackest Curse"
```
```
user configuration: /Users/k/.config/beets/config.yaml
data directory: /Users/k/.config/beets
plugin paths:
Sending event: pluginload
library database: /Users/k/.config/beets/library.db
library directory: /Volumes/music
Sending event: library_opened
lastgenre: genre for album Integrity - The Blackest Curse (keep): metalcore
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: write
zero: comments:  -> None
Sending event: after_write
Sending event: cli_exit
```

Led to this problem:

```
lastgenre: genre for album Integrity - The Blackest Curse (keep): metalcore
```

### Setup

* OS: 10.13.5
* Python version: 3.6.5
* beets version: 1.4.7
* Turning off plugins made problem go away (yes/no): no - to be more precise I turned off all others plugins than lastgenre - obviously ;-)

My configuration (output of `beet config`) is:

```yaml
directory: /Volumes/music/

paths:
    default: $albumartist/$album/%if{$disc == 0 && $totaldisc == 1, 01, $disc} - $track - $title
    comp: Compilations/$album/%if{$disc == 0 && $totaldisc == 1, 01, $disc} - $track - $title

ignore: ['Ringtones', '#recycle', '.*', '*~', 'System Volume Information', 'lost+found', '.m4r']

format_item: ($format) $artist - $album - $track - $title

clutter: ['Thumbs.db', '.DS_Store', '*.m3u', '*.pls', '*.nfo', '*.sfv', '*.jpg', '*.jpeg', '*.png', '*.url', '*.URL', '*.txt', '*.ini']

import:
    copy: no
    write: yes
    move: yes

plugins: [discogs, bandcamp, fetchart, embedart, chroma, zero, scrub, duplicates, missing, edit, lastgenre]

bandcamp:
    art: true

fetchart:
    cautious: true
    minwidth: 200
    maxwidth: 200
    enforce_ratio: yes
    sources: [filesystem, bandcamp, coverart, amazon, albumart, wikipedia, google]

zero:
    fields: comments
    update_database: true

lastgenre:
    source: album
    count: 10
    force: yes
    canonical: '~/Documents/git/india.kimpenhaus.home/beets/genres-tree.yaml'
    whitelist: '~/Documents/git/india.kimpenhaus.home/beets/genres.txt'
    prefer_specific: yes
    min_weight: 20
    fallback: ''
    separator: ';'

missing:
    format: $albumartist - $album - $title
    count: no
    total: no

edit:
    itemfields: [track, title, artist, albumartist, album, genre]

```
If you need more detailed info I will gladly provide.
Thanks!
Awesome! Thank you for all the extra detail.

To confirm a suspicion, can you please try using the command-line flag equivalent (that is, use the `-f` flag to the `lastgenre` command)? I’m guessing that will work. We probably need to remove the default parameter on this line:
https://github.com/beetbox/beets/blob/a62e4eff8c15f7ab67f082e7e0985f96266e6c48/beetsplug/lastgenre/__init__.py#L367
You're a beast 😄 That worked!

![grafik](https://user-images.githubusercontent.com/575109/41744381-e9e02512-75a3-11e8-98e8-e53a1cc5a9bb.png)


Great!! This should be an easy fix. (I’m away from a computer right now, so anyone reading this thread is welcome to take credit for the necessary one-line change.)

Resolving patch:
diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py
--- a/beetsplug/lastgenre/__init__.py
+++ b/beetsplug/lastgenre/__init__.py
@@ -373,7 +373,7 @@ def commands(self):
         lastgenre_cmd = ui.Subcommand('lastgenre', help=u'fetch genres')
         lastgenre_cmd.parser.add_option(
             u'-f', u'--force', dest='force',
-            action='store_true', default=False,
+            action='store_true',
             help=u're-download genre when already present'
         )
         lastgenre_cmd.parser.add_option(


Test patch: