Plugin: Pitchfork Album Reviews (looking for testers)

I’ve created a hacky plugin that grabs album reviews from Pitchfork, you can find it here: https://github.com/fortes/beets-pitchfork

To install, run:

pip install git+git://github.com/fortes/beets-pitchfork.git@master

And add pitchfork to your plugin list.

You can now add reviews via the pitchfork command, like this: beet pitchfork kendrick lamar (be nice to Pitchfork’s servers, and don’t try to query your entire library at once!)

The plugin adds the following flexible album attributes:

  • pitchfork_bnm: Whether the album was awarded “Best New Music”
  • pitchfork_description: Album abstract
  • pitchfork_score: Numeric score given by p4k
  • pitchfork_url: The URL to the review

The plugin uses the full album name & album artist name, which means matches are not always found. I’m not yet sure how to best fix this, so I’m open to ideas!

A help question from me: I’ve tried using %ifdef{pitchfork_score,$pitchfork_score} in format_album config, but it will output $pitchfork_score when the value isn’t present. What am I doing wrong?

4 Likes

Wow; this looks awesome! Nice work.

Your syntax for ifdef seems right, so this might be a beets bug. In fact, just %ifdef{pitchfork_score} should do it. Maybe something’s wrong with our implementation of the function?

Ah, looks like %ifdef{pitchfork_score} returns 0.0, which I can live with. Thanks.

Related: Is there anything like the inline plugin’s album_type for format_album?

Hmm, I’m not quite sure I understand—what’s the album_type you’re referring to? Is this something inline-specific?

Sorry, that’s a typo – I meant album_fields: https://beets.readthedocs.io/en/v1.4.7/plugins/inline.html#album-fields

It should be possible to use inline-defined album fields in format_album; sure.

Or perhaps you’re asking whether it’s possible to use template syntax to define new fields? Not currently, unfortunately, but it would be pretty cool…

Another stupid typo on my part, got it working now. Thanks!

1 Like

This is really cool! Any chance you might extend this plugin to support other websites, CritiqueBrainz for example?

Glad you liked it @reg, I’m open to adding other sites, however I haven’t really found much that has a lot of reviews and easy access. I looked at CritiqueBrainz, but it seems to have very few reviews.

I’d love to use rateyoumusic, but they don’t have an API and scraping is against their TOS

1 Like

I think this is awesome. Still in the process of importing my albums, but will let you know if I find any bugs.

1 Like

Regarding use of template syntax for fields, format_fields plugin might be of interest. I do think it’d be nice to provide the apply_template function to inline functions, though, so inline can explicitly evaluate a template.

I use it in combination with inline. A bit messy, might be cleaner to try to combine the two, but it works for now and avoids some duplication in my path formats.

Ex.:

format_fields:
  album_fields:
    incomplete: '%if{$tracktotal,%if{$missing,1,0},0}'

    # Used in path formats
    albumsdir: '%if{$tracktotal,%if{$missing,Incomplete ,}}Albums'
    album_directory_alldiscs: '%the{$album%aunique{}}$explicit_or_clean_album'
    _album_directory: '$album%aunique{}%if{$multidisc, Disc $trim_disc}%if{$disctitle,: $disctitle}$explicit_or_clean_album'
    albumartistdir: '%asciify{%first{$comp_albumartist}}'
   
    # Fallback from item for other contexts
    album_directory: '$album_directory_alldiscs'
  item_fields:
    # Used in path formats
    # singleton is an item field, not an album field, obviously..
    album_directory: '%if{$singleton,[non-album tracks],$album_directory_alldiscs}'
    full_title: '$title%ifdef{itunesadvisory,$explicit_or_clean}'
    comp_filename: '%if{$singleton,,$disc_and_track_pre}%if{$comp,$artist - $full_title,$full_title}'

alternatives:
  dap:
    default: '%if{$single_track,Single Tracks/$artist - $title,$albumsdir/$albumartistdir/$album_directory/$comp_filename}'

Agreed, I’m playing with this plugin now, thanks much @fortes.

1 Like

One thing you might add to the documentation is that you need to have an lxml parser installed. I was able to resolve errors with pip3 install lxml.

Looks good to me so far otherwise.

Strange, I don’t have lxml installed in my virtualenv at all, and I’m not getting any error but I’m on Linux. beets-pitchfork doesn’t call into lxml at all, maybe one of the dependencies does outside of Linux?

Here’s the error I get:

Error trying to get review: Couldn’t find a tree builder with the features you requested: lxml. Do you need to install a parser library?

Along with the error “Could not fetch review”

This is on Ubuntu Server 18.04. A more or less clean install, since all I do with it is mpd, icecast and beets.

Installing lxml resolved the issue, however. Are there other logs I can grab for you?

Hm, looks like this is an issue that some people hit with BeautifulSoup (which the pitchfork library used by beets-pitchfork uses): https://stackoverflow.com/questions/24398302/bs4-featurenotfound-couldnt-find-a-tree-builder-with-the-features-you-requeste/42151504