Skip to content
Snippets Groups Projects
Commit bc7d0a04 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch 'initialRelease' into 'master'

Initial release

See merge request !1
parents 6a5519b8 41379668
No related branches found
No related tags found
1 merge request!1Initial release
The MIT License (MIT)
Copyright (c) 2018 Benoît Harrault
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# plugin.audio.fip # Fip Radio KODI Plugin
Listen to FIP radio streams
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.fip" name="Fip, an eclectic music radio" version="0.0.1" provider-name="Benoît Harrault">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides>audio</provides>
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<license>MIT</license>
<language>en</language>
<summary lang="en">Fip, an eclectic music radio</summary>
<description lang="en">Listen to fip french radio streams</description>
</extension>
</addon>
# https://docs.python.org/2.7/
import os
import sys
import urllib
import urlparse
# http://mirrors.kodi.tv/docs/python-docs/
import xbmcaddon
import xbmcgui
import xbmcplugin
def get_streams():
streams = {}
base_stream_url = 'https://direct.fipradio.fr/live/'
streams.update({
1: {
'title': 'fip',
'url': base_stream_url + 'fip-midfi.mp3?ID=radiofrance',
'album_cover': 'https://www.fip.fr/sites/default/files/fip-quadri-filet.png'
},
2: {
'title': 'fip / electro',
'url': base_stream_url + 'fip-webradio8.mp3?ID=radiofrance',
'album_cover': 'https://www.fip.fr/sites/default/files/asset/images/2017/05/webradio-electro-small.png'
},
3: {
'title': 'fip / groove',
'url': base_stream_url + 'fip-webradio3.mp3?ID=radiofrance',
'album_cover': 'https://www.fip.fr/sites/default/files/asset/images/2016/06/webradio-groove-small.png'
},
4: {
'title': 'fip / rock',
'url': base_stream_url + 'fip-webradio1.mp3?ID=radiofrance',
'album_cover': 'https://www.fip.fr/sites/default/files/asset/images/2016/06/webradio-rock-small.png'
}
})
return streams
def build_url(query):
base_url = sys.argv[0]
return base_url + '?' + urllib.urlencode(query)
def build_streams_list(streams):
stream_list = []
for stream in streams:
# create a list item using the stream filename for the label
li = xbmcgui.ListItem(
label=streams[stream]['title'], thumbnailImage=streams[stream]['album_cover'])
# set the fanart to the albumc cover
li.setProperty('fanart_image', streams[stream]['album_cover'])
# set the list item to playable
li.setProperty('IsPlayable', 'true')
# build the plugin url for Kodi
# Example: plugin://plugin.audio.example/?url=http%3A%2F%2Fwww.theaudiodb.com%2Ftestfiles%2F01-pablo_perez-your_ad_here.mp3&mode=stream&title=01-pablo_perez-your_ad_here.mp3
url = build_url({
'mode': 'stream',
'url': streams[stream]['url'],
'title': streams[stream]['title']
})
# add the current list item to a list
stream_list.append((url, li, False))
# add list to Kodi per Martijn
# http://forum.kodi.tv/showthread.php?tid=209948&pid=2094170#pid2094170
xbmcplugin.addDirectoryItems(addon_handle, stream_list, len(stream_list))
# set the content of the directory
xbmcplugin.setContent(addon_handle, 'songs')
xbmcplugin.endOfDirectory(addon_handle)
def play_stream(url):
play_item = xbmcgui.ListItem(path=url)
xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)
def main():
args = urlparse.parse_qs(sys.argv[2][1:])
mode = args.get('mode', None)
# initial launch of add-on
if mode is None:
streams = get_streams()
build_streams_list(streams)
# a stream from the list has been selected
elif mode[0] == 'stream':
# pass the url of the stream to play_stream
play_stream(args['url'][0])
if __name__ == '__main__':
addon_handle = int(sys.argv[1])
main()
icon.png 0 → 100644
icon.png

14.5 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment