mirror of https://github.com/Free-TV/IPTV
Compare commits
1 Commits
74db1a2913
...
198d933994
| Author | SHA1 | Date |
|---|---|---|
|
|
198d933994 |
|
|
@ -17,5 +17,5 @@ jobs:
|
||||||
git config user.email "playlistbot@users.noreply.github.com" || true
|
git config user.email "playlistbot@users.noreply.github.com" || true
|
||||||
python3 ./make_playlist.py
|
python3 ./make_playlist.py
|
||||||
git add .
|
git add .
|
||||||
git diff --staged --quiet || git commit --quiet -m "Update Playlist (GitHub Actions)"
|
git commit --quiet -m "Update Playlist (GitHub Actions)"
|
||||||
git diff --quiet HEAD @{u} || git push -f origin HEAD
|
git push -f origin master
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
EPG_LIST = open('epglist.txt',"r") # for a clean code
|
||||||
|
|
||||||
class Channel:
|
class Channel:
|
||||||
def __init__(self, group, md_line):
|
def __init__(self, group, md_line):
|
||||||
|
|
@ -28,39 +29,32 @@ class Channel:
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
dir_playlists = 'playlists'
|
||||||
lists_dir = os.path.join(base_dir, "lists")
|
if not (os.path.isdir(dir_playlists)):
|
||||||
dir_playlists = os.path.join(base_dir, "playlists")
|
|
||||||
|
|
||||||
if not os.path.isdir(dir_playlists):
|
|
||||||
os.mkdir(dir_playlists)
|
os.mkdir(dir_playlists)
|
||||||
|
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
|
||||||
with open(os.path.join(base_dir, "epglist.txt"), encoding='utf-8') as epg_file:
|
processed_epg_list = ", ".join(EPG_LIST).replace('\n', '')
|
||||||
epg_urls = [line.strip() for line in epg_file if line.strip()]
|
head_playlist = f'#EXTM3U x-tvg-url="{processed_epg_list}"'
|
||||||
processed_epg_list = ", ".join(epg_urls)
|
print(f'#EXTM3U x-tvg-url="{processed_epg_list}"', file=playlist)
|
||||||
head_playlist = f'#EXTM3U x-tvg-url="{processed_epg_list}"\n'
|
os.chdir("lists")
|
||||||
|
for filename in sorted(os.listdir(".")):
|
||||||
with open(os.path.join(base_dir, "playlist.m3u8"), "w", encoding='utf-8') as playlist:
|
|
||||||
playlist.write(head_playlist)
|
|
||||||
for filename in sorted(os.listdir(lists_dir)):
|
|
||||||
if filename == "README.md" or not filename.endswith(".md"):
|
if filename == "README.md" or not filename.endswith(".md"):
|
||||||
continue
|
continue
|
||||||
markup_path = os.path.join(lists_dir, filename)
|
with open(filename, encoding='utf-8') as markup_file:
|
||||||
country_path = os.path.join(dir_playlists, "playlist_" + filename[:-3] + ".m3u8")
|
file_country = os.path.join("..", dir_playlists, "playlist_" + filename[:-3:] + ".m3u8")
|
||||||
group = filename[:-3].replace("_", " ").title()
|
playlist_country = open(file_country, "w", encoding='utf-8')
|
||||||
print(f"Generating {group}")
|
playlist_country.write(head_playlist + "\n")
|
||||||
with open(markup_path, encoding='utf-8') as markup_file, \
|
group = filename.replace(".md", "").title()
|
||||||
open(country_path, "w", encoding='utf-8') as playlist_country:
|
print(f"Generating {group}")
|
||||||
playlist_country.write(head_playlist)
|
|
||||||
for line in markup_file:
|
for line in markup_file:
|
||||||
if "<h1>" in line.lower() and "</h1>" in line.lower():
|
if "<h1>" in line.lower() and "</h1>" in line.lower():
|
||||||
group = re.sub('<[^<>]+>', '', line.strip())
|
group = re.sub('<[^<>]+>', '', line.strip())
|
||||||
if "[>]" not in line:
|
if not "[>]" in line:
|
||||||
continue
|
continue
|
||||||
channel = Channel(group, line)
|
channel = Channel(group, line)
|
||||||
m3u_line = channel.to_m3u_line()
|
print(channel.to_m3u_line(), file=playlist)
|
||||||
print(m3u_line, file=playlist)
|
print(channel.to_m3u_line(), file=playlist_country)
|
||||||
print(m3u_line, file=playlist_country)
|
playlist_country.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue