Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add genre filters for charts #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ msgctxt "#30302"
msgid "New & hot"
msgstr "Neu und angesagt"

msgctxt "#30310"
msgid "Music genres"
msgstr "Musikgenres"

msgctxt "#30311"
msgid "Audio genres"
msgstr "Audio-Genres"

# GUI - Generic
msgctxt "#30901"
msgid "Next page"
Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ msgctxt "#30302"
msgid "New & hot"
msgstr ""

msgctxt "#30310"
msgid "Music genres"
msgstr ""

msgctxt "#30311"
msgid "Audio genres"
msgstr ""

# GUI - Generic
msgctxt "#30901"
msgid "Next page"
Expand Down
65 changes: 65 additions & 0 deletions resources/lib/kodi/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,71 @@ def charts(self):

return items

def charts_genres(self):
items = []

# Music genres
list_item = xbmcgui.ListItem(label=format_bold(self.addon.getLocalizedString(30310)))
url = self.addon_base + PATH_CHARTS + "?" + urllib.parse.urlencode({
"action": "top"
})
items.append((url, list_item, True))

# Audio genres
list_item = xbmcgui.ListItem(label=format_bold(self.addon.getLocalizedString(30311)))
url = self.addon_base + PATH_CHARTS + "?" + urllib.parse.urlencode({
"action": "trending"
})
items.append((url, list_item, True))

"""
alternativerock: n(51).t('Alternative Rock'),
ambient: n(51).t('Ambient'),
classical: n(51).t('Classical'),
country: n(51).t('Country'),
danceedm: n(51).t('Dance & EDM'),
dancehall: n(51).t('Dancehall'),
deephouse: n(51).t('Deep House'),
disco: n(51).t('Disco'),
drumbass: n(51).t('Drum & Bass'),
dubstep: n(51).t('Dubstep'),
electronic: n(51).t('Electronic'),
folksingersongwriter: n(51).t('Folk & Singer-Songwriter'),
hiphoprap: n(51).t('Hip-hop & Rap'),
house: n(51).t('House'),
indie: n(51).t('Indie'),
jazzblues: n(51).t('Jazz & Blues'),
latin: n(51).t('Latin'),
metal: n(51).t('Metal'),
piano: n(51).t('Piano'),
pop: n(51).t('Pop'),
rbsoul: n(51).t('R&B & Soul'),
reggae: n(51).t('Reggae'),
reggaeton: n(51).t('Reggaeton'),
rock: n(51).t('Rock'),
soundtrack: n(51).t('Soundtrack'),
speech: n(51).t('Speech'),
techno: n(51).t('Techno'),
trance: n(51).t('Trance'),
trap: n(51).t('Trap'),
triphop: n(51).t('Triphop'),
world: n(51).t('World'),
audiobooks: n(51).t('Audiobooks'),
business: n(51).t('Business'),
comedy: n(51).t('Comedy'),
entertainment: n(51).t('Entertainment'),
learning: n(51).t('Learning'),
newspolitics: n(51).t('News & Politics'),
religionspirituality: n(51).t('Religion & Spirituality'),
science: n(51).t('Science'),
sports: n(51).t('Sports'),
storytelling: n(51).t('Storytelling'),
technology: n(51).t('Technology')
},
"""

return items

def from_collection(self, collection):
items = []

Expand Down
2 changes: 2 additions & 0 deletions resources/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def run():
xbmcplugin.addDirectoryItems(handle, items, len(items))
xbmcplugin.endOfDirectory(handle)
else:
items = listItems.charts_genres()
api_result = api.charts({"kind": action, "genre": genre, "limit": 50})
collection = listItems.from_collection(api_result)
xbmcplugin.addDirectoryItems(handle, items, len(items))
xbmcplugin.addDirectoryItems(handle, collection, len(collection))
xbmcplugin.endOfDirectory(handle)

Expand Down