diff --git a/channels/streamtime.json b/channels/streamtime.json index c0a8b2e6..674d57ed 100644 --- a/channels/streamtime.json +++ b/channels/streamtime.json @@ -2,52 +2,10 @@ "id": "streamtime", "name": "StreamTime", "language": ["ita"], - "active": false, + "active": true, "adult": false, - "thumbnail": "", - "banner": "streamtime.png", + "thumbnail": "streamtime.png", + "banner": "", "categories": ["tvshow", "movie"], - "settings": [ - { - "id": "include_in_global_search", - "type": "bool", - "label": "Includi in Ricerca Globale", - "default": true, - "enabled": true, - "visible": true - }, - { - "id": "include_in_newest_peliculas", - "type": "bool", - "label": "Includi in Novità - Film", - "default": true, - "enabled": true, - "visible": true - }, - { - "id": "include_in_newest_italiano", - "type": "bool", - "label": "Includi in Novità - Italiano", - "default": true, - "enabled": true, - "visible": true - }, - { - "id": "checklinks", - "type": "bool", - "label": "Verifica se i link esistono", - "default": false, - "enabled": true, - "visible": true - }, - { - "id": "checklinks_number", - "type": "list", - "label": "Numero di link da verificare", - "default": 1, - "enabled": true, - "visible": "eq(-1,true)", - "lvalues": [ "5", "10", "15", "20" ] - } - ] + "settings": [] } diff --git a/channels/streamtime.py b/channels/streamtime.py index c1191f53..d4032c8d 100644 --- a/channels/streamtime.py +++ b/channels/streamtime.py @@ -3,6 +3,12 @@ from core import support, httptools, scrapertoolsV2 from core.item import Item from platformcode import config, logger + +""" +Nota per i tester: questo non è un canale 'tradizionale', essendo un canale telegram, i cui contenuti (film/serie) sono mischiati tra loro (ed a volte ci sono messaggi sponsor), +la lista delle pagine non sarà affatto 'uniforme' (a seconda di come viene presentata la preview) +""" + __channel__ = "streamtime" host = config.get_channel_url(__channel__) headers = [['Referer', 'org.telegram.messenger']] @@ -20,7 +26,7 @@ def mainlist(item): @support.scrape def peliculas(item): - patron = """tgme_widget_message_photo_wrap blured.*?image:url\("(?P[^"]+).*?(?:🎥|🎬)(?P.*?)(?:🎥|🎬).*?(?:Audio(?:</b>)?: (?P<lang>.*?<br>))?.*?Anno(?:</b>)?: (?P<year>[0-9]{4}).*?(?:<b>Stream</b>|Risoluzione|<b>Tipo</b>): (?P<quality>[^<]+).*?tgme_widget_message_inline_button url_button" href="(?P<url>[^"]+)""" + patron = """tgme_widget_message_photo_wrap blured.*?image:url\("(?P<thumbnail>[^"]+).*?//telegram\.org/img/emoji/40/(?:F09F8EAC|F09F8EA5)\.png"\)">.*?</i>\s?(?:<b>)?(?P<title>[^<]+).*?(?:Audio(?:</b>)?: (?P<lang>.*?<br>))?.*?Anno(?:</b>)?: (?P<year>[0-9]{4}).*?(?:<b>Stream</b>|Risoluzione|<b>Tipo</b>|Tipo|Stream): (?P<quality>[^<]+).*?tgme_widget_message_inline_button url_button" href="(?P<url>[^"]+)""" def itemlistHook(itemlist): retItemlist = [] # filtro per tipo @@ -32,35 +38,32 @@ def peliculas(item): if '/SerieTv/' in i.url: retItemlist.append(i) # rimuovo duplicati - if item.contentType != 'movie': + if item.contentType != 'movie' and not item.cercaSerie: nonDupl = [] - # support.dbg() for i in retItemlist: for nd in nonDupl: - if i.title == nd.title: + if i.fulltitle == nd.fulltitle: break else: - daAgg = i - spl1 = i.url.split('-') - stagione1 = spl1[-2] - nEp1 = int(spl1[-1]) - - for i2 in retItemlist[1:]: - if i.title == i2.title: - spl2 = i2.url.split('-') - stagione2 = spl2[-2] - nEp2 = int(spl2[-1]) - if stagione1 == stagione2 and nEp2 > nEp1: - daAgg = i2 - nonDupl.append(daAgg) + nonDupl.append(i) retItemlist = nonDupl return retItemlist[::-1] # debug = True - patronNext = 'tgme_widget_message_photo_wrap blured" href="([^"]+)' - def fullItemlistHook(itemlist): - msgId = int(itemlist[-1].url.split('/')[-1]) - itemlist[-1].url = host + '?before=' + str(msgId) + '&after=' + str(msgId-20) - return itemlist + # nella ricerca faccio finta che non ci siano "pagine successive", sarebbe un casino gestirle (ed è piuttosto improbabile) + if item.action != 'search' and item.action: + patronNext = 'tgme_widget_message_photo_wrap blured" href="([^"]+)' + + # trovo l'id dell'ultimo messaggio e nella pagina successiva ci metto il link per prendere i 20 msg precedenti + def fullItemlistHook(itemlist): + msgId = int(itemlist[-1].url.split('/')[-1]) + itemlist[-1].url = host + '?before=' + str(msgId) + '&after=' + str(msgId-20) + return itemlist + + # necessario per togliere html vario dal titolo (operazione fatta solo su fulltitle) + def itemHook(item): + item.contentTitle = item.fulltitle + item.show = item.fulltitle + return item if item.contentType == 'tvshow': action = 'episodios' @@ -79,29 +82,59 @@ def search(item, texto): return [] +def newest(categoria): + item = Item() + if categoria == "series": + item.contentType = 'tvshow' + item.url = host + '?q=%23SerieTv' + else: + item.contentType = 'movie' + item.url = host + '?q=%23Film' + return peliculas(item) + + +# cerco il titolo, così mi escono fuori tutti i messaggi contenenti puntate singole o serie def episodios(item): - domain, id, season, episode = scrapertoolsV2.find_single_match(item.url, r'(https?://[a-z0-9.-]+).*?/([^-/]+)-S([0-9]+)-([0-9]+)$') + url = item.url + item.cercaSerie = True + itemlist = search(item, item.fulltitle) + stagioni = {} + + for i in itemlist[:-1]: + spl1 = i.url.split('-') + st = spl1[-2] + nEp = int(spl1[-1]) + if st not in stagioni.keys(): + stagioni[st] = nEp + elif nEp > stagioni[st]: + stagioni[st] = nEp + itemlist = [] - for n in range(1, int(episode)): - url = domain + '/play_s.php?s=' + id + '-S' + season + '&e=' + str(n) - itemlist.append( - Item(channel=item.channel, - action="findvideos", - title=str(int(season)) + 'x' + str(n) + support.typo(item.quality, '-- [] color kod'), - url=url, - fulltitle=item.fulltitle, - thumbnail=item.thumbnail, - show=item.show, - quality=item.quality, - contentType=item.contentType, - folder=False, - args={'id': id, 'season': season, 'episode': episode})) + domain, id, season, episode = scrapertoolsV2.find_single_match(url, r'(https?://[a-z0-9.-]+).*?/([^-/]+)-S([0-9]+)-([0-9]+)$') + for st in stagioni.keys(): + season = st[1:] + episode = stagioni[st] + for n in range(1, int(episode)): + url = domain + '/play_s.php?s=' + id + '-S' + season + '&e=' + str(n) + itemlist.append( + Item(channel=item.channel, + action="findvideos", + title=str(int(season)) + 'x' + str(n) + support.typo(item.quality, '-- [] color kod'), + url=url, + fulltitle=item.fulltitle, + thumbnail=item.thumbnail, + show=item.show, + quality=item.quality, + contentType='episode', + folder=False, + args={'id': id, 'season': season, 'episode': episode})) support.videolibrary(itemlist, item) return itemlist def findvideos(item): + # support.dbg() domain = scrapertoolsV2.find_single_match(item.url, 'https?://[a-z0-9.-]+') if item.contentType == 'movie': id = item.url.split('/')[-1] @@ -109,25 +142,22 @@ def findvideos(item): else: url = item.url id = item.args['id'] - season = item.args['season'] - episode = item.args['episode'] - res = support.match(item, 'src="([^"]+)">.*?</video>', url=url, headers=[['Referer', domain]]) + season = str(item.args['season']) + episode = str(item.args['episode']) + res = support.match(item, 'src="([^"]+)"[^>]*></video>', url=url, headers=[['Referer', domain]]) itemlist = [] - support.dbg() if res[0]: itemlist.append( Item(channel=item.channel, action="play", - title='stpgs.ml' + support.typo(item.quality, '-- [] color kod'), + title='contentful', url=res[0][0], server='directo', fulltitle=item.fulltitle, thumbnail=item.thumbnail, - show=item.show, quality=item.quality, - contentType=item.contentType, - folder=False)) + contentType=item.contentType)) download = itemlist[0].clone() if item.contentType == 'movie': download.url = downPrefix + id @@ -137,5 +167,4 @@ def findvideos(item): else: # google drive... pass - support.videolibrary(itemlist, item) - return support.controls(itemlist, item, True, True) + return support.server(item, itemlist=itemlist)