Esempio n. 1
0
def CatMenu(source):
    m3uread = m3uRegex(source)
    m3udata = m3uread.EpgRegex()
    f = open(m3udata_json, 'w')
    f.write(m3udata)
    f.close()
    m = m3u(m3udata)
    del m3udata
    for cat in m.get_categories():
        if len(cat) == 2:
            for k, v in iso_info.items():
                if v.get('alpha2') == cat:
                    name = v.get('name')
                    break
                else:
                    name = cat
        else:
            name = cat
        hidden_cats = json.load(
            open(customiser_json)).get('hidden_category').keys()
        if not ''.join(name.lower().split()) in hidden_cats:
            addDir(name,
                   cat,
                   2,
                   addon_icon,
                   addon_fanart,
                   'Categories',
                   addcontext=['hide_cat'])
Esempio n. 2
0
def MainMenu():
    addDir('Build Menu',
           '',
           1,
           addon_icon,
           addon_fanart,
           local_string(30001),
           isFolder=True)
    addDir('Maintenance',
           '',
           5,
           addon_icon,
           addon_fanart,
           local_string(30002),
           isFolder=True)
    addDir('Fresh Start',
           '',
           4,
           addon_icon,
           addon_fanart,
           local_string(30003),
           isFolder=False)
    addDir('Notification',
           '',
           100,
           addon_icon,
           addon_fanart,
           'Bring up the notifications dialog',
           isFolder=False)
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Esempio n. 3
0
def subMenu_maintenance():
    addDir('Clear Packages',
           '',
           6,
           addon_icon,
           addon_fanart,
           local_string(30005),
           isFolder=False)
    addDir('Clear Thumbnails',
           '',
           7,
           addon_icon,
           addon_fanart,
           local_string(30008),
           isFolder=False)
    addDir('Advanced Settings',
           '',
           8,
           addon_icon,
           addon_fanart,
           local_string(30009),
           isFolder=False)
    addDir('Full wipe',
           '',
           9,
           addon_icon,
           addon_fanart,
           local_string(30010),
           isFolder=False)

    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Esempio n. 4
0
def ChannelMenu(cname):
    f = open(m3udata_json, 'r')
    m3udata = f.read()
    f.close()
    m = m3u(m3udata)
    for channel in m.get_catlist(cname):
        keyid = list(channel.keys())
        c = channel.get(keyid[0])
        hidden_chan = json.load(
            open(customiser_json)).get('hidden_channel').keys()
        if not c.get('tvg_id') in hidden_chan:
            addDir(c.get('channel_name', 'Unknown'),
                   c.get('stream_url', ''),
                   3,
                   c.get('tvg_logo', addon_icon),
                   addon_fanart,
                   'Channels',
                   isFolder=False,
                   channeldata=c,
                   addcontext=['hide_chan', 'add_fav_chan'])
Esempio n. 5
0
def BuildMenu():
    req = Request(buildfile, headers = headers)
    response = urlopen(req).read()
    try:
    	builds = json.loads(response)['builds']
    	for build in builds:
    		name = (build.get('name', ''))
    		version = (build.get('version', '0'))
    		url = (build.get('url', ''))
    		icon = (build.get('icon', addon_icon))
    		fanart = (build.get('fanart', addon_fanart))
    		description = (build.get('description', 'No Description Available.'))
    		if url.endswith('.zip'):
    			addDir(name + ' Version ' + version,url,3,icon,fanart,description,name2=name,version=version,isFolder=False)
    		else:
    			addDir('Invalid build URL. Please contact the build creator.','','','','','',isFolder=False)
    		
    except:
    	builds = ET.fromstring(response)
    	for build in builds.findall('build'):
    		try:
    			name = build.get('name')
    		except:
    			name = ''
    		try:
    			version = build.find('version').text
    		except:
    			version = 0
    		try:
    			url = build.find('url').text
    		except:
    			url = ''
    		try:
    			icon = build.find('icon').text
    		except:
    			icon = addon_icon
    		try:
    			fanart = build.find('fanart').text
    		except:
    			fanart = addon_fanart
    		try:
    			description = build.find('description').text
    		except:
    			description = 'No Description Available.'
    		if url.endswith('.zip'):
    			addDir(name + ' Version ' + version,url,3,icon,fanart,description,name2=name,version=version,isFolder=False)
    		else:
    			addDir('Invalid build URL. Please contact the build creator.','','','','','',isFolder=False)
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Esempio n. 6
0
def MainMenu():
    for s in m3usources:
        url = s.get('url')
        if UrlValidator(url):
            statuslabel = '[COLOR green]Online[/COLOR]'
        else:
            statuslabel = '[COLOR red]Offline[/COLOR]'
        img = s.get('icon') if s.get('icon') else addon_icon
        addDir(s.get("name"), url, 1, img, addon_fanart, statuslabel)
    addDir(local_string(32000), '', 4, icon_search, addon_fanart,
           local_string(32004))
    addDir(local_string(32001), '', 5, icon_fav, addon_fanart,
           local_string(32005))
    addDir(local_string(32002), '', 6, icon_recent, addon_fanart,
           local_string(32006))
    addDir(local_string(32003),
           '',
           7,
           icon_settings,
           addon_fanart,
           local_string(32007),
           isFolder=False)
