Skip to content

Commit

Permalink
Display correct user and playlist info
Browse files Browse the repository at this point in the history
Fixes #63
  • Loading branch information
jaylinski committed Mar 20, 2024
1 parent 5c0d308 commit b3ab69c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This add-on uses [Pipenv](https://pypi.org/project/pipenv/) to manage its depend

### Setup

[Install Pipenv](https://pipenv.readthedocs.io/en/latest/install/#installing-pipenv) and run `pipenv install --dev`.
[Install Pipenv](https://pipenv.pypa.io/en/latest/installation.html#installing-pipenv) and run `pipenv install --dev`.

### Build

Expand Down
14 changes: 12 additions & 2 deletions resources/lib/models/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ class Playlist(ListItem):
def to_list_item(self, addon_base):
list_item = xbmcgui.ListItem(label=self.label, label2=self.label2)
list_item.setArt({"thumb": self.thumb})
list_item.setInfo("music", {
"title": self.label
list_item.setIsFolder(True)
list_item.setProperty("isPlayable", "false")
# We have to use the `video`-type in order to display a proper folder description
list_item.setInfo("video", {
"plot": self._get_description()
})

url = addon_base + "/?" + urllib.parse.urlencode({
"action": "call",
"call": "/playlists/{id}".format(id=self.id)
})

return url, list_item, True

def _get_description(self):
return "{}\n\n{}".format(
self.info.get("artist"),
self.info.get("description") or ""
)
15 changes: 13 additions & 2 deletions resources/lib/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ class User(ListItem):
def to_list_item(self, addon_base):
list_item = xbmcgui.ListItem(label=self.label, label2=self.label2)
list_item.setArt({"thumb": self.thumb})
list_item.setInfo("music", {
"title": self.info.get("description")
list_item.setIsFolder(True)
list_item.setProperty("isPlayable", "false")
# We have to use the `video`-type in order to display a proper folder description
list_item.setInfo("video", {
"plot": self._get_description()
})

url = addon_base + PATH_USER + "?" + urllib.parse.urlencode({
"id": self.id,
"call": "/users/{id}/tracks".format(id=self.id)
})

return url, list_item, True

def _get_description(self):
return "{}\n{} followers\n\n{}".format(
self.label2 if self.label2 != "" else self.label,
self.info.get("followers"),
self.info.get("description") or ""
)
6 changes: 4 additions & 2 deletions resources/lib/soundcloud/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def _map_json_to_collection(self, json_obj):
user.label2 = item.get("full_name", "")
user.thumb = self._get_thumbnail(item, self.thumbnail_size)
user.info = {
"artist": item.get("description", None)
"description": item.get("description", ""),
"followers": item.get("followers_count", 0)
}
collection.items.append(user)

Expand All @@ -185,7 +186,8 @@ def _map_json_to_collection(self, json_obj):
playlist.label2 = item.get("label_name", "")
playlist.thumb = self._get_thumbnail(item, self.thumbnail_size)
playlist.info = {
"artist": item["user"]["username"]
"artist": item["user"]["username"],
"description": item.get("description", ""),
}
collection.items.append(playlist)

Expand Down

0 comments on commit b3ab69c

Please sign in to comment.