commit
d2f6a1205d
|
@ -1,4 +1,4 @@
|
|||
# top-most EditorConfig file
|
||||
# Top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
|
@ -7,7 +7,13 @@ end_of_line = lf
|
|||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
# 4 space indentation
|
||||
# Four-space indentation
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# Two-space indentation
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
|
|
@ -18,7 +18,7 @@ env:
|
|||
- TOXENV=pypy3
|
||||
sudo: false
|
||||
install:
|
||||
- travis_retry pip install tox
|
||||
- travis_retry pip install tox==2.1.1
|
||||
- travis_retry pip install coveralls
|
||||
script: tox
|
||||
after_success:
|
||||
|
|
|
@ -1809,8 +1809,21 @@ class _Opus(_BaseObject, _Taggable):
|
|||
def get_mbid(self):
|
||||
"""Returns the MusicBrainz ID of the album or track."""
|
||||
|
||||
return _extract(
|
||||
self._request(self.ws_prefix + ".getInfo", cacheable=True), "mbid")
|
||||
doc = self._request(self.ws_prefix + ".getInfo", cacheable=True)
|
||||
|
||||
try:
|
||||
lfm = doc.getElementsByTagName('lfm')[0]
|
||||
opus = self._get_children_by_tag_name(lfm, self.ws_prefix).next()
|
||||
mbid = self._get_children_by_tag_name(opus, "mbid").next()
|
||||
return mbid.firstChild.nodeValue
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
def _get_children_by_tag_name(self, node, tag_name):
|
||||
for child in node.childNodes:
|
||||
if (child.nodeType == child.ELEMENT_NODE and
|
||||
(tag_name == '*' or child.tagName == tag_name)):
|
||||
yield child
|
||||
|
||||
|
||||
class Album(_Opus):
|
||||
|
@ -1844,9 +1857,9 @@ class Album(_Opus):
|
|||
def get_tracks(self):
|
||||
"""Returns the list of Tracks on this album."""
|
||||
|
||||
uri = 'lastfm://playlist/album/%s' % self.get_id()
|
||||
|
||||
return XSPF(uri, self.network).get_tracks()
|
||||
return _extract_tracks(
|
||||
self._request(
|
||||
self.ws_prefix + ".getInfo", cacheable=True), "tracks")
|
||||
|
||||
def get_url(self, domain_name=DOMAIN_ENGLISH):
|
||||
"""Returns the URL of the album or track page on the network.
|
||||
|
|
|
@ -1972,5 +1972,15 @@ class TestPyLast(unittest.TestCase):
|
|||
# Assert
|
||||
self.assertEqual(corrected_track_name, "Mr. Brownstone")
|
||||
|
||||
def test_track_with_no_mbid(self):
|
||||
# Arrange
|
||||
track = pylast.Track("Static-X", "Set It Off", self.network)
|
||||
|
||||
# Act
|
||||
mbid = track.get_mbid()
|
||||
|
||||
# Assert
|
||||
self.assertEqual(mbid, None)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(failfast=True)
|
||||
|
|
Loading…
Reference in a new issue