Esempio n. 7
0
def RecentPlayedMenu(name):
    with open(recentplayed_json, 'r') as f:
        data = json.load(f)
        played = data.get('played')
        if len(played) > 0:
            for k, v in sorted(played.items(), reverse=True):
                for k1, v1 in v.items():
                    if k1 == 'timestamp':
                        dt = Timestamp_Region_dt(v1)
                    else:
                        c = v1
                addDir(f"{c.get('channel_name')} last played({dt})",
                       c.get('stream_url', ''),
                       3,
                       c.get('tvg_logo', addon_icon),
                       addon_fanart,
                       'Channels',
                       isFolder=False,
                       addcontext=['hide_chan', 'add_fav_chan'],
                       channeldata=c)
        else:
            dialog.notification(addon_name,
                                local_string(32024).format(menu=name))
            xbmc.executebuiltin('Action(Back)')
Esempio n. 8
0
def SearchMenu():
    matches = []
    query = None
    with open(search_json, 'r+') as f:
        data = json.load(f)
        searches = data.get('search_history')
        searches = dict(reversed(list(searches.items())))
        if len(searches) > 0:
            items = [(xbmcgui.ListItem(local_string(32008)), None)]
            for k, v in searches.items():
                items.append(
                    (xbmcgui.ListItem(v.get('query')), v.get('matches')))
            ret = dialog.select(local_string(32009), [x[0] for x in items])
            if ret >= 0:
                label = items[ret][0].getLabel()
                if label == local_string(32008):
                    #New search
                    nsq = NewSearchQuery()
                    if nsq:
                        ss = SelSources()
                        if ss:
                            matches, query = SearchSelected(nsq, ss)
                    else:
                        xbmc.executebuiltin('Action(Back)')
                elif label in [x[0].getLabel() for x in items]:
                    retu = dialog.yesnocustom(addon_name, local_string(32010),
                                              local_string(32025),
                                              local_string(32012),
                                              local_string(32011))
                    if retu == 1:
                        ss = SelSources()
                        if ss:
                            matches, query = SearchSelected(label, ss)
                        else:
                            xbmc.executebuiltin('Action(Back)')
                    elif retu == 0:
                        matches = items[ret][1]
                        query = items[ret][0].getLabel()
                    else:
                        xbmc.executebuiltin('Action(Back)')
            else:
                xbmc.executebuiltin('Action(Back)')
        else:
            nsq = NewSearchQuery()
            if nsq:
                ss = SelSources()
                if ss:
                    matches, query = SearchSelected(nsq, ss)
    if len(matches) > 0:
        with open(customiser_json, 'r') as _f:
            hidden_chan = json.load(_f).get('hidden_channel').keys()
            for c in matches:
                if not c.get('tvg_id') in hidden_chan:
                    addDir(c.get('channel_name', 'Unknown'),
                           c.get('stream_url', ''),
                           3,
                           c.get('tvg_logo', addon_icon),
                           addon_fanart,
                           'Channels',
                           isFolder=False,
                           addcontext=['hide_chan', 'add_fav_chan'],
                           channeldata=c)
    elif query:
        ret = dialog.yesno(addon_name, local_string(32013).format(query=query))
        if ret:
            SearchMenu()
        else:
            xbmc.executebuiltin('Action(Back)')
    else:
        return
Esempio n. 9
0
def myFavMenu(name):
    stream_url_fail = []
    refresh = False
    with open(fav_json, 'r+') as f:
        data = json.load(f)
        channels = data.get('channels')
        categorys = data.get('categorys')
        if len(channels) > 0 or len(categorys) > 0:
            for k, v in list(channels.items()):
                stream_url = v.get('stream_url')
                stream_name = v.get('channel_name', 'Data missing')
                if addon.getSettingBool(
                        'general.smart') and addon.getSettingBool(
                            'general.smart.fav'):
                    if not UrlValidator(stream_url):
                        ret = dialog.yesnocustom(
                            addon_name,
                            local_string(32018).format(
                                stream_name=stream_name), local_string(32019),
                            local_string(32020), local_string(32021))
                        #return values to function Remove = 2, Replace = 0 ignore = 1
                        if ret == 0:
                            ss = SelSources()
                            if ss:
                                matches, query = SearchSelected(
                                    stream_name, ss)
                                items = []
                                for m in matches:
                                    li = xbmcgui.ListItem(
                                        m.get('channel_name'))
                                    li.setArt({'thumb': m.get('tvg_logo')})
                                    items.append((li, m))
                                retu = dialog.multiselect(
                                    local_string(32022), [x[0] for x in items])
                                if len(retu) > 0:
                                    for i in retu:
                                        channels.update({
                                            items[i][1].get('tvg_id'):
                                            items[i][1]
                                        })
                                    f.seek(0)
                                    json.dump(data, f, indent=4)
                                    f.truncate()
                                    refresh = True
                        elif ret == 2:
                            chanId = v.get('tvg_id')
                            channels.pop(chanId)
                            f.seek(0)
                            json.dump(data, f, indent=4)
                            f.truncate()
                            refresh = True
                        else:
                            pass
                addDir(stream_name,
                       stream_url,
                       3,
                       v.get('tvg_logo', addon_icon),
                       addon_fanart,
                       v.get('group_title'),
                       isFolder=False,
                       addcontext=['re_fav_chan'],
                       channeldata=v)
            if refresh:
                xbmc.executebuiltin("Container.Refresh")
        else:
            dialog.notification(addon_name,
                                local_string(32024).format(menu=name))
            xbmc.executebuiltin('Action(Back)')