filmontv: prova con kltv.gz

This commit is contained in:
marco
2020-06-27 12:06:11 +02:00
parent 2243656cf2
commit fe16253e47

View File

@@ -8,26 +8,7 @@ from core import filetools, downloadtools, support, scrapertools
from core.item import Item
from platformcode import logger
host = "http://www.epgitalia.tv/xml/guide.gzip"
lCanali = ['Rai 1', 'Rai 2', 'Rai 3', 'Rete 4', 'Canale 5', 'Italia 1', 'Italia 2', 'Mediaset Extra', 'TeleTicino',
'la5@it', 'La7D', 'Sky TG24 HD', 'TG Norba24', 'Rai Premium', 'Rai News DTT', 'Rai Movie', 'Rai 4 DTT',
'Iris', 'GIALLO DTT', 'Alice', 'RAI Sport', 'Automoto TV', 'Sky Cinema Uno HD', 'Sky Cinema Uno +24 HD',
'Sky Cinema Collection HD', 'Sky Cinema Family HD', 'Sky Cinema Romance HD', 'Sky Cinema Comedy HD',
'Sky Cinema Action HD', 'Sky Cinema Due HD', 'Sky Cinema Due +24 HD', 'Sky Cinema Drama HD',
'Sky Cinema Suspense HD', 'Comedy Central', 'Laeffe', 'Sky Uno HD', 'Classica HD', 'Sky Atlantic', 'Fox HD',
'Fox Life HD', 'Fox Crime HD', 'Blaze', 'Paramount Channel Italia', 'Lei', 'Dove', 'CI Crime+ Investigation',
'Sky Sport F1 HD', 'Sky Sport MotoGP', 'RaiSportpiuHD', 'Class Horse TV', 'SuperTennis HD', 'Eurosport HD',
'Eurosport 2HD', 'Sky Sport 24', 'Sky Sport Uno', 'Sky Sport Football HD', 'Sky Sport Arena',
'Sky Sport Serie A', 'Sky Sport NBA', 'Sky Sport Collection HD', 'Inter Channel', 'Lazio Style Channel',
'Milan TV', 'Roma TV', 'Torino Channel', 'Sky Arte HD-400', 'Discovery Science HD', 'National Geo HD',
'Nat Geo Wild HD', 'History Channel', 'FOCUS', 'DMAX HD', 'Caccia e Pesca', 'Gambero Rosso HD', 'Cielo DTT',
'Cartoon Network', 'Baby TV', 'Nickelodeon', 'DeAKids', 'Super! DTT', 'MAN-GA', 'MTV', 'Telelombardia',
'Spike tv', 'TV8', 'NOVE', 'Premium Cinema HD', 'Premium Cinema Energy', 'Premium Cinema Emotion',
'Premium Cinema Comedy', 'Premium Cinema +24 HD', 'Premium Stories', 'Premium Crime DTT', 'Premium Action',
'Top Crime', 'Sportitalia', 'MySports One F', 'MySports 2/Sky 2 F', 'MySports 3/Sky 3 F',
'MySports 4/Sky 4 F', 'MySports 5/Sky 5 F', 'MySports 6/Sky 6 F', 'MySports 7/Sky 7 F', 'MySports 8/Sky 8 F',
'MySports 9/Sky 9 F', 'Rai Italia', 'Radionorba TV', 'SMtv San Marino', 'Radio 1', 'Italia 7 Gold',
'Mediaset', 'HSE 24']
host = "http://epg-guide.com/kltv.gz"
def mainlist(item):
@@ -54,13 +35,13 @@ def getEpg():
# inmemory = io.BytesIO(httptools.downloadpage(host).data)
downloadtools.downloadfile(host, archiveName)
support.log('opening gzip and writing xml')
fStream = gzip.GzipFile(archiveName, mode='rb')
# guide = fStream.read()
# with open(xmlName, 'w') as f:
# f.write(guide)
fStream = gzip.GzipFile(archiveName, mode='rb')
guide = fStream.read().replace('\n', ' ').replace('><', '>\n<')
with open(xmlName, 'w') as f:
f.write(guide)
# else:
# guide = open(xmlName).read()
return fStream
guide = open(xmlName)
return guide
def category(item):
@@ -96,14 +77,19 @@ def peliculas(item, f=None, ):
line = f.readline()
if '<programme' in line:
channel = scrapertools.find_single_match(line, r'channel="([^"]+)"')
if channel not in lCanali:
skip = True
elif '<title' in line:
title = scrapertools.find_single_match(line, r'>([^<]+?)(?: - 1\s*\^\s*TV)?<')
if title in titles:
skip = True
elif not skip and '<desc' in line:
plot = scrapertools.find_single_match(line, r'>([^<]+)<')
for match in scrapertools.find_multiple_matches_groups(line, r'>(?:\[(?P<genre>[^\]]+)\])?(?P<episode>S[0-9]+\s*Ep?[0-9]+)?(?P<plot>[^<]+)'):
if match['genre']:
genres.append(match['genre'])
episode = match['episode']
plot = match['plot']
if episode and item.contentType == 'movie':
skip = True
elif not skip and '<actor' in line:
match = scrapertools.find_single_match(line, r'(?:role="([^"]*)")?>([^<]+)<')
actors.append([match[1], match[0]])
@@ -111,8 +97,6 @@ def peliculas(item, f=None, ):
director = scrapertools.find_single_match(line, r'>([^<]+)<')
elif not skip and '<date' in line:
year = scrapertools.find_single_match(line, r'>([^<]+)<')
elif not skip and '<category' in line:
genres.append(scrapertools.find_single_match(line, r'>([^<]+)<'))
elif not skip and '<country' in line:
country = scrapertools.find_single_match(line, r'>([^<]+)<')
elif not skip and '<episode-num' in line:
@@ -122,9 +106,9 @@ def peliculas(item, f=None, ):
elif not skip and '<icon' in line:
thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
elif '</programme' in line:
if not skip and (actors or 'Film' in genres):
if not skip:
titles.append(title)
if (item.contentType == 'movie' and (item.category in genres or item.all==True)) or (item.contentType == 'tvshow' and episode):
if (item.contentType == 'movie' and genres and (item.category in genres or item.all==True)) or (item.contentType == 'tvshow' and episode):
itemlist.append(Item(
channel=item.channel,
action='new_search',
@@ -175,8 +159,6 @@ def listaCanali(item):
line = f.readline()
if '<channel' in line:
channel = scrapertools.find_single_match(line, r'id="([^"]+)"')
if channel not in lCanali:
skip = True
elif not skip and '<icon' in line:
thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
elif not skip and '<programme' in line:
@@ -190,13 +172,11 @@ def listaCanali(item):
channelName=channel,
thumbnail=thumbnail
))
lCanali.remove(channel)
thumbnail = None
skip = False
if not lCanali:
break
# return itemlist
# logger.info([i.title for i in itemlist])
f.close()
return sorted(itemlist, key=lambda x: x.title)
@@ -229,6 +209,8 @@ def guidatv(item):
skip = True
elif not skip and '<title' in line:
title = scrapertools.find_single_match(line, r'>([^<]+?)<')
if title == 'EPG non disponibile':
skip = True
elif not skip and '<desc' in line:
plot = scrapertools.find_single_match(line, r'>([^<]+)<')
elif not skip and '<actor' in line:
@@ -248,9 +230,10 @@ def guidatv(item):
thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
elif '</programme' in line:
if not skip:
start = time.strptime(str(int(start.split(' ')[0]) + int(start.split('+')[1])), '%Y%m%d%H%M%S')
stop = time.strptime(str(int(stop.split(' ')[0]) + int(stop.split('+')[1])), '%Y%m%d%H%M%S')
duration = days[start.tm_wday] + ' alle ' + str(start.tm_hour).zfill(2) + ':' + str(start.tm_min).zfill(2) + ' - ' + str(stop.tm_hour).zfill(2) + ':' + str(stop.tm_min).zfill(2) + ' - '
tzHour = int(start.split('+')[1][:2])
start = time.strptime(start.split(' ')[0], '%Y%m%d%H%M%S')
stop = time.strptime(stop.split(' ')[0], '%Y%m%d%H%M%S')
duration = days[start.tm_wday] + ' alle ' + str(start.tm_hour + tzHour).zfill(2) + ':' + str(start.tm_min).zfill(2) + ' - ' + str(stop.tm_hour + tzHour).zfill(2) + ':' + str(stop.tm_min).zfill(2) + ' - '
itemlist.append(Item(
channel=item.channel,
action='new_search',
@@ -285,6 +268,7 @@ def guidatv(item):
start = ''
stop = ''
skip = False
f.close()
return itemlist