diff --git a/readme.md b/readme.md index eceedb5..865b482 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/resources/language/resource.language.de_de/strings.po b/resources/language/resource.language.de_de/strings.po index 429f82a..c3feada 100644 --- a/resources/language/resource.language.de_de/strings.po +++ b/resources/language/resource.language.de_de/strings.po @@ -146,3 +146,11 @@ msgstr "In deinem Land nicht verfügbar" msgctxt "#30903" msgid "Preview" msgstr "Vorschau" + +msgctxt "#30904" +msgid "followers" +msgstr "Follower" + +msgctxt "#30905" +msgid "likes" +msgstr "Likes" diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 65836bc..6d99f97 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -146,3 +146,11 @@ msgstr "" msgctxt "#30903" msgid "Preview" msgstr "" + +msgctxt "#30904" +msgid "followers" +msgstr "" + +msgctxt "#30905" +msgid "likes" +msgstr "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index 9c7a797..31e82ac 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -145,3 +145,11 @@ msgstr "Niet beschikbaar in jouw land" msgctxt "#30903" msgid "Preview" msgstr "" + +msgctxt "#30904" +msgid "followers" +msgstr "volgers" + +msgctxt "#30905" +msgid "likes" +msgstr "" diff --git a/resources/lib/models/playlist.py b/resources/lib/models/playlist.py index fead064..5741c19 100644 --- a/resources/lib/models/playlist.py +++ b/resources/lib/models/playlist.py @@ -1,7 +1,10 @@ from resources.lib.models.list_item import ListItem import urllib.parse +import xbmcaddon import xbmcgui +likes = xbmcaddon.Addon().getLocalizedString(30905) + class Playlist(ListItem): thumb = "" @@ -11,12 +14,24 @@ 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\n{}".format( + self.info.get("artist"), + self.info.get("likes"), + likes, + self.info.get("description") or "" + ) diff --git a/resources/lib/models/track.py b/resources/lib/models/track.py index 7791a8e..f30e05e 100644 --- a/resources/lib/models/track.py +++ b/resources/lib/models/track.py @@ -26,6 +26,7 @@ def to_list_item(self, addon_base): "genre": self.info.get("genre"), "title": self.label, "year": self.info.get("date")[:4], + "playcount": self.info.get("playback_count"), "comment": self.info.get("description") }) list_item.setProperty("isPlayable", "true") diff --git a/resources/lib/models/user.py b/resources/lib/models/user.py index 52b9207..29ea6ec 100644 --- a/resources/lib/models/user.py +++ b/resources/lib/models/user.py @@ -1,8 +1,11 @@ from resources.lib.models.list_item import ListItem from resources.routes import * import urllib.parse +import xbmcaddon import xbmcgui +followers = xbmcaddon.Addon().getLocalizedString(30904) + class User(ListItem): thumb = "" @@ -11,12 +14,24 @@ 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{} {}\n\n{}".format( + self.label2 if self.label2 != "" else self.label, + self.info.get("followers"), + followers, + self.info.get("description") or "" + ) diff --git a/resources/lib/soundcloud/api_v2.py b/resources/lib/soundcloud/api_v2.py index f464610..37358a3 100644 --- a/resources/lib/soundcloud/api_v2.py +++ b/resources/lib/soundcloud/api_v2.py @@ -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) @@ -185,7 +186,9 @@ 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", ""), + "likes": item.get("likes_count", 0) } collection.items.append(playlist) @@ -251,7 +254,8 @@ def _build_track(self, item): "genre": item.get("genre", None), "date": item.get("display_date", None), "description": item.get("description", None), - "duration": int(item["duration"]) / 1000 + "duration": int(item["duration"]) / 1000, + "playback_count": item.get("playback_count", 0) } return track