Пример #1
0
def m3uCategory(url):
    
    if url.find("http:") < 0 :

        list = common.m3u2list(os.path.join(chanDir, url)) 
        	
        for channel in list:
            name = common.GetEncodeString(channel["display_name"])

            if channel.get("tvg_logo", ""): 
                logo = channel.get("tvg_logo", "")
            else :
                logo = "tv.png"
                
            iconname = "http://kodilive.eu/logo/" + logo
            AddDir(name ,channel["url"], 3, iconname, isFolder=False)
        
    else :
        tmp = TempFileName (url)
	#tmpList = []
	tcache = 18000
	
	if os.path.isfile(tmp):
            t = time.time() - os.path.getmtime(tmp)
        else :
            t = 0
	
	if os.path.isfile(tmp) and t < tcache :
                list = common.m3u2list(tmp)
        else :       
                list = common.m3u2list(url)
                
	for channel in list:
		name = common.GetEncodeString(channel["display_name"])
		#logo = common.GetEncodeString(channel["params"])
                #logo = logo.replace(' ', '')
                if channel.get("tvg_logo", ""): 
                    logo = channel.get("tvg_logo", "")
                else :
                    logo = "tv.png"
                
                iconname = "http://kodilive.eu/logo/" + logo
                #iconname = "http://kodilive.site88.net/logo/" + logo
                
		AddDir(name ,channel["url"], 3, iconname, isFolder=False)
		#tmpList.append({"url": channel["url"], "image": "", "name": name.decode("utf-8")})
        
        xbmc.log( "*** tmp file time : " + format(t) )
        
        if not os.path.isfile(tmp) or t > tcache :
                content = common.OpenURL(url)
                if len(content) > 10 :
                    write_file(tmp, content) 
                    xbmc.log('Write temp list : ' + tmp + '- size : ' + format( len(content) ) )
def m3uCategory(url, logos, cache, gListIndex=-1):	
	tmpList = []
	chList = common.m3u2list(url, cache)
	groupChannels = []
	for channel in chList:
		if makeGroups:
			matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0].get("group_title", x[0]["display_name"]) == channel.get("group_title", channel["display_name"])]
		if makeGroups and len(matches) == 1:
			groupChannels[matches[0]].append(channel)
		else:
			groupChannels.append([channel])
	for channels in groupChannels:
		idx = groupChannels.index(channels)
		if gListIndex > -1 and gListIndex != idx:
			continue
		isGroupChannel = gListIndex < 0 and len(channels) > 1
		chs = [channels[0]] if isGroupChannel else channels
		for channel in chs:
			name = common.GetEncodeString(channel["display_name"]) if not isGroupChannel else common.GetEncodeString(channel.get("group_title", channel["display_name"]))
			if isGroupChannel:
				name = '[{0}]'.format(name)
				chUrl = url
				image = ''
				AddDir(name ,url, 10, index=idx)
			else:
				chUrl = common.GetEncodeString(channel["url"])
				image = channel.get("tvg_logo", channel.get("logo", ""))
				if logos is not None and logos != ''  and image != "" and not image.startswith('http'):
					image = logos + image
				AddDir(name, chUrl, 3, image, index=-1, isFolder=False, IsPlayable=True)
			tmpList.append({"url": chUrl.decode("utf-8"), "image": image.decode("utf-8"), "name": name.decode("utf-8")})
	common.SaveList(tmpListFile, tmpList)
def m3uCategory(url, logos):
    if isM3UDir(url):
        m3uDir(url, logos)
        return

    tmpList = []
    list = common.m3u2list(url)

    for channel in list:
        name = common.GetEncodeString(channel["display_name"])
        image = channel.get("tvg_logo", "")
        if image == "":
            image = channel.get("logo", "")
        if logos is not None and logos != '' and image is not None and image != '' and not image.startswith(
                'http'):
            image = logos + image
        url = common.GetEncodeString(channel["url"])
        AddDir(name, url, 3, image, isFolder=False)
        tmpList.append({
            "url": url.decode("utf-8"),
            "image": image.decode("utf-8"),
            "name": name.decode("utf-8")
        })

    common.SaveList(tmpListFile, tmpList)
Пример #4
0
def m3uCategory(url):
    list = common.m3u2list(url)
    for channel in list:
        iconimage = "" if not channel.has_key(
            "tvg_logo") else channel["tvg_logo"]
        addDir(channel["display_name"].encode('utf-8'),
               channel["url"],
               3,
               iconimage,
               isFolder=False)
