ABrainz: Added copyright header, docstrings, and followed long line

standards.
This commit is contained in:
Ohm Patel 2015-12-30 22:27:53 -06:00
parent ff81bbf8f5
commit 29e6cbedfe

View file

@ -1,3 +1,20 @@
# -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
""" Fetch various AcousticBrainz metadata using MBID
"""
from __future__ import (division, absolute_import, print_function,
unicode_literals)
@ -7,7 +24,6 @@ import requests
ACOUSTIC_URL = "http://acousticbrainz.org/"
LEVEL = "/high-level"
PLUGIN_DESCRIPTION = "Fetch metadata from AcousticBrainz"
class AcousticPlugin(plugins.BeetsPlugin):
@ -15,7 +31,8 @@ class AcousticPlugin(plugins.BeetsPlugin):
super(AcousticPlugin, self).__init__()
def commands(self):
cmd = ui.Subcommand('acoustic', help=PLUGIN_DESCRIPTION)
cmd = ui.Subcommand('acoustic',
help="fetch metadata from AcousticBrainz")
def func(lib, opts, args):
fetch_info(lib)
@ -24,8 +41,9 @@ class AcousticPlugin(plugins.BeetsPlugin):
return [cmd]
# Currently outputs MBID and corresponding request status code
def fetch_info(lib):
"""Currently outputs MBID and corresponding request status code
"""
for item in lib.items():
if item.mb_trackid:
r = requests.get(generate_url(item.mb_trackid))
@ -33,6 +51,7 @@ def fetch_info(lib):
print(r.status_code)
# Generates url of AcousticBrainz end point for given MBID
def generate_url(mbid):
"""Generates url of AcousticBrainz end point for given MBID
"""
return ACOUSTIC_URL + mbid + LEVEL