Skip to content

Commit

Permalink
Add getReleaseMetadata and modify _getMetadata
Browse files Browse the repository at this point in the history
_getMetadata got changed so that it works with a release
without specifying a discid
getReleaseData is used in mblookup

[Fixes whipper-team#251]
Signed-off-by: ABCbum <[email protected]>
  • Loading branch information
ABCbum committed Dec 14, 2019
1 parent 31d589b commit 95108f3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions whipper/common/mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _getWorks(recording):
return works


def _getMetadata(release, discid, country=None):
def _getMetadata(release, discid=None, country=None):
"""
:type release: dict
:param release: a release dict as returned in the value for key release
Expand Down Expand Up @@ -220,7 +220,7 @@ def _getMetadata(release, discid, country=None):
# only show discs from medium-list->disc-list with matching discid
for medium in release['medium-list']:
for disc in medium['disc-list']:
if disc['id'] == discid:
if discid is None or disc['id'] == discid:
title = release['title']
discMD.releaseTitle = title
if 'disambiguation' in release:
Expand Down Expand Up @@ -274,6 +274,19 @@ def _getMetadata(release, discid, country=None):
# see http://bugs.musicbrainz.org/browser/python-musicbrainz2/trunk/examples/
# ripper.py

def getReleaseMetadata(release_id):
import musicbrainzngs

musicbrainzngs.set_useragent("whipper", whipper.__version__,
"https://github.com/whipper-team/whipper")
release = musicbrainzngs.get_release_by_id(
release_id, includes=["artists", "artist-credits",
"recordings", "discids",
"labels", "recording-level-rels",
"work-rels", "release-groups"])
releaseDetail = release['release']
return _getMetadata(releaseDetail)


def musicbrainz(discid, country=None, record=False):
"""
Expand Down

0 comments on commit 95108f3

Please sign in to comment.