Пример #5
0
def PlayUrl(name, url, iconimage=None):
        _NAME_=name
        list = common.m3u2list(ServerURL)
        for channel in list:
            name = common.GetEncodeString(channel["display_name"])
            stream=channel["url"]
            if _NAME_ in name:
                listitem = xbmcgui.ListItem(path=stream, thumbnailImage=iconimage)
                listitem.setInfo(type="Video", infoLabels={ "Title": name })
                xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)				
Пример #6
0
def PlayUrl(name, url, iconimage=None):
        _NAME_=name
        list = common.m3u2list(ServerURL)
        for channel in list:
            name = common.GetEncodeString(channel["display_name"])
            stream=channel["url"]
            if _NAME_ in name:
                listitem = xbmcgui.ListItem(path=stream, thumbnailImage=iconimage)
                listitem.setInfo(type="Video", infoLabels={ "Title": name })
                xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)				
Пример #7
0
def m3uCategory(url):	
	tmpList = []
	list = common.m3u2list(url)

	for channel in list:
		name = common.GetEncodeString(channel["display_name"])
		AddDir(name ,channel["url"], 3, "", isFolder=False)
		tmpList.append({"url": channel["url"], "image": "", "name": name.decode("utf-8")})

	common.SaveList(tmpListFile, tmpList)
Пример #8
0
def m3uCategory(url):
    tmpList = []
    list = common.m3u2list(url)

    for channel in list:
        name = GetEncodeString(channel["display_name"])
        AddDir(name, channel["url"], 3, "", isFolder=False)
        tmpList.append({"url": channel["url"], "image": "", "name": name})

    common.SaveList(tmpListFile, tmpList)
def m3uCategory(url, logos, cache, gListIndex=-1): 
      
    meta = None
    '''
    meta_id = common.searchMetaTVDBId(url, playlistsFile)
    if not meta_id is None:
        if common.isScannedByTheTvDB(meta_id):
            meta = common.loadDataFromTheTvDB(meta_id)

    elif common.isScannedByTheMovieDB(gListIndex):
        meta = common.loadDataFromTheMovieDB(gListIndex)
    '''
    tmpList = []
    chList = common.m3u2list(url, cache)
    groupChannels = []
    
    for channel in chList:
        if makeGroups:
            matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0].get("group_title", x[0]["display_name"]) == channel.get("group_title", channel["display_name"])]
        
        if makeGroups and len(matches) == 1:
            groupChannels[matches[0]].append(channel)
        else:
            groupChannels.append([channel])
    
    
    for channels in groupChannels:
        idx = groupChannels.index(channels)
        if gListIndex > -1 and gListIndex != idx:
            continue
        isGroupChannel = gListIndex < 0 and len(channels) > 1
        chs = [channels[0]] if isGroupChannel else channels
        
        for channel in chs:
            name = common.GetEncodeString(channel["display_name"]) if not isGroupChannel else common.GetEncodeString(channel.get("group_title", channel["display_name"]))
            plot = "" if meta is None else meta[channel["group_title"]]["overview"] if channel["group_title"] in meta else ""
            fanart = "" if meta is None else meta[channel["group_title"]]["fanarts"][0] if (channel["group_title"] in meta and len(meta[channel["group_title"]]["fanarts"]) > 0) else ""

            if isGroupChannel:
                name = '{0}'.format(name)
                chUrl = url
                try:
                    image = channel['tvg_logo'] if meta is None else meta[channel["group_title"]]["poster"] if channel["group_title"] in meta else channel['tvg_logo']
                except KeyError:
                    image = "DefaultTVShows.png"
                AddDir(name ,url, 10, index=idx, iconimage=image, plot=plot, fanart=fanart)
            else:
                chUrl = common.GetEncodeString(channel["url"])
                image = channel.get("tvg_logo", channel.get("logo", ""))
                if logos is not None and logos != ''  and image != "" and not image.startswith('http'):
                    image = logos + image
                AddDir(name, chUrl, 3, image, index=-1, isFolder=False, IsPlayable=True, plot=plot, fanart=fanart)
            tmpList.append({"url": chUrl.decode("utf-8"), "image": image.decode("utf-8"), "name": name.decode("utf-8")})
    
    common.SaveList(tmpListFile, tmpList)
Пример #10
0
def m3uCategory(url):	
	tmpList = []
	list = common.m3u2list(url)
	for channel in list:
		iconimage = ""
		#iconimage = "" if not channel.has_key("tvg_logo") else channel["tvg_logo"]
		name = channel["display_name"].decode(chardet.detect(channel["display_name"])["encoding"]).encode("utf-8")
		AddDir(name ,channel["url"], 3, iconimage, isFolder=False)
		tmpList.append({"url": channel["url"], "image": iconimage, "name": name})
		
	common.SaveList(tmpListFile, tmpList)
Пример #11
0
def m3uCategory(url):
    tmpList = []
    list = common.m3u2list(url)

    for channel in list:
        name = common.GetEncodeString(channel["display_name"])
        mode = LibCommon + 26 if channel["url"].find("youtube") > 0 else 3
        AddDir(name, channel["url"], mode, "", isFolder=False)
        tmpList.append({
            "url": channel["url"],
            "image": "",
            "name": name.decode("utf-8")
        })

    common.SaveList(tmpListFile, tmpList)
Пример #12
0
def m3uCategory(url, logos):	
	tmpList = []
	list = common.m3u2list(url)

	for channel in list:
		name = common.GetEncodeString(channel["display_name"])
		image = channel.get("tvg_logo", "")
		if image == "":
			image = channel.get("logo", "")
		if logos is not None and logos != '' and image is not None and image != '' and not image.startswith('http'):
			image = logos + image
		url = common.GetEncodeString(channel["url"])
		AddDir(name ,url, 3, image, isFolder=False)
		tmpList.append({"url": url.decode("utf-8"), "image": image.decode("utf-8"), "name": name.decode("utf-8")})

	common.SaveList(tmpListFile, tmpList)
Пример #13
0
def m3uCategory(url):	
	tmpList = []
	list = common.m3u2list(url)

	for channel in list:
		menu = channel["menu"]
		name = common.GetEncodeString(channel["display_name"])
		if "MENU_M3U" in menu:
			AddDir(name,channel["url"], 4, channel["logo"])
		elif  "MENU_XML" in menu:
			addShowDir(name,channel["url"], 50, channel["logo"])
		else:
			AddDir(name ,channel["url"], 3, channel["logo"], isFolder=False)
			tmpList.append({"url": channel["url"], "image": channel["logo"], "name": name.decode("utf-8"), "hashcode": hashlib.md5(name).hexdigest()})

	common.SaveList(tmpListFile, tmpList)
Пример #14
0
def m3uCategory(url):	
	tmpList = []
	list = common.m3u2list(url)
        
	for channel in list:
		name = common.GetEncodeString(channel["display_name"])
		#logo = common.GetEncodeString(channel["params"])
                #logo = logo.replace(' ', '')
                if channel.get("tvg_logo", ""): 
                    logo = channel.get("tvg_logo", "")
                else :
                    logo = "tv.png"
                
                iconname = "http://kodilive.eu/logo/" + logo
                #iconname = "http://kodilive.site88.net/logo/" + logo
                
		AddDir(name ,channel["url"], 3, iconname, isFolder=False)
		tmpList.append({"url": channel["url"], "image": "", "name": name.decode("utf-8")})

	common.SaveList(tmpListFile, tmpList)
Пример #15
0
def LiveTv(url):
    list = common.m3u2list(ServerURL)
    for channel in list:
        name = common.GetEncodeString(channel["display_name"])
        AddDir(name ,channel["url"], 3, iconimage, isFolder=False)
Пример #16
0
def Buildlist(url):
    list = common.m3u2list(url)
    for channel in list:
        name = common.GetEncodeString(channel["display_name"])
        AddDir(name ,channel["url"], 3, iconimage, isFolder=False)
Пример #17
0
def m3uCategory(url):	
	list = common.m3u2list(url)
	for channel in list:
		iconimage = "" if not channel.has_key("tvg_logo") else channel["tvg_logo"]
		addDir(channel["display_name"].encode('utf-8') ,channel["url"], 3, iconimage, isFolder=False)
