Exemple #1
0
def main_menu():
    """
    Displays main menu.
    """
    playable_url = get_stream_link()
    if playable_url == 0:
        commontasks.message(_prb_radio_not_broadcasting, _prb_radio_off_air)
        return 0
    # Live stream link
    addDir(_prb_radio, playable_url, 1, links_info[_prb_radio]['thumbs'],
           links_info[_prb_radio]['fanart'], links_info[_prb_radio]['desc'])
    if _hide_artist_info != 'true':
        # Artist information link
        addDir(_artist_info, playable_url, 2,
               links_info[_artist_info]['thumbs'],
               links_info[_artist_info]['fanart'],
               links_info[_artist_info]['desc'])
    if _hide_fav_songs != 'true':
        # Favorite Songs link
        addDir(_fav_songs,
               playable_url,
               3,
               links_info[_fav_songs]['thumbs'],
               links_info[_fav_songs]['fanart'],
               links_info[_fav_songs]['desc'],
               isFolder=True)
    # Settings link
    addDir(_settings, playable_url, 4, links_info[_settings]['thumbs'],
           links_info[_settings]['fanart'], links_info[_settings]['desc'])
    xbmcplugin.endOfDirectory(__handle__)
Exemple #2
0
def get_artist_name(artist=None):
    """
    Parse artist name or current stream title
    """
    if artist == None:
        # Check audio atream is playing
        if xbmc.Player().isPlayingAudio():
            # Get title of audio stream
            title = xbmc.Player().getMusicInfoTag().getTitle()
            if len(title) > 0:
                # Split artist name from stream title
                items = title.split(' - ')
                artist_name = items[0]
                if len(artist_name) > 1:
                    return artist_name
            else:
                # No artist name present
                commontasks.notification(_no_artist_name_present, _artist_info,
                                         __icon__, 5000)
        else:
            # No audio stream playing
            commontasks.message(_no_audio_stream, _artist_info)
    else:
        if len(artist) > 0:
            # Split artist name from artist
            items = artist.split(' - ')
            artist_name = items[0]
            if len(artist_name) > 1:
                return artist_name
    return None
Exemple #3
0
def _create_settings_xml(addon=None):
    # Copy the default settings xml file to userdata folder
    resources = xbmc.translatePath(
        os.path.join('special://home/addons/' + addon, 'resources'))
    if os.path.isfile(os.path.join(resources, 'settings.xml')):
        settings_file = os.path.join(resources, 'settings.xml')
        tree = et.parse(settings_file)
        root = tree.getroot()
        msg = ''
        new_root = et.Element('settings')
        for setting in root.iter('setting'):
            if setting.get('id') != None:
                if setting.get('default') != None:
                    et.SubElement(new_root,
                                  "setting",
                                  value=setting.get('default'),
                                  id=setting.get('id'))
                else:
                    et.SubElement(new_root,
                                  "setting",
                                  value="",
                                  id=setting.get('id'))
                msg += '%s=%s\n' % (setting.get('id'), setting.get('default'))
        new_tree = et.ElementTree(new_root)
        addon_data_dir = xbmc.translatePath(
            os.path.join('special://profile/addon_data', addon))
        new_tree.write(os.path.join(addon_data_dir, 'settings.xml'))
        commontasks.message(msg, "Create Settings XML")
Exemple #4
0
def add_fav_song():
    if xbmc.Player().isPlayingAudio():
        title = xbmc.Player().getMusicInfoTag().getTitle()
        if len(title) > 0:
            commontasks.write_to_file(__fav_songs_list__, title + '\n', True)
        xbmc.executebuiltin('Container.Refresh')
    else:
        commontasks.message(_no_audio_stream, _fav_songs)
Exemple #5
0
def set_media_source():
    # Set the root location of media files
    global __download_dir__
    msg = ''
    dialog = xbmcgui.Dialog()
    download_dir = dialog.browse(3, 'Media Source', 'files', '')
    __download_dir__ = download_dir
    if download_dir != '':
        __addon__.setSetting('set_media_source', download_dir)
        msg += _create_folders(stealth=True)
        msg += _set_media_source_paths()
        msg += _set_download_paths()
        msg = msg.replace(', \n', '.\n')
        commontasks.message(msg, 'Summary')
Exemple #6
0
def send_web_form(recursive=True):
    # Send the system info results to web form
    systeminfo_path = xbmc.translatePath(
        os.path.join('special://home/addons/'
                     'script.system-info/', 'resources/lib'))
    sendinfo = xbmc.translatePath(os.path.join(systeminfo_path, 'sendinfo.py'))
    if os.path.isfile(sendinfo):
        xbmc.executebuiltin(
            'XBMC.RunPlugin(plugin://script.system-info/?action=send)')
        commontasks.message('Form is being sent to PRB.', 'Send Form')
    else:
        if recursive == True:
            commontasks.install_addon('script.system-info')
            send_web_form(False)
def main_menu():
    """
    Displays main menu.
    """
    playable_url = get_stream_link()
    if playable_url == 0:
        commontasks.message(_prb_radio_not_broadcasting, _prb_radio_off_air)
        return 0
    # Live stream link
    addDir(name=_prb_radio,
           url=playable_url,
           mode=1,
           icon=links_info[_prb_radio]['thumbs'],
           fanart=links_info[_prb_radio]['fanart'],
           desc=links_info[_prb_radio]['desc'])
    if _hide_mixes != 'true':
        # Mixes link
        addDir(name=_mixes,
               url=playable_url,
               mode=8,
               icon=links_info[_mixes]['thumbs'],
               fanart=links_info[_mixes]['fanart'],
               desc=links_info[_mixes]['desc'],
               isFolder=True)
    if _hide_artist_info != 'true':
        # Artist information link
        addDir(name=_artist_info,
               url=playable_url,
               mode=2,
               icon=links_info[_artist_info]['thumbs'],
               fanart=links_info[_artist_info]['fanart'],
               desc=links_info[_artist_info]['desc'])
    if _hide_fav_songs != 'true':
        # Favorite Songs link
        addDir(name=_fav_songs,
               url=playable_url,
               mode=3,
               icon=links_info[_fav_songs]['thumbs'],
               fanart=links_info[_fav_songs]['fanart'],
               desc=links_info[_fav_songs]['desc'],
               isFolder=True)
    # Settings link
    addDir(name=_settings,
           url=playable_url,
           mode=4,
           icon=links_info[_settings]['thumbs'],
           fanart=links_info[_settings]['fanart'],
           desc=links_info[_settings]['desc'])
    xbmcplugin.endOfDirectory(__handle__)
Exemple #8
0
def _create_folders(stealth=False):
    # Create download folders on hard drive if not already there
    msg = ''
    if os.path.isdir(__download_dir__):
        for folder in __folders__:
            if os.path.isdir(__download_dir__ + folder) != True:
                msg += '[COLOR orange]%s[/COLOR], ' % folder
                os.mkdir(__download_dir__ + folder)
    if len(msg) > 0:
        msg = 'Created the following folders: %s\n' + msg
        if stealth == False:
            commontasks.message(msg, 'Folders Created')
    else:
        msg = '[COLOR green]Folders already exist[/COLOR] :)\n'
        if stealth == False:
            commontasks.message(msg, "Folders Present")
    return msg