forked from STI/Astroport.ONE
204 lines
7.9 KiB
Python
204 lines
7.9 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# vStream https://github.com/Kodi-vStream/venom-xbmc-addons
|
||
|
|
||
|
import re
|
||
|
|
||
|
from resources.lib.gui.hoster import cHosterGui
|
||
|
from resources.lib.gui.gui import cGui
|
||
|
from resources.lib.handler.inputParameterHandler import cInputParameterHandler
|
||
|
from resources.lib.handler.outputParameterHandler import cOutputParameterHandler
|
||
|
from resources.lib.handler.requestHandler import cRequestHandler
|
||
|
from resources.lib.parser import cParser
|
||
|
from resources.lib.comaddon import siteManager
|
||
|
from resources.lib.util import cUtil
|
||
|
|
||
|
SITE_IDENTIFIER = 'kstreamingfilm'
|
||
|
SITE_NAME = 'K Streaming Film'
|
||
|
SITE_DESC = 'Films en streaming français sur internet.'
|
||
|
|
||
|
URL_MAIN = siteManager().getUrlMain(SITE_IDENTIFIER)
|
||
|
|
||
|
MOVIE_MOVIE = (True, 'load')
|
||
|
MOVIE_NEWS = (URL_MAIN, 'showMovies')
|
||
|
MOVIE_GENRES = (True, 'showGenres')
|
||
|
MOVIE_ANNEES = (True, 'showYears')
|
||
|
|
||
|
URL_SEARCH = (URL_MAIN + '?s=', 'showMovies')
|
||
|
URL_SEARCH_MOVIES = (URL_SEARCH[0], 'showMovies')
|
||
|
FUNCTION_SEARCH = 'showMovies'
|
||
|
|
||
|
|
||
|
def load():
|
||
|
oGui = cGui()
|
||
|
|
||
|
oOutputParameterHandler = cOutputParameterHandler()
|
||
|
oOutputParameterHandler.addParameter('siteUrl', 'http://venom/')
|
||
|
oGui.addDir(SITE_IDENTIFIER, 'showSearch', 'Recherche', 'search.png', oOutputParameterHandler)
|
||
|
|
||
|
oOutputParameterHandler.addParameter('siteUrl', MOVIE_NEWS[0])
|
||
|
oGui.addDir(SITE_IDENTIFIER, MOVIE_NEWS[1], 'Films (Derniers ajouts)', 'news.png', oOutputParameterHandler)
|
||
|
|
||
|
oOutputParameterHandler.addParameter('siteUrl', MOVIE_GENRES[0])
|
||
|
oGui.addDir(SITE_IDENTIFIER, MOVIE_GENRES[1], 'Films (Genres)', 'genres.png', oOutputParameterHandler)
|
||
|
|
||
|
oOutputParameterHandler.addParameter('siteUrl', MOVIE_ANNEES[0])
|
||
|
oGui.addDir(SITE_IDENTIFIER, MOVIE_ANNEES[1], 'Films (Années)', 'annees.png', oOutputParameterHandler)
|
||
|
|
||
|
oGui.setEndOfDirectory()
|
||
|
|
||
|
|
||
|
def showSearch():
|
||
|
oGui = cGui()
|
||
|
|
||
|
sSearchText = oGui.showKeyBoard()
|
||
|
if sSearchText != False:
|
||
|
sUrl = URL_SEARCH[0] + sSearchText.replace(' ', '+')
|
||
|
showMovies(sUrl)
|
||
|
oGui.setEndOfDirectory()
|
||
|
return
|
||
|
|
||
|
|
||
|
def showGenres():
|
||
|
oGui = cGui()
|
||
|
|
||
|
liste = [['Action', 'action'], ['Afro', 'afro'], ['Animation', 'animation'], ['Arts Martiaux', 'art-martiaux'],
|
||
|
['Aventure', 'aventure'], ['Biographique', 'biographique'], ['Biopic', 'biopic'], ['Comédie', 'comedie'],
|
||
|
['Comédie dramatique', 'comedie-dramatique'], ['Comédie musicale', 'comedie-musicale'], ['Crime', 'crime'],
|
||
|
['Divers', 'divers'], ['Documentaire', 'documentaire'], ['Drame', 'drame'],
|
||
|
['Epouvante-horreur', 'epouvante-horreur'], ['Erotique', 'erotique'], ['Espionnage', 'espionnage'],
|
||
|
['Famille', 'famille'], ['Fantastique', 'fantastique'], ['Film-musical', 'film-musical'],
|
||
|
['Guerre', 'guerre'], ['Historique', 'historique'], ['Horreur', 'horreur'], ['Judiciaire', 'judiciaire'],
|
||
|
['Musical', 'musical'], ['Mystère', 'mystere'], ['Non classé', 'non-classe'], ['Policier', 'policier'],
|
||
|
['Romance', 'romance'], ['Science fiction', 'science-fiction'], ['Slasher', 'slasher'],
|
||
|
['Sport', 'sport-event'], ['Terreur', 'thrillerterreur'], ['Thriller', 'thriller'], ['Western', 'western']]
|
||
|
|
||
|
oOutputParameterHandler = cOutputParameterHandler()
|
||
|
for sTitle, sUrl in liste:
|
||
|
oOutputParameterHandler.addParameter('siteUrl', URL_MAIN + sUrl + '/')
|
||
|
oGui.addDir(SITE_IDENTIFIER, 'showMovies', sTitle, 'genres.png', oOutputParameterHandler)
|
||
|
|
||
|
oGui.setEndOfDirectory()
|
||
|
|
||
|
|
||
|
def showYears():
|
||
|
oGui = cGui()
|
||
|
oOutputParameterHandler = cOutputParameterHandler()
|
||
|
for i in reversed(range(1935, 2022)):
|
||
|
sYear = str(i)
|
||
|
oOutputParameterHandler.addParameter('siteUrl', URL_MAIN + 'release/' + sYear )
|
||
|
oGui.addDir(SITE_IDENTIFIER, 'showMovies', sYear, 'annees.png', oOutputParameterHandler)
|
||
|
oGui.setEndOfDirectory()
|
||
|
|
||
|
|
||
|
def showMovies(sSearch=''):
|
||
|
oGui = cGui()
|
||
|
if sSearch:
|
||
|
oUtil = cUtil()
|
||
|
sSearchText = sSearch.replace(URL_SEARCH_MOVIES[0], '')
|
||
|
sSearchText = oUtil.CleanName(sSearchText)
|
||
|
sUrl = sSearch
|
||
|
else:
|
||
|
oInputParameterHandler = cInputParameterHandler()
|
||
|
sUrl = oInputParameterHandler.getValue('siteUrl')
|
||
|
|
||
|
if 'release/' in sUrl or sSearch:
|
||
|
sPattern = 'center-icons".+?src="([^"]+)" alt="([^"]+).+?href="([^"]+).+?movie-release">([^<]*)'
|
||
|
else:
|
||
|
sPattern = 'center-icons".+?src="([^"]+)" alt="([^"]+).+?href="([^"]+).+?movie-release">([^<]*).+?story\'>([^<]+).+?movie-cast'
|
||
|
|
||
|
oRequestHandler = cRequestHandler(sUrl)
|
||
|
sHtmlContent = oRequestHandler.request()
|
||
|
oParser = cParser()
|
||
|
|
||
|
if 'Derniers films ajoutés' in sHtmlContent:
|
||
|
sStart = 'Derniers films ajoutés'
|
||
|
sEnd = 'Film streaming les plus populaires'
|
||
|
sHtmlContent = oParser.abParse(sHtmlContent, sStart, sEnd)
|
||
|
|
||
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
||
|
|
||
|
if aResult[0] is False:
|
||
|
oGui.addText(SITE_IDENTIFIER)
|
||
|
else:
|
||
|
oOutputParameterHandler = cOutputParameterHandler()
|
||
|
for aEntry in aResult[1]:
|
||
|
sThumb = aEntry[0]
|
||
|
sTitle = aEntry[1]
|
||
|
sUrl = aEntry[2]
|
||
|
sYear = aEntry[3].replace(' ', '')
|
||
|
sDesc = ''
|
||
|
|
||
|
if sSearch: # Filtre de recherche
|
||
|
if not oUtil.CheckOccurence(sSearchText, sTitle):
|
||
|
continue
|
||
|
|
||
|
if len(aEntry) > 4:
|
||
|
sDesc = aEntry[4]
|
||
|
sDisplayTitle = sTitle + ' (' + sYear + ')'
|
||
|
|
||
|
oOutputParameterHandler.addParameter('siteUrl', sUrl)
|
||
|
oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
|
||
|
oOutputParameterHandler.addParameter('sThumb', sThumb)
|
||
|
oOutputParameterHandler.addParameter('sYear', sYear)
|
||
|
oOutputParameterHandler.addParameter('sDesc', sDesc)
|
||
|
|
||
|
oGui.addMovie(SITE_IDENTIFIER, 'showHosters', sDisplayTitle, '', sThumb, sDesc, oOutputParameterHandler)
|
||
|
|
||
|
if not sSearch:
|
||
|
sNextPage, sPaging = __checkForNextPage(sHtmlContent)
|
||
|
if sNextPage != False:
|
||
|
oOutputParameterHandler = cOutputParameterHandler()
|
||
|
oOutputParameterHandler.addParameter('siteUrl', sNextPage)
|
||
|
oGui.addNext(SITE_IDENTIFIER, 'showMovies', 'Page ' + sPaging, oOutputParameterHandler)
|
||
|
|
||
|
oGui.setEndOfDirectory()
|
||
|
|
||
|
|
||
|
def __checkForNextPage(sHtmlContent):
|
||
|
sPattern = '>([^<]+)</a></div><div class="naviright"><a href="([^"]+?)">Suivant'
|
||
|
oParser = cParser()
|
||
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
||
|
if aResult[0] is True:
|
||
|
sNumberMax = aResult[1][0][0]
|
||
|
sNextPage = aResult[1][0][1]
|
||
|
sNumberNext = re.search('page.([0-9]+)', sNextPage).group(1)
|
||
|
sPaging = sNumberNext + '/' + sNumberMax
|
||
|
return sNextPage, sPaging
|
||
|
|
||
|
return False, 'none'
|
||
|
|
||
|
|
||
|
def showHosters():
|
||
|
oGui = cGui()
|
||
|
|
||
|
oInputParameterHandler = cInputParameterHandler()
|
||
|
sUrl = oInputParameterHandler.getValue('siteUrl')
|
||
|
sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
|
||
|
sThumb = oInputParameterHandler.getValue('sThumb')
|
||
|
|
||
|
oRequestHandler = cRequestHandler(sUrl)
|
||
|
sHtmlContent = oRequestHandler.request()
|
||
|
|
||
|
sPattern = '<iframe.+?src="([^"]+)"'
|
||
|
|
||
|
oParser = cParser()
|
||
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
||
|
|
||
|
if aResult[0] is True:
|
||
|
list_hoster = []
|
||
|
for aEntry in aResult[1]:
|
||
|
|
||
|
sHosterUrl = aEntry.strip()
|
||
|
if sHosterUrl not in list_hoster:
|
||
|
list_hoster.append(sHosterUrl)
|
||
|
else:
|
||
|
continue
|
||
|
|
||
|
oHoster = cHosterGui().checkHoster(sHosterUrl)
|
||
|
if oHoster != False:
|
||
|
oHoster.setDisplayName(sMovieTitle)
|
||
|
oHoster.setFileName(sMovieTitle)
|
||
|
cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb)
|
||
|
|
||
|
oGui.setEndOfDirectory()
|