forked from axiom-team/astrXbian
270 lines
9.4 KiB
Python
270 lines
9.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# vStream https://github.com/Kodi-vStream/venom-xbmc-addons
|
|
# Arias800
|
|
|
|
import json
|
|
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 progress#, VSlog
|
|
|
|
|
|
SITE_IDENTIFIER = 'neko_sama'
|
|
SITE_NAME = 'Neko Sama'
|
|
SITE_DESC = 'anime en streaming'
|
|
|
|
URL_MAIN = 'https://www.neko-sama.fr/'
|
|
|
|
URL_SEARCH = (URL_MAIN + 'animes-search.json', 'showSearchResult')
|
|
URL_SEARCH_SERIES = (URL_SEARCH[0], 'showSearchResult')
|
|
FUNCTION_SEARCH = 'showSearchResult'
|
|
|
|
ANIM_ANIMS = ('http://', 'load')
|
|
ANIM_POPULAR = (URL_MAIN + 'anime/', 'showMovies')
|
|
|
|
|
|
def load():
|
|
oGui = cGui()
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', 'http://venom/')
|
|
oGui.addDir(SITE_IDENTIFIER, 'showSearch', 'Recherche', 'search.png', oOutputParameterHandler)
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', ANIM_POPULAR[0])
|
|
oGui.addDir(SITE_IDENTIFIER, ANIM_POPULAR[1], 'Animés (Populaire)', 'animes.png', oOutputParameterHandler)
|
|
|
|
oGui.setEndOfDirectory()
|
|
|
|
|
|
def showSearch():
|
|
oGui = cGui()
|
|
sSearchText = oGui.showKeyBoard()
|
|
if (sSearchText != False):
|
|
showSearchResult(sSearchText)
|
|
oGui.setEndOfDirectory()
|
|
return
|
|
|
|
|
|
def showGenres():
|
|
oGui = cGui()
|
|
|
|
liste = []
|
|
liste.append(['Action', URL_MAIN + 'action/'])
|
|
liste.append(['Animation', URL_MAIN + 'animation/'])
|
|
liste.append(['Arts Martiaux', URL_MAIN + 'arts-martiaux/'])
|
|
liste.append(['Aventure', URL_MAIN + 'aventure/'])
|
|
liste.append(['Biopic', URL_MAIN + 'biopic/'])
|
|
liste.append(['Comédie', URL_MAIN + 'comedie/'])
|
|
liste.append(['Comédie Dramatique', URL_MAIN + 'comedie-dramatique/'])
|
|
liste.append(['Comédie Musicale', URL_MAIN + 'comedie-musicale/'])
|
|
liste.append(['Documentaire', URL_MAIN + 'documentaire/'])
|
|
liste.append(['Drame', URL_MAIN + 'drame/'])
|
|
liste.append(['Epouvante Horreur', URL_MAIN + 'epouvante-horreur/'])
|
|
liste.append(['Erotique', URL_MAIN + 'erotique'])
|
|
liste.append(['Espionnage', URL_MAIN + 'espionnage/'])
|
|
liste.append(['Famille', URL_MAIN + 'famille/'])
|
|
liste.append(['Fantastique', URL_MAIN + 'fantastique/'])
|
|
liste.append(['Guerre', URL_MAIN + 'guerre/'])
|
|
liste.append(['Historique', URL_MAIN + 'historique/'])
|
|
liste.append(['Musical', URL_MAIN + 'musical/'])
|
|
liste.append(['Policier', URL_MAIN + 'policier/'])
|
|
liste.append(['Péplum', URL_MAIN + 'peplum/'])
|
|
liste.append(['Romance', URL_MAIN + 'romance/'])
|
|
liste.append(['Science Fiction', URL_MAIN + 'science-fiction/'])
|
|
liste.append(['Spectacle', URL_MAIN + 'spectacle/'])
|
|
liste.append(['Thriller', URL_MAIN + 'thriller/'])
|
|
liste.append(['Western', URL_MAIN + 'western/'])
|
|
liste.append(['Divers', URL_MAIN + 'divers/'])
|
|
|
|
for sTitle, sUrl in liste:
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', sUrl)
|
|
oGui.addDir(SITE_IDENTIFIER, 'showMovies', sTitle, 'genres.png', oOutputParameterHandler)
|
|
|
|
oGui.setEndOfDirectory()
|
|
|
|
|
|
def parseJson(json_object, sSearch):
|
|
# Parse le json pour recuperer les elements qui contiennent sSearch dans leurs titre
|
|
Title = []
|
|
Url = []
|
|
Thumb = []
|
|
|
|
for dicts in json_object:
|
|
if sSearch in dicts['title'].lower() or sSearch in dicts['title_english'].lower() or sSearch in dicts['others'].lower():
|
|
Title.append(dicts['title'])
|
|
Url.append(dicts['url'])
|
|
Thumb.append(dicts['url_image'])
|
|
|
|
return Title, Url, Thumb
|
|
|
|
|
|
def showSearchResult(sSearch):
|
|
oGui = cGui()
|
|
oRequestHandler = cRequestHandler(URL_SEARCH[0])
|
|
|
|
sSearch = sSearch.lower()
|
|
data = json.loads(oRequestHandler.request())
|
|
|
|
Title, Url, Thumb = parseJson(data, sSearch)
|
|
total = len(Title)
|
|
progress_ = progress().VScreate(SITE_NAME)
|
|
for title, url, thumb in zip(Title, Url, Thumb):
|
|
progress_.VSupdate(progress_, total)
|
|
if progress_.iscanceled():
|
|
break
|
|
|
|
sTitle = title
|
|
sUrl2 = URL_MAIN + url
|
|
sThumb = thumb
|
|
sDesc = ''
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', sUrl2)
|
|
oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
|
|
oOutputParameterHandler.addParameter('sThumb', sThumb)
|
|
|
|
oGui.addAnime(SITE_IDENTIFIER, 'ShowSerieSaisonEpisodes', sTitle, '', sThumb, sDesc, oOutputParameterHandler)
|
|
|
|
progress_.VSclose(progress_)
|
|
|
|
if not sSearch:
|
|
oGui.setEndOfDirectory()
|
|
|
|
|
|
def showMovies():
|
|
oGui = cGui()
|
|
oParser = cParser()
|
|
|
|
oInputParameterHandler = cInputParameterHandler()
|
|
sUrl = oInputParameterHandler.getValue('siteUrl')
|
|
|
|
oRequestHandler = cRequestHandler(sUrl)
|
|
sHtmlContent = oRequestHandler.request()
|
|
sPattern = '<a href="([^"]+)"><div class="nekosama-lazy-wrapper">.+?<img src="#" data-src="([^"]+)" alt="([^"]+)"'
|
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
|
|
|
if (aResult[0] == False):
|
|
oGui.addText(SITE_IDENTIFIER)
|
|
|
|
if (aResult[0] == True):
|
|
total = len(aResult[1])
|
|
progress_ = progress().VScreate(SITE_NAME)
|
|
|
|
for aEntry in aResult[1]:
|
|
progress_.VSupdate(progress_, total)
|
|
if progress_.iscanceled():
|
|
break
|
|
|
|
sUrl2 = URL_MAIN + aEntry[0]
|
|
sThumb = aEntry[1]
|
|
sTitle = aEntry[2]
|
|
sDesc = ''
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', sUrl2)
|
|
oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
|
|
oOutputParameterHandler.addParameter('sThumb', sThumb)
|
|
|
|
oGui.addAnime(SITE_IDENTIFIER, 'ShowSerieSaisonEpisodes', sTitle, '', sThumb, sDesc, oOutputParameterHandler)
|
|
|
|
progress_.VSclose(progress_)
|
|
|
|
sNextPage = __checkForNextPage(sHtmlContent)
|
|
if (sNextPage != False):
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', sNextPage)
|
|
number = re.search('/([0-9]+)', sNextPage).group(1)
|
|
oGui.addNext(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Page ' + number + ' >>>[/COLOR]', oOutputParameterHandler)
|
|
|
|
oGui.setEndOfDirectory()
|
|
|
|
|
|
def __checkForNextPage(sHtmlContent):
|
|
oParser = cParser()
|
|
sPattern = '<a href="([^"]+)" class="">\s*<svg'
|
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
|
|
|
if (aResult[0] == True):
|
|
return URL_MAIN + str(aResult[1][0])
|
|
|
|
return False
|
|
|
|
|
|
def ShowSerieSaisonEpisodes():
|
|
oGui = cGui()
|
|
oParser = cParser()
|
|
|
|
oInputParameterHandler = cInputParameterHandler()
|
|
sUrl = oInputParameterHandler.getValue('siteUrl')
|
|
sThumb = oInputParameterHandler.getValue('sThumb')
|
|
sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
|
|
|
|
oRequestHandler = cRequestHandler(sUrl)
|
|
sHtmlContent = oRequestHandler.request()
|
|
|
|
sDesc = ''
|
|
try:
|
|
sPattern = '<p>([^"]+)</p>'
|
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
|
if aResult[0]:
|
|
sDesc = aResult[1][0]
|
|
except:
|
|
pass
|
|
|
|
sPattern = '"episode":"([^"]+)".+?"url":"([^"]+)","url_image":"([^"]+)"'
|
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
|
|
|
if (aResult[0] == True):
|
|
for aEntry in aResult[1]:
|
|
sTitle = sMovieTitle + ' ' + aEntry[0].replace('Ep. ', 'E')
|
|
sUrl2 = URL_MAIN + aEntry[1].replace('\\/', '/')
|
|
sThumb = aEntry[2]
|
|
|
|
oOutputParameterHandler = cOutputParameterHandler()
|
|
oOutputParameterHandler.addParameter('siteUrl', sUrl2)
|
|
oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
|
|
oOutputParameterHandler.addParameter('sThumb', sThumb)
|
|
|
|
oGui.addEpisode(SITE_IDENTIFIER, 'seriesHosters', sTitle, '', sThumb, sDesc, oOutputParameterHandler)
|
|
|
|
oGui.setEndOfDirectory()
|
|
|
|
|
|
def seriesHosters():
|
|
oGui = cGui()
|
|
oInputParameterHandler = cInputParameterHandler()
|
|
sUrl = oInputParameterHandler.getValue('siteUrl')
|
|
sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
|
|
sThumb = oInputParameterHandler.getValue('sThumb')
|
|
|
|
oRequestHandler = cRequestHandler(sUrl)
|
|
sHtmlContent = oRequestHandler.request()
|
|
|
|
sPattern = "video\[\d+\] = \'([^']+)\'"
|
|
oParser = cParser()
|
|
aResult = oParser.parse(sHtmlContent, sPattern)
|
|
|
|
if (aResult[0] == True):
|
|
for aEntry in aResult[1]:
|
|
|
|
sHosterUrl = aEntry
|
|
# Enleve les faux liens
|
|
if 'openload' in aEntry and not '.mp4' in aEntry:
|
|
continue
|
|
|
|
oHoster = cHosterGui().checkHoster(sHosterUrl)
|
|
if (oHoster != False):
|
|
oHoster.setDisplayName(sMovieTitle)
|
|
oHoster.setFileName(sMovieTitle)
|
|
cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb)
|
|
|
|
oGui.setEndOfDirectory()
|