Skip to content

Commit

Permalink
fix favorites endpoint, add previous & next songs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir Elbaz authored and Nir Elbaz committed Oct 8, 2016
1 parent 6dbef00 commit 0a4b1ae
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 26 deletions.
23 changes: 13 additions & 10 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ def update_artwork(channel, recent_tracks_url):
last_album_cover = ''

# update now playing fanart, channel name & description:
artwork.overlay.setImage('{0}{1}'.format(config['urls']['calm_blurred_arts_host'], channel['image']))
artwork.channel.setLabel('[B]' + channel['title'] + '[/B]')
artwork.description.setText(channel['description'])
artwork.show()
Expand All @@ -319,16 +318,20 @@ def update_artwork(channel, recent_tracks_url):
artwork.album.setLabel('[B]Album[/B]: ' + (recent_tracks['now_playing']['album']
if recent_tracks['now_playing']['album'] else 'N/A'))
artwork.artist.setLabel('[B]Artist[/B]: ' + recent_tracks['now_playing']['artist'])
# next track:
artwork.next_1.setLabel('- [B]{0}[/B] by {1}'.format(
recent_tracks['next_playing']['title'], recent_tracks['next_playing']['artist']
))
# recent tracks:
# artwork.recent_1.setLabel('[B]{0}[/B] by {1}'.format(
# recent_tracks['recently_played'][0]['title'], recent_tracks['recently_played'][0]['artist']
# ))
# artwork.recent_2.setLabel('[B]{0}[/B] by {1}'.format(
# recent_tracks['recently_played'][1]['title'], recent_tracks['recently_played'][1]['artist']
# ))
# artwork.recent_3.setLabel(' - [B]{0}[/B] by {1}'.format(
# recent_tracks['recently_played'][2]['title'], recent_tracks['recently_played'][2]['artist']
# ))
artwork.recent_1.setLabel('- [B]{0}[/B] by {1}'.format(
recent_tracks['recently_played'][0]['title'], recent_tracks['recently_played'][0]['artist']
))
artwork.recent_2.setLabel('- [B]{0}[/B] by {1}'.format(
recent_tracks['recently_played'][1]['title'], recent_tracks['recently_played'][1]['artist']
))
artwork.recent_3.setLabel('- [B]{0}[/B] by {1}'.format(
recent_tracks['recently_played'][2]['title'], recent_tracks['recently_played'][2]['artist']
))
sleep(5000)

log('Artwork closed')
Expand Down
6 changes: 3 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.calmradio" name="Calm Radio" version="0.2.3" provider-name="Nir Elbaz">
<addon id="plugin.audio.calmradio" name="Calm Radio" version="0.2.6" provider-name="Nir Elbaz">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.requests" version="2.9.1"/>
<import addon="script.module.routing" version="0.2.0"/>
</requires>
Expand All @@ -19,4 +19,4 @@
<email>support@calmradio.com</email>
<source>https://github.com/nire0510/plugin.audio.calmradio</source>
</extension>
</addon>
</addon>
26 changes: 17 additions & 9 deletions artwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ def __init__(self):
self.setCoordinateResolution(0) # 1920x1080

# overlay
self.overlay = xbmcgui.ControlImage(0, 0, 1920, 1080,
'special://home/addons/plugin.audio.calmradio/resources/media/000000-0.8.png')
clouds = xbmcgui.ControlImage(0, 0, 1920, 1080,
'special://home/addons/plugin.audio.calmradio/fanart.jpg')

overlay = xbmcgui.ControlImage(0, 0, 1920, 1080,
'special://home/addons/plugin.audio.calmradio/resources/media/000000-0.5.png')

# top bar
topbar = xbmcgui.ControlImage(0, 0, 1920, 100,
Expand All @@ -29,13 +32,17 @@ def __init__(self):
self.channel = xbmcgui.ControlLabel(810, 160, 1060, 30, 'Channel Name', textColor='0xff18b0e2')

# channel description
self.description = xbmcgui.ControlTextBox(810, 200, 1060, 800, 'Channel Description')
self.description = xbmcgui.ControlTextBox(810, 200, 1060, 350, 'Channel Description')

# next song
next = xbmcgui.ControlLabel(810, 580, 950, 30, '[B]Next Song:[/B]')
self.next_1 = xbmcgui.ControlLabel(810, 630, 950, 30, 'Song 1', textColor='0xffcccccc', font='font12')

# recent songs
# recent = xbmcgui.ControlLabel(840, 730, 950, 30, '[B]Recent Songs:[/B]')
# self.recent_1 = xbmcgui.ControlLabel(840, 860, 950, 30, 'Song 1')
# self.recent_2 = xbmcgui.ControlLabel(840, 890, 950, 30, 'Song 2')
# self.recent_3 = xbmcgui.ControlLabel(840, 920, 950, 30, 'Song 3')
recent = xbmcgui.ControlLabel(810, 710, 950, 30, '[B]Recent Songs:[/B]')
self.recent_1 = xbmcgui.ControlLabel(810, 760, 950, 30, 'Song 1', textColor='0xffcccccc', font='font12')
self.recent_2 = xbmcgui.ControlLabel(810, 800, 950, 30, 'Song 2', textColor='0xffcccccc', font='font12')
self.recent_3 = xbmcgui.ControlLabel(810, 840, 950, 30, 'Song 3', textColor='0xffcccccc', font='font12')

self.btn_volume = xbmcgui.ControlButton(1760, 20, 60, 60, '',
focusTexture='special://home/addons/plugin.audio.calmradio/resources/media/volume.png',
Expand Down Expand Up @@ -86,8 +93,9 @@ def __init__(self):
# artist
self.artist = xbmcgui.ControlLabel(70, 975, 660, 30, 'Artist Name', font='font12')
# add all controls:
self.addControls((self.overlay, topbar, calmradio, self.channel, self.description,
# recent, self.recent_1, self.recent_2, self.recent_3,
self.addControls((clouds, overlay, topbar, calmradio, self.channel, self.description,
next, self.next_1,
recent, self.recent_1, self.recent_2, self.recent_3,
self.btn_mute, self.btn_volume, self.btn_close,
cover_shadow, spinner, self.cover, self.song, self.album, self.artist))

Expand Down
12 changes: 11 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
v0.2.6
- Fix favorites API endpoint
- Add previous and next songs

v0.2.5
- fix missing bg image bug

-v0.2.4
- add verify flag to requests

v0.2.3
- set default bit rate to 128kb for non registered users
- set default bit rate to 128kb

v0.2.2
- rename categories and sub categories to sections and categories
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'calm_blurred_arts_host': 'http://calmradio.com/kodi/blurred',
'calm_auth_api': 'https://api.calmradio.com/get_token?user={0}&pass={1}',
'calm_sua_api': 'http://api.calmradio.com/check?user={0}&pass={1}',
'calm_favorites_api': 'http://test.calmradio.com/player/favorites.php?login={0}&token={1}&action={2}&id={3}'
'calm_favorites_api': 'http://calmradio.com/player/favorites.php?login={0}&token={1}&action={2}&id={3}'
},
'viewmodes': {
'thumbnail': {
Expand Down
Binary file added resources/media/000000-0.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def __init__(self):
self.token = None

@staticmethod
def get_json(url):
r = requests.get(url)
def get_json(url, verify=False):
r = requests.get(url, verify=verify)
if r.status_code == 200:
return json.loads(r.text)

Expand Down

0 comments on commit 0a4b1ae

Please sign in to comment.