-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AcousticBrainz Plugin #1784
AcousticBrainz Plugin #1784
Changes from 1 commit
ff81bbf
29e6cbe
9daa02b
59a1333
ed6d908
d15d7ef
bcd4c6d
6183095
fdd1534
ff89716
5201e1c
6337b7f
fa90393
ad57943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import (division, absolute_import, print_function, | ||
unicode_literals) | ||
|
||
|
||
from beets import plugins, ui | ||
import requests | ||
|
||
ACOUSTIC_URL = "http://acousticbrainz.org/" | ||
LEVEL = "/high-level" | ||
PLUGIN_DESCRIPTION = "Fetch metadata from AcousticBrainz" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think most of the help text in beets starts with a lower-case letter. |
||
|
||
|
||
class AcousticPlugin(plugins.BeetsPlugin): | ||
def __init__(self): | ||
super(AcousticPlugin, self).__init__() | ||
|
||
def commands(self): | ||
cmd = ui.Subcommand('acoustic', help=PLUGIN_DESCRIPTION) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The usual way to format long lines like this is to wrap inside the parentheses. For example: cmd = ui.Subcommand('acoustic',
help='...') or: cmd = ui.Subcommand(
'acoustic',
help='...',
) rather than using a constant. |
||
|
||
def func(lib, opts, args): | ||
fetch_info(lib) | ||
|
||
cmd.func = func | ||
return [cmd] | ||
|
||
|
||
# Currently outputs MBID and corresponding request status code | ||
def fetch_info(lib): | ||
for item in lib.items(): | ||
if item.mb_trackid: | ||
r = requests.get(generate_url(item.mb_trackid)) | ||
print(item.mb_trackid) | ||
print(r.status_code) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a hint for the next step, you can get the data from the response with |
||
|
||
|
||
# Generates url of AcousticBrainz end point for given MBID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Python, these per-function (or per-class) comments can actually be docstrings (worth a google). For example: def generate_url(mbid):
"""Generate the URL of the AcousticBrainz end point for given MBID.
"""
return ACOUSTIC_URL + mbid + LEVEL |
||
def generate_url(mbid): | ||
return ACOUSTIC_URL + mbid + LEVEL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will (eventually) need the standard comment header found at the top of all the files in the tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 29e6cbe