Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
1,974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.72 KB | None | 0 0
  1. #-*- coding: utf-8 -*-
  2. #Venom.
  3. from resources.lib.gui.hoster import cHosterGui #system de recherche pour l'hote
  4. from resources.lib.handler.hosterHandler import cHosterHandler #system de recherche pour l'hote
  5. from resources.lib.gui.gui import cGui #system d'affichage pour xbmc
  6. from resources.lib.gui.guiElement import cGuiElement #system d'affichage pour xbmc
  7. from resources.lib.handler.inputParameterHandler import cInputParameterHandler #entrer des parametres
  8. from resources.lib.handler.outputParameterHandler import cOutputParameterHandler #sortis des parametres
  9. from resources.lib.handler.requestHandler import cRequestHandler #requete url
  10. from resources.lib.config import cConfig #config
  11. from resources.lib.parser import cParser #recherche de code
  12. from resources.lib.util import cUtil
  13. import urllib2,urllib,re
  14. import xbmcgui
  15. #from t0mm0.common.net import Net
  16. #import unicodedata
  17.  
  18.  
  19. SITE_IDENTIFIER = 'lapza_com' #identifant nom de votre fichier remplacer les espaces et les . par _ aucun caractere speciale
  20. SITE_NAME = 'Lapza.com' # nom que xbmc affiche
  21. SITE_DESC = 'Film en streaming' #description courte de votre source
  22.  
  23. URL_MAIN = 'http://www.lapza.com' # url de votre source
  24.  
  25. #definis les url pour les catégories principale ceci et automatique si la deffition et présente elle seras afficher.
  26.  
  27. MOVIE_NEWS = ('http://www.lapza.com/iwv/', 'showMovies')
  28.  
  29. MOVIE_GENRES = (True, 'showGenre')
  30.  
  31. URL_SEARCH = ('http://www.lapza.com/iwv/index.php?ordering=&searchphrase=all&Itemid=7&option=com_search&searchword=', 'showMovies')
  32. FUNCTION_SEARCH = 'showMovies'
  33.  
  34.  
  35. def unescape(text):
  36.     def fixup(m):
  37.         text = m.group(0)
  38.         if text[:2] == "&#":
  39.             # character reference
  40.             try:
  41.                 if text[:3] == "&#x":
  42.                     return unichr(int(text[3:-1], 16))
  43.                 else:
  44.                     return unichr(int(text[2:-1]))
  45.             except ValueError:
  46.                 pass
  47.         else:
  48.             # named entity
  49.             try:
  50.                 text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
  51.             except KeyError:
  52.                 pass
  53.         return text # leave as is
  54.     return re.sub("&#?\w+;", fixup, text)
  55.  
  56.  
  57. def load():
  58.     oGui = cGui()
  59.  
  60.     oOutputParameterHandler = cOutputParameterHandler() #apelle la function pour sortir un parametre
  61.     oOutputParameterHandler.addParameter('siteUrl', 'http://venom/') # sortis du parametres siteUrl oublier pas la Majuscule
  62.     oGui.addDir(SITE_IDENTIFIER, 'showSearch', 'Recherche', 'search.png', oOutputParameterHandler)
  63.    
  64.     oOutputParameterHandler = cOutputParameterHandler()
  65.     oOutputParameterHandler.addParameter('siteUrl', MOVIE_NEWS[0])
  66.     oGui.addDir(SITE_IDENTIFIER, MOVIE_NEWS[1], 'Films Nouveaute', 'films.png', oOutputParameterHandler)
  67.    
  68.     oOutputParameterHandler = cOutputParameterHandler()
  69.     oOutputParameterHandler.addParameter('siteUrl', MOVIE_GENRES[0])
  70.     oGui.addDir(SITE_IDENTIFIER, 'showGenre', 'Films Genres', 'genres.png', oOutputParameterHandler)
  71.            
  72.     oGui.setEndOfDirectory() #ferme l'affichage
  73.  
  74. def showSearch():
  75.     oGui = cGui()
  76.  
  77.     sSearchText = oGui.showKeyBoard()
  78.     if (sSearchText != False):
  79.         sUrl = 'http://www.lapza.com/iwv/index.php?ordering=&searchphrase=all&Itemid=7&option=com_search&searchword=' + sSearchText
  80.         showMovies(sUrl)
  81.         oGui.setEndOfDirectory()
  82.         return  
  83.    
  84.    
  85. def showGenre(): #affiche les genres
  86.     oGui = cGui()
  87.  
  88.     #juste a entrer c'est caterorie et les lien qui vont bien
  89.     liste = []
  90.     liste.append( ['Action','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=1:action-&Itemid=6&layout=default'] )
  91.     liste.append( ['Aventure','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=4:aventure-&Itemid=6&layout=default'] )
  92.     liste.append( ['Comedie','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=6:comedie-&Itemid=6&layout=default'] )
  93.     liste.append( ['Drame','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=7:drame-&Itemid=6&layout=default'] )
  94.     liste.append( ['Fantastique','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=8:fantastique-&Itemid=6&layout=default'] )
  95.     liste.append( ['Horreur','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=9:horreur-&Itemid=6&layout=default'] )
  96.     liste.append( ['Policier','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=10:policier-&Itemid=6&layout=default'] )
  97.     liste.append( ['Science fiction','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=11:science-fiction-&Itemid=6&layout=default'] )
  98.     liste.append( ['Thriller','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=12:thriller-&Itemid=6&layout=default'] )
  99.     liste.append( ['Animation','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=2&Itemid=2'] )
  100.     liste.append( ['Documentaires','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=26&Itemid=4'] )
  101.     liste.append( ['Spectacle','http://www.lapza.com/iwv/index.php?option=com_content&view=category&id=3&Itemid=5'] )
  102.                
  103.     for sTitle,sUrl in liste:#boucle
  104.        
  105.         oOutputParameterHandler = cOutputParameterHandler()
  106.         oOutputParameterHandler.addParameter('siteUrl', sUrl)#sortis de l'url en parametre
  107.         oGui.addDir(SITE_IDENTIFIER, 'showMovies', sTitle, 'genres.png', oOutputParameterHandler)
  108.        
  109.     oGui.setEndOfDirectory()
  110.  
  111. def showMovies(sSearch = ''):
  112.     oGui = cGui() #ouvre l'affichage
  113.  
  114.     if sSearch :
  115.         sUrl = sSearch
  116.         sPattern = '<fieldset>(\t|\n)+<div>(?:\t|\n)+<span class="small">(?:\r|\n|.)+?<.span>(\t|\n)+<a href="(.+?)">(\t|\n)+(.+?)<.a>'
  117.     else :
  118.         oInputParameterHandler = cInputParameterHandler()
  119.         sUrl = oInputParameterHandler.getValue('siteUrl')
  120.        
  121.         if (sUrl == 'http://www.lapza.com/iwv/') :
  122.             sPattern = '<a href="(.+?)" class="latestnews">(\t|\n)+(.+?)<.a>'
  123.         else:
  124.             sPattern = '<td>(\t|\n)+<a href="(.+?)">(\t|\n)+(.+?)<.a>'
  125.    
  126.     #print sUrl
  127.    
  128.     oRequestHandler = cRequestHandler(sUrl)
  129.     sHtmlContent = oRequestHandler.request();
  130.        
  131.     #oParser = cParser()
  132.     #aResult = oParser.parse(sHtmlContent, sPattern)
  133.    
  134.     aResult = re.findall(sPattern, sHtmlContent)
  135.    
  136.     #print aResult
  137.    
  138.     if not (aResult == False):
  139.         total = len(aResult)
  140.         dialog = cConfig().createDialog(SITE_NAME)
  141.        
  142.         for aEntry in aResult:
  143.             cConfig().updateDialog(dialog, total)
  144.             if dialog.iscanceled():
  145.                 break
  146.            
  147.             if sSearch:
  148.                 sTitle2 = aEntry[4]
  149.                 sUrl2 = aEntry[2]
  150.             elif sUrl == 'http://www.lapza.com/iwv/' :
  151.                 sTitle2 = aEntry[2]
  152.                 sUrl2 = aEntry[0]
  153.             else :
  154.                 sTitle2 = aEntry[3]
  155.                 sUrl2 = aEntry[1]
  156.                
  157.             #sTitle = sTitle.replace('film ','')
  158.            
  159.             #not found better way
  160.             #sTitle = unicode(sTitle, errors='replace')
  161.             #sTitle = sTitle.encode('ascii', 'ignore').decode('ascii')
  162.            
  163.             oOutputParameterHandler = cOutputParameterHandler()
  164.             oOutputParameterHandler.addParameter('siteUrl', str(URL_MAIN) + str(sUrl2))
  165.             oOutputParameterHandler.addParameter('sMovieTitle', str(sTitle2))
  166.  
  167.             oGui.addMovie(SITE_IDENTIFIER, 'showHosters', sTitle2, '', '', '', oOutputParameterHandler)
  168.  
  169.         cConfig().finishDialog(dialog)
  170.            
  171.         sNextPage = __checkForNextPage(sHtmlContent)#cherche la page suivante
  172.         if (sNextPage != False):
  173.             oOutputParameterHandler = cOutputParameterHandler()
  174.             oOutputParameterHandler.addParameter('siteUrl', sNextPage)
  175.             oGui.addDir(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Next >>>[/COLOR]', 'next.png', oOutputParameterHandler)
  176.             #Ajoute une entrer pour le lien Next | pas de addMisc pas de poster et de description inutile donc
  177.  
  178.     if not sSearch:
  179.         oGui.setEndOfDirectory() #ferme l'affichage
  180.    
  181. def __checkForNextPage(sHtmlContent): #cherche la page suivante
  182.     sPattern = '<a href="([^<]+)" title="Suivant">Suivant<.a>'
  183.     oParser = cParser()
  184.     aResult = oParser.parse(sHtmlContent, sPattern)
  185.     if (aResult[0] == True):
  186.         return str(URL_MAIN) + aResult[1][0]
  187.  
  188.     return False
  189.  
  190. def showHosters():
  191.     oGui = cGui()
  192.    
  193.     sLink = ''
  194.     sThumb = ''
  195.     sComm = ''
  196.    
  197.     oInputParameterHandler = cInputParameterHandler()
  198.     sUrl = oInputParameterHandler.getValue('siteUrl')
  199.     sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
  200.  
  201.     #print sUrl
  202.    
  203.     oRequestHandler = cRequestHandler(sUrl)
  204.     sHtmlContent = oRequestHandler.request();
  205.    
  206.     sPattern = '<div class="article-content">(\t|\n)*<p style="text-align: center;"><img src="(.+?)" border="0"'
  207.     aResult = re.findall(sPattern, sHtmlContent)
  208.     if aResult:
  209.         sThumb = aResult[0][1]
  210.        
  211.     sHtmlContent = sHtmlContent.replace('\r','')
  212.    
  213.     #sPattern = '>>>>> histoire <<<< :(.|\r|)+center;">\r+(.+?)\r+<.p>'
  214.     sPattern = '>>> histoire <<<(?:.+?)center;">(.+?)<.p>(?:.+?)>>>> Illimit'
  215.     aResult = re.findall(sPattern, sHtmlContent)
  216.     if aResult:
  217.         sComm = unescape(aResult[0])
  218.  
  219.     sPattern = 'class="jwts_tabbertab" title="(.+?)">.+?<iframe src="(\/iwv\/.+?)" width='
  220.     aResult = re.findall(sPattern, sHtmlContent)
  221.  
  222.     #Si il n'a pas de selection de qualitéé
  223.     if (aResult == []):
  224.         sPattern = '<iframe src="(\/iwv\/.+?)" width='
  225.         aResult = re.findall(sPattern, sHtmlContent)
  226.         aResult = [('???',aResult[0])]
  227.  
  228.        
  229.     #print aResult
  230.  
  231.     if not (aResult == [] ):
  232.         total = len(aResult)
  233.         dialog = cConfig().createDialog(SITE_NAME)
  234.        
  235.         for aEntry in aResult:
  236.             cConfig().updateDialog(dialog, total)
  237.             if dialog.iscanceled():
  238.                 break
  239.            
  240.             sLink = str(URL_MAIN) + urllib.unquote(aEntry[1]).decode('utf8')
  241.            
  242.             oOutputParameterHandler = cOutputParameterHandler()
  243.             oOutputParameterHandler.addParameter('siteUrl', sLink)
  244.             oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
  245.  
  246.             oGui.addMovie(SITE_IDENTIFIER, 'showHostersLink', '[COLOR teal][' + str(aEntry[0]) + '][/COLOR] ' + sMovieTitle, sThumb, sThumb, sComm, oOutputParameterHandler)
  247.  
  248.         cConfig().finishDialog(dialog)
  249.        
  250.     oGui.setEndOfDirectory()
  251.    
  252. def showHostersLink():
  253.     #En fait ici, tout leur lien sont sur le meme hebergeur d'ou le lien deja traduit
  254.     oGui = cGui()
  255.    
  256.     oInputParameterHandler = cInputParameterHandler()
  257.     sUrl = oInputParameterHandler.getValue('siteUrl')
  258.     sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')  
  259.    
  260.     #recuperation urls
  261.     oRequestHandler = cRequestHandler(sUrl)
  262.     sHtmlContent = oRequestHandler.request()
  263.    
  264.     #fh = open('c:\\test.txt', "w")
  265.     #fh.write(sHtmlContent)
  266.     #fh.close()
  267.    
  268.     url = re.findall('"file":"(.+?)", "label":"(.+?)",', sHtmlContent)
  269.    
  270.     #dialogue final
  271.    
  272.     if (url):
  273.         for aEntry in url:
  274.  
  275.             sTitle = '[COLOR teal][' + str(aEntry[1]) + '][/COLOR] ' + sMovieTitle
  276.             sUrl = aEntry[0]
  277.  
  278.             sHosterUrl = str(sUrl)
  279.             oHoster = cHosterGui().checkHoster(sHosterUrl)
  280.            
  281.             if (oHoster != False):
  282.                 oHoster.setDisplayName(sTitle)
  283.                 oHoster.setFileName(sTitle)
  284.                 cHosterGui().showHoster(oGui, oHoster, sHosterUrl, '')
  285.            
  286.         oGui.setEndOfDirectory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement