Change this loop to return specific set of channels
#1
I am by no means a coder, but I need to adjust this bit of code to not return all the channels, but only.

The loop below returns 72 channels (names) currently from the url but I only want to return 6, from channel 30 to channel 36. How can I edit that for loop below to make that happen?

Code:
def Channels(murls):
    setCookie()
    i=1
    link = OPENURL('URLFORWEBSITE',cookie='NAME')
    link = cleanHex(link)
    link=link.replace('\r','').replace('\n','').replace('\t','').replace(' ','').replace('  ','')  
    addLink2('[I][COLOR red]Refresh Links[/COLOR][/I]  (Click Here if Vidoes are not playing)','url',555,artpath+'empty.png',fanart)
    if '<a href="#" class="user-name">'+user+'</a>' in link:
        matchlist=re.compile('<li>([^<]+)</li><ul class="inner-ul">(.+?)</ul></a>').findall(link)
        for name,urls in matchlist:
            addPlay(name,urls,411,art+str(i)+'.png')
            i=i+1

Thanks in advance.

PlexMan
Reply
#2
give this a shot:

Code:
for name,urls in matchlist:
    if i in range(30, 37):
        addPlay(name,urls,411,art+str(i)+'.png')
    i=i+1
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Thanks for your help, but unfortunately adding that broke the plugin. I removed it to ensure it wasn't something else and the plugin worked again afterwards. Any other thoughts?
Reply
#4
look in the kodi log why it fails with my code.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
Ronie, you are a star. I looked into it a little more. I had no idea indents and their placement had an impact. Unless I did something wrong before? Do indents have an impact on python programming?
Reply
#6
PS. It's working perfectly.
Reply
#7
(2016-11-28, 02:57)PlexMan Wrote: Do indents have an impact on python programming?

yup. a lot :-)
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
(2016-11-28, 02:57)PlexMan Wrote: Do indents have an impact on python programming?

Good joke!Big Grin

I also have to add that in most cases explicit counters inside loops and functions returning lists are the signs of code smell in Python.
Reply

Logout Mark Read Team Forum Stats Members Help
Change this loop to return specific set of channels0