1. Dear visitor, you are viewing Rapid IPTV as a guest member who has restricted access to our forum. You can either sign-up or login with your username here: http://www.rapidiptv.com/login/

Script to sort the m3u file

Discussion in 'Tutorials & Installation Guides' started by ecircuit, Oct 19, 2016.

Watchers:
This thread is being watched by 3 users.
  1. ecircuit

    ecircuit New Member

    30%
    Joined:
    Oct 3, 2016
    Messages:
    4
    Likes Received:
    7
    Liked:
    0
    Trophy Points:
    3
    Device:
    Kodi (Fire TV Stick)
    Hi there,
    I contacted the support if it was possible to generate the m3u file on my own to filter out all categories and channels which I do not need because of perfomance reasons. They told me that this was not possible so I coded a quick and dirty workaround on my own and host this script on one of my linux servers (ubuntu server 14.04).

    The code is written in Python. I run this script every six hours over crontab and the file is served to Kodi over FTP. You need to install the requests library over pip.

    Here is the code. Feel free to use it:

    Code:
    import requests
    url = "yourlink"
    response = requests.get(url)
    if response.status_code == 200:
    	f = open("m3ulist.m3u", 'w')
    	f.write(response.content)
    	f.close()
     
    f = open("m3ulist.m3u","r")
    myList = []
    for line in f:
    	myList.append(line)
    f.close()
     
    listGermany = []
    listGermanyVIP = []
    listTurkey = []
     
    found = 0
     
     
    for entry in myList:
    	if 'Germany' in str(entry):
    		listGermany.append(entry)
    		found = 1
    	else:
    		if found == 1:
    			listGermany.append(entry)
    			found = 0
     
    for entry in myList:
    	if 'VIP DE' in str(entry):
    		listGermanyVIP.append(entry)
    		found = 1
    	else:
    		if found == 1:
    			istGermanyVIP.append(entry)
    			found = 0
     
    for entry in myList:
    	if 'Turkey' in str(entry):
    		listTurkey.append(entry)
    		found = 1
    	else:
    		if found == 1:
    			listTurkey.append(entry)
    			found = 0
     
    f = open("iptv.m3u","w")
    f.write("#EXTM3U\n")
    for entry in listGermany:
    	f.write(entry)
    for entry in listGermanyVIP:
    	f.write(entry)
    for entry in listTurkey:
    	f.write(entry)
    f.close()
     
    
    Have fun.
     
    Tags:
    xanthus, ragonline, Cuvillier and 3 others like this.
  2. Schamlos

    Schamlos New Member

    80%
    Joined:
    Oct 3, 2016
    Messages:
    32
    Likes Received:
    11
    Liked:
    19
    Trophy Points:
    8
    Gender:
    Male
    Device:
    Fire Tv Stick
    Thank you i will Test it!
     
  3. ecircuit

    ecircuit New Member

    30%
    Joined:
    Oct 3, 2016
    Messages:
    4
    Likes Received:
    7
    Liked:
    0
    Trophy Points:
    3
    Device:
    Kodi (Fire TV Stick)
    You are welcome.

    If there is a demand I can enhace the code and add other functions.
     
  4. xanthus

    xanthus New Member

    30%
    Joined:
    Nov 3, 2016
    Messages:
    8
    Likes Received:
    1
    Liked:
    2
    Trophy Points:
    3
    Gender:
    Male
    Device:
    Kodi
    You read my mind!! Thank you!
     

Share This Page

Loading...