def m3uCategory(url, logos, epg, cache, mode, gListIndex=-1): 
      
    meta = None
    '''
    meta_id = common.searchMetaTVDBId(url, playlistsFile)
    if not meta_id is None:
        if common.isScannedByTheTvDB(meta_id):
            meta = common.loadDataFromTheTvDB(meta_id)

    elif common.isScannedByTheMovieDB(gListIndex):
        meta = common.loadDataFromTheMovieDB(gListIndex)
    '''
    tmpList = []
    chList = common.m3u2list(url, cache)
    if mode == 10 and epg != None and epg != '':
      epgDict = common.epg2dict(epg, cache=720)
      dnow = datetime.now(tz.UTC)
      to_zone = tz.tzlocal()
      use_percent = 'true'
      use_time = 'true'
    else: epgDict = {}
    
    #xbmc.log('EPGDICT')
    #xbmc.log(str(epgDict))
    groupChannels = []
    
    for channel in chList:
        if makeGroups:
            matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0].get("group_title", x[0]["display_name"]) == channel.get("group_title", channel["display_name"])]
        
        if makeGroups and len(matches) == 1:
            groupChannels[matches[0]].append(channel)
        else:
            groupChannels.append([channel])
    
    
    for channels in groupChannels:
        idx = groupChannels.index(channels)
        if gListIndex > -1 and gListIndex != idx:
            continue
        isGroupChannel = gListIndex < 0 and len(channels) > 1
        chs = [channels[0]] if isGroupChannel else channels
        
        #xbmc.log(str(epgDict.get(u'name')))
        for channel in chs:
            name = common.GetEncodeString(channel["display_name"]) if not isGroupChannel else common.GetEncodeString(channel.get("group_title", channel["display_name"]))
            plot = "" if meta is None else meta[channel["group_title"]]["overview"] if channel["group_title"] in meta else ""
            fanart = "" if meta is None else meta[channel["group_title"]]["fanarts"][0] if (channel["group_title"] in meta and len(meta[channel["group_title"]]["fanarts"]) > 0) else ""

            if isGroupChannel:
                name = '{0}'.format(name)
                chUrl = url
                try:
                    image = channel['tvg_logo'] if meta is None else meta[channel["group_title"]]["poster"] if channel["group_title"] in meta else channel['tvg_logo']
                except KeyError:
                    image = "DefaultTVShows.png"
                AddDir(name ,url, 10, epg=epg, index=idx, iconimage=image, cacheMin=cache, plot=plot, fanart=fanart)
            else:
                chUrl = common.GetEncodeString(channel["url"])
                image = channel.get("tvg_logo", channel.get("logo", ""))
                '''
                if image == "" and epgDict:
                    if name.decode('utf-8') in epgDict.get(u'name'):
                        image = epgDict[u'data'][epgDict[u'name'].index(name.decode('utf-8'))][1]
                    if name in epgDict.get(u'name'):
                        image = epgDict[u'data'][epgDict[u'name'].index(name)][1]
'''
                if epgDict:
                    idx = None
                    id = None
                    if epgDict.get(u'name'):
                        if name.decode('utf-8') in epgDict.get(u'name'):
                            idx = epgDict[u'name'].index(name.decode('utf-8'))
                        elif name in epgDict.get(u'name'):
                            idx = epgDict[u'name'].index(name)
                        if image == "" and idx is not None:
                                image = epgDict[u'data'][idx][1]
                                
                        t2len = 0
                        title2nd = ''
                        edescr = ''
                        next = False

                        if idx is not None:
                            #xbmc.log(str( epgDict.get('prg').get(epgDict[u'data'][idx][0])))
                            if epgDict.get('prg').get(epgDict[u'data'][idx][0]):
                                for start,stop,title in epgDict.get('prg').get(epgDict[u'data'][idx][0]):
                                    stime = parser.parse(start)
                                    etime = parser.parse(stop)
                                    if stime <= dnow <= etime or next:
                                        ebgn = stime.astimezone(to_zone).strftime('%H:%M')
                                        eend = etime.astimezone(to_zone).strftime('%H:%M')
                                        if use_time == 'true':
                                            stmp = '%s-%s' % (ebgn, eend)
                                            t2len += (len(stmp) + 1) 
                                            if not next: title2nd += ' [COLOR FF00BB66]%s[/COLOR]' % stmp
                                            else:  title2nd += ' %s' % stmp
                                        title2nd += ' %s' % title
                                        t2len += (len(title) + 1)
                                        
                                        title2nd = title2nd.replace('&quot;','`').replace('&amp;',' & ')
                                        if not t2len: t2len = len(name)
                                        if not next:
                                            plot += '[B][COLOR FF0084FF]%s-%s[/COLOR] [COLOR FFFFFFFF] %s[/COLOR][/B]' % (ebgn, eend, title)
                                            name = '[B]%s[/B]\n%s' % (name.ljust(int(t2len * 1.65)), title2nd.encode('utf-8'))
                                            next = True
                                        else: 
                                            plot += '[COLOR FF999999]\n\n%s-%s %s[/COLOR]\n' % (ebgn, eend, title) 
                                            next = False
                                            break
                                    elif dnow < stime and not next: 
                                        break
                                    

                
                if logos is not None and logos != ''  and image != "" and not image.startswith('http'):
                    image = logos + image
                AddDir(name, chUrl, 3, image, epg=epg, index=-1, isFolder=False, IsPlayable=True, plot=plot, fanart=fanart)
            tmpList.append({"url": chUrl.decode("utf-8"), "image": image.decode("utf-8"), "name": name.decode("utf-8")})
    
    common.SaveList(tmpListFile, tmpList)