linuxmint / hypnotix

An M3U IPTV Player
1.26k stars 169 forks source link

Playlist formatting. Grouping. #129

Open aleksey1831981 opened 3 years ago

aleksey1831981 commented 3 years ago

Hello. My primary language is Russian. But I will try to write clear words)

I have an IPTV provider ilook.tv

When I load a .M3U playlist from ilook.tv, hypnotix does not see the channel grouping. Although Free-IPTV has grouping.

Free-IPTV has the following format:

#EXTM3U
#EXTINF:-1 tvg-name="GERMANY (Partly GEO-Blocked) github.com/Free-IPTV" group-title="GERMANY" tvg-logo="https://i.imgur.com/xku2oyd.png",GERMANY (Partly GEO-Blocked) - github.com/Free-IPTV
https://raw.githubusercontent.com/Free-IPTV/Others/master/FreeIPTV.mp4

ilook.tv has the following format:

#EXTM3U
#EXTINF:0 tvg-rec="0",First FHD
#EXTGRP:General
http://8jcmieoy.ottclub.xyz/iptv/K2VY5Y28QM5E3N/10029/index.m3u8

Can I hope that this will be fixed and hypnotix will be able to read the playlist from ilook.tv without additional magic? Or should I use this solution: https://github.com/linuxmint/hypnotix/issues/94#issuecomment-760762050 ?

Axel-Erfurt commented 3 years ago

try this, adjust the path to ilook.m3u

t = open("ilook.m3u", "r").read()

tlist = t.splitlines()
name = ""
group = ""
url = ""
result = ["#EXTM3U"]

for line in tlist[1:]:
    if "EXTINF:0" in line:
        name = f'#EXTINF:-1 tvg-name="{line.partition(",")[2]}"'
    elif "EXTGRP" in line:
        group = f'group-title="{line.partition("EXTGRP:")[2]}"'
    else:
        url = line
        print(f'{name} {group}\n{url}')
        result.append(f'{name} {group}\n{url}')

with open("ilook_converted.m3u", "w") as f:
    f.write('\n'.join(result))

and you will get something like this

#EXTM3U
#EXTINF:-1 tvg-name="First FHD" group-title="General"
http://8jcmieoy.ottclub.xyz/iptv/K2VY5Y28QM5E3N/10029/index.m3u8
aleksey1831981 commented 3 years ago

Thanks.

If this code works, will you add support for ILOOKTV playlists in the next release? It would be nice if hypnotix would automatically detect the type of playlist and work with it correctly. I think this will make hypnotix easier to use, and will encourage mass adoption)

aleksey1831981 commented 3 years ago

I also have a question about EPG. Does Hypnotix support EPG? If I specify an EPG file then it doesn't work. I tried .xml.gz and .xml but it doesn't work.

If necessary, I can create a new issue.

Axel-Erfurt commented 3 years ago

If this code works, will you add support for ILOOKTV playlists in the next release?

I don't know, I'm not the developer of hypnotix

Does Hypnotix support EPG?

I think no, hypnotix uses imdb for movies and series

ghost commented 3 years ago

try this, adjust the path to ilook.m3u

@Axel-Erfurt hello from Russia! Your script is not working with this playlist:

#EXTM3U
#EXTINF:-1 group-title="Group 1" tvg-logo="http://127.0.0.1",Channel 1
http://127.0.0.1
#EXTINF:-1 group-title="Group 2" tvg-logo="http://127.0.0.1",Channel 2
http://127.0.0.1
#EXTINF:-1 tvg-logo="http://127.0.0.1",Channel 3
#EXTGRP:Group 3
http://127.0.0.1
#EXTINF:-1 tvg-logo="http://127.0.0.1",Channel 4
#EXTGRP:Group 4
http://127.0.0.1

can you fix it please?

Axel-Erfurt commented 3 years ago

try this

t = open("test.m3u", "r").read()

tlist = t.splitlines()
name = '""'
group = ""
url = '""'
logo = '""'
result = ["#EXTM3U"]

for x in range (1, len(tlist)-1):
    line = tlist[x]
    nextline = tlist[x+1]
    if "#EXTINF" in line and not "tvg-name" in line:
        name = line.rpartition(",")[2]
        if 'group-title=' in line:
            group = line.rpartition('group-title="')[2].partition('"')[0]
        else:
            group = ""
        if 'tvg-logo=' in line:
            logo = line.rpartition('tvg-logo="')[2].partition('"')[0]
        else:
            logo = ""
        if not "EXTGRP" in nextline:
            url = nextline
        else:
            group = nextline.partition('#EXTGRP:')[2]
            url = tlist[x+2]
        result.append(f'#EXTINF:-1 tvg-name="{name}" group-title="{group}" tvg-logo="{logo}",{name}\n{url}')

with open("test_converted.m3u", "w") as f:
    f.write('\n'.join(result))

Result with your example is:

#EXTM3U
#EXTINF:-1 tvg-name="Channel 1" group-title="Group 1" tvg-logo="http://127.0.0.1",Channel 1
http://127.0.0.1
#EXTINF:-1 tvg-name="Channel 2" group-title="Group 2" tvg-logo="http://127.0.0.1",Channel 2
http://127.0.0.1
#EXTINF:-1 tvg-name="Channel 3" group-title="Group 3" tvg-logo="http://127.0.0.1",Channel 3
http://127.0.0.1
#EXTINF:-1 tvg-name="Channel 4" group-title="Group 4" tvg-logo="http://127.0.0.1",Channel 4
http://127.0.0.1
ghost commented 3 years ago

@Axel-Erfurt works perfect with all my playlists, thank you!

Axel-Erfurt commented 3 years ago

In the last few days I have written an m3uEditor. With it you can edit your converted m3u.

m3uEdit at github

Versions for Gtk or PyQt5

screenshot2

screenshot