From b2f9a3a474e9e761c382bad64e9f006adc7d607b Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 9 Jun 2021 00:43:29 +0530 Subject: Initial Commit * Working Media Player * Adds Album Art TODO: Adds Pagination --- plugin.retrowave.indrajith/addon.py | 57 ++++++++++++++++++++++++++ plugin.retrowave.indrajith/addon.xml | 35 ++++++++++++++++ plugin.retrowave.indrajith/resources/icon.png | Bin 0 -> 109947 bytes 3 files changed, 92 insertions(+) create mode 100644 plugin.retrowave.indrajith/addon.py create mode 100644 plugin.retrowave.indrajith/addon.xml create mode 100644 plugin.retrowave.indrajith/resources/icon.png (limited to 'plugin.retrowave.indrajith') diff --git a/plugin.retrowave.indrajith/addon.py b/plugin.retrowave.indrajith/addon.py new file mode 100644 index 0000000..ea0f558 --- /dev/null +++ b/plugin.retrowave.indrajith/addon.py @@ -0,0 +1,57 @@ +import os +import sys +import urllib +import xbmcaddon +import xbmc +import xbmcgui +import xbmcplugin +import requests +from urllib.parse import parse_qs, urlencode + + +def build_url(query): + base_url = sys.argv[0] + dialog = xbmcgui.Dialog() + dialog.notification('RetroWave Player', 'Base Url: '+base_url, xbmcgui.NOTIFICATION_INFO, 5000) + return base_url + '?' + urlencode(query) + + +def getMusicList(): + song_list = [] + URL = "http://retrowave.ru/api/v1/tracks" + PARAMS = {'cursor': 1, 'limit': 3} + r = requests.get(url=URL, params=PARAMS) + data = r.json() + for song in data['body']['tracks']: + li = xbmcgui.ListItem(label=song['title']) + li.setArt({'thumb': 'http://retrowave.ru/' + song['artworkUrl'], 'fanart': 'http://retrowave.ru/' + song['artworkUrl']}) + url = build_url({'mode': 'stream', 'url': 'http://retrowave.ru' + song['streamUrl'], 'title': song['title'], 'artwork': 'http://retrowave.ru/' + song['artworkUrl']}) + song_list.append((url, li, False)) + + xbmcplugin.addDirectoryItems(addon_handle, song_list, len(song_list)) + xbmcplugin.setContent(addon_handle, 'songs') + xbmcplugin.endOfDirectory(addon_handle) + +def play_song(url,title, artwork): + play_item = xbmcgui.ListItem(path=url,label=title) + play_item.setArt({'thumb': artwork, 'fanart': artwork}) + + dialog = xbmcgui.Dialog() + # dialog.notification('RetroWave Player', 'Mode: '+url, xbmcgui.NOTIFICATION_INFO, 5000) + # xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item) + xbmc.Player().play(item=url, listitem=play_item) + +def main(): + args = parse_qs(sys.argv[2][1:]) + mode = args.get('mode', None) + + if mode is None: + getMusicList() + elif mode[0] == 'stream': + dialog = xbmcgui.Dialog() + dialog.notification('RetroWave Player', 'Mode: '+args['title'][0], xbmcgui.NOTIFICATION_INFO, 5000) + play_song(args['url'][0], args['title'][0], args['artwork'][0]) + +if __name__ == '__main__': + addon_handle = int(sys.argv[1]) + main() diff --git a/plugin.retrowave.indrajith/addon.xml b/plugin.retrowave.indrajith/addon.xml new file mode 100644 index 0000000..4e6004c --- /dev/null +++ b/plugin.retrowave.indrajith/addon.xml @@ -0,0 +1,35 @@ + + + + + + + + + audio + + + Listen to Synthwave, Vaporwave Musics + + + + all + + + + + + + v0.0.1 (2021-08-06) + - Initial release + + + resources/icon.png + + + + + + + + diff --git a/plugin.retrowave.indrajith/resources/icon.png b/plugin.retrowave.indrajith/resources/icon.png new file mode 100644 index 0000000..e36d5f7 Binary files /dev/null and b/plugin.retrowave.indrajith/resources/icon.png differ -- cgit v1.2.3