Skip to content

Instantly share code, notes, and snippets.

@DVDAndroid
Last active April 16, 2022 14:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DVDAndroid/c5cff59facdafbabf57c6aeffd855722 to your computer and use it in GitHub Desktop.
epg-downloader guidatv sky

docker pull ghcr.io/dvdandroid/epg-downloader-guidatvsky:latest

[
{
"name": "Rai1.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rai1.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=2606803"
},
{
"name": "Rai2.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rai2.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718"
},
{
"name": "Rai3.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rai3.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308709"
},
{
"name": "Rai3Puglia.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rai3.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=668697"
},
{
"name": "Rai4.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rai4.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718"
},
{
"name": "RaiPremium.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/raipremium.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=746992"
},
{
"name": "RaiMovie.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/raimovie.png",
"m3u8": "https://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=747002"
},
{
"name": "Rete4.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/rete4.png",
"m3u8": "https://live2-mediaset-it.akamaized.net/content/hls_h0_clr_vos/live/channel(r4)/index.m3u8"
},
{
"name": "Canale5.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/canale5.png",
"m3u8": "https://live2-mediaset-it.akamaized.net/content/hls_h0_clr_vos/live/channel(c5)/index.m3u8"
},
{
"name": "Italia1.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/italia1.png",
"m3u8": "https://live2-mediaset-it.akamaized.net/content/hls_h0_clr_vos/live/channel(i1)/index.m3u8"
},
{
"name": "Italia2.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/italia2.png",
"m3u8": "https://live2-mediaset-it.akamaized.net/content/hls_h0_clr_vos/live/channel(i2)/index.m3u8"
},
{
"name": "20Mediaset.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/20mediaset.png"
},
{
"name": "MediasetExtra.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/mediasetextra.png",
"m3u8": "https://live2-mediaset-it.akamaized.net/content/hls_h0_clr_vos/live/channel(kq)/index.m3u8"
},
{
"name": "La7.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/la7.png",
"m3u8": "https://d15umi5iaezxgx.cloudfront.net/LA7/CLN/HLS-B/Live_1280x720_.m3u8"
},
{
"name": "La7d.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/la7d.png",
"m3u8": "https://d15umi5iaezxgx.cloudfront.net/LA7D/CLN/HLS-B/Live_1280x720_.m3u8"
},
{
"name": "Nove.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/nove.png",
"m3u8": "https://sbshdlu5-lh.akamaihd.net/i/sbshdl_3@810997/master.m3u8"
},
{
"name": "TV8.it",
"logo": "https://cdn.jsdelivr.net/gh/jurijnota/iptv-italy/logos/7.png",
"m3u8": "http://localhost:10293/?id=7"
},
{
"name": "RealTimeItalia.us",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/realtime.png",
"m3u8": "https://sbshdlu5-lh.akamaihd.net/i/sbshdl_4@810998/master.m3u8"
},
{
"name": "DMAXItalia.us",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/dmax.png",
"m3u8": "https://sbshdlu5-lh.akamaihd.net/i/sbshdl_5@825063/master.m3u8"
},
{
"name": "VH1Italia.us",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/vh1.png"
},
{
"name": "Cielo.it",
"logo": "https://cdn.jsdelivr.net/gh/Tundrak/IPTV-Italia/logos/cielo.png",
"m3u8": "http://localhost:10293/?id=2"
}
]
FROM python:alpine
COPY main.py /app/main.py
COPY requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python", "/app/main.py"]
import json
import re
from datetime import datetime, timedelta
import requests
CHANNELS_XML = "https://raw.githubusercontent.com/iptv-org/epg/master/sites/guidatv.sky.it/guidatv.sky.it_it.channels.xml"
CHANNELS_XML_REGEX = "<channel.+xmltv_id=\"(.+)\" site_id=\"(.+)\">(.+)</channel>"
PROGRAMMES = []
def sky_api_call(channel):
return requests.get("https://apid.sky.it/gtv/v1/events", params={
"from": datetime.now().strftime("%Y-%m-%d") + "T00:00:00Z",
"to": (datetime.now() + timedelta(days=7)).strftime("%Y-%m-%d") + "T23:59:59Z",
"pageSize": 999,
"pageNum": 0,
"env": "DTH",
"channels": channel,
}).json()
def channel2str(channel):
s = f"""<channel id="{channel['xmltv_id']}">"""
s += f"""<display-name lang="it">{channel['name']}</display-name>"""
s += f"""<icon src="{channel['icon']}" />"""
if "m3u8" in channel.keys():
s += f"""<m3u8 src="{channel['m3u8']}" />"""
s += "</channel>"
return s
def programme2str(programme):
s = f"""<programme start="{programme['start']} +0000" stop="{programme['stop']} +0000" channel="{programme['channel']}">"""
s += f"""<title lang="it">{programme['title'].replace('&', '&amp;')}</title>"""
s += f"""<desc lang="it">{programme['desc'].replace('&', '&amp;')}</desc>"""
for c in programme['category']:
s += f"<category>{c}</category>"
s += f"""<icon src="{programme['icon']}" />"""
s += "</programme>"
return s
def main():
channels = []
favorite_channels = []
with open('channels.json') as f:
favorite_channels = json.load(f)
xml = requests.get(CHANNELS_XML).text
matches = re.findall(CHANNELS_XML_REGEX, xml)
for match in matches:
channels.append({
"xmltv_id": match[0],
"site_id": match[1],
"name": match[2],
})
favorite_channels_names = list(map(lambda c: c["name"], favorite_channels))
channels = [c for c in channels if c["xmltv_id"] in favorite_channels_names]
for channel in channels:
api_call = sky_api_call(channel["site_id"].split("#")[1])
channel["icon"] = next(c['logo'] for c in favorite_channels if c["name"] == channel['xmltv_id'])
channel["m3u8"] = next((c['m3u8'] for c in favorite_channels if c["name"] == channel['xmltv_id'] and "m3u8" in c.keys()), None)
for programme in api_call["events"]:
PROGRAMMES.append({
"channel": channel["xmltv_id"],
"title": programme["eventTitle"],
"desc": programme["eventSynopsis"],
"category": [programme["content"]["genre"]["name"], programme["content"]["subgenre"]["name"]],
"start": programme["starttime"],
"stop": programme["endtime"],
"icon": "https://guidatv.sky.it" +
next(x for x in programme["content"]["imagesMap"] if x["key"] == "cover")["img"]["url"]
})
out = """<?xml version="1.0" encoding="UTF-8" ?><tv>\n"""
out += "\n".join([channel2str(c) for c in channels])
out += "\n"
out += "\n".join([programme2str(p) for p in PROGRAMMES])
out += "\n</tv>"
print(out)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment