diff --git a/README.rst b/README.rst index 7b339b3..7c1eed5 100644 --- a/README.rst +++ b/README.rst @@ -93,6 +93,15 @@ Note: Adding an artist by clicking on the artist in a search result or by manual bandcamp page can take a long time depending on the artist. This is because Mopidy-Bandcamp tries to load the entirety of the artist's discography. +Mopidy-Bandcamp also supports bndcmpr.co playlists. Just get the playlist id from the bndcmpr url, prepend with +"bandcamp:bndcmpr" and add it to Mopidy. For example, to add this bndcmpr playlist "https://bndcmpr.co/4dfdd589" +using mpc on the command line: + +.. code:: shell + + $ mpc add "bandcamp:bndcmpr:4dfdd589" + +Would add all the tracks in the bndcmpr playlist to the queue. Web Client ---------- @@ -107,7 +116,8 @@ as a URL for a bookmark in your web browser: Note: Replace *hostname* and *6680* with your mopidy server's hostname and configured HTTP port. -Now when you're browsing bandcamp you can simply click that bookmark to add the current page to Mopidy. +Now when you're browsing bandcamp (or a bndcmpr playlist) you can simply click that bookmark to add the +current page to Mopidy. (This works in Chrome and Firefox. I haven't bothered checking anything else.) Configuration diff --git a/mopidy_bandcamp/library.py b/mopidy_bandcamp/library.py index 6a6b858..d0c0f1e 100644 --- a/mopidy_bandcamp/library.py +++ b/mopidy_bandcamp/library.py @@ -1,7 +1,10 @@ import datetime import hashlib +import json import re +from concurrent.futures.thread import ThreadPoolExecutor + from mopidy import backend from mopidy.models import Album, Artist, Image, Ref, SearchResult, Track from urllib.parse import quote @@ -295,6 +298,14 @@ def lookup(self, uri): f"bandcamp:track:{disc['band_id']}-0-{disc['item_id']}" ) ) + elif func == "bndcmpr": + bndcmpr_raw = self.backend.bandcamp._get(f"https://bndcmpr.co/api/list/{bcId}") + bndcmpr_tracks = json.loads(bndcmpr_raw["tracks"].encode().decode()) + bndcmpr_uris = [f'bandcamp:{track["url"]}' for track in bndcmpr_tracks] + with ThreadPoolExecutor(4) as executor: + futures = executor.map(self.lookup, bndcmpr_uris) + [ret.extend(value) for value in futures if value is not None] + return ret elif re.match(r"^https?", func, re.I): url = uri[9:] try: diff --git a/mopidy_bandcamp/web.py b/mopidy_bandcamp/web.py index 815845b..7ac72c4 100644 --- a/mopidy_bandcamp/web.py +++ b/mopidy_bandcamp/web.py @@ -15,6 +15,11 @@ def get(self): self.write( "
Invalid URL: "%s"
"