Advertisement
mino60

Untitled

Jul 8th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 14.92 KB | None | 0 0
  1. #-*- coding: utf-8 -*-
  2. #Venom.
  3. from resources.lib.gui.hoster import cHosterGui
  4. from resources.lib.handler.hosterHandler import cHosterHandler
  5. from resources.lib.gui.gui import cGui
  6. from resources.lib.gui.guiElement import cGuiElement
  7. from resources.lib.handler.inputParameterHandler import cInputParameterHandler
  8. from resources.lib.handler.outputParameterHandler import cOutputParameterHandler
  9. from resources.lib.handler.requestHandler import cRequestHandler
  10. from resources.lib.config import cConfig
  11. from resources.lib.parser import cParser
  12. from resources.lib.util import cUtil
  13. import urllib2,urllib,re
  14. import unicodedata,htmlentitydefs
  15.  
  16. #Je garde le nom kepliz pour pas perturber
  17. SITE_IDENTIFIER = 'kepliz_com'
  18. SITE_NAME = 'Kepliz'
  19. SITE_DESC = 'Film en streaming'
  20. URL_HOST = 'http://www.grudal.com/'
  21.  
  22. URL_MAIN = 'URL_MAIN'
  23. FILMPATTERN = '<div class="article-content"><p style="text-align: center;"><img src="(.+?)" border.+?<p style="text-align: left;">([^<>]+?)<\/p>'
  24. SEARCHPATTERN = '<fieldset> *<div> *<b><a *href="\/[0-9a-zA-Z]+\/(.+?)" *>(.+?)<\/a><\/b>'
  25. NORMALPATTERN = '<span style="list-style-type:none;" >.+? href="\/[0-9a-zA-Z]+\/(.+?)">(.+?)<\/a>'
  26. NEXTPAGEPATTERN = '<span class="pagenav">[0-9]+<.span><.li><li><a title=".+?" href="\/[0-9a-zA-Z]+\/(.+?)" class="pagenav">'
  27. FRAMEPATTERN = 'GRUDALpluginsphp\("player1",{link:"(.+?)"}\);'
  28. FRAMEPATTERN2 = '<iframe src="*\/([^<>"]+\/player\.php\?id=.+?)"'
  29. HOSTPATTERN = '"link":"([^"]+?)","label":"([^"]+?)"'
  30.  
  31. #pour l'addon
  32. MOVIE_NEWS = (URL_MAIN, 'showMovies')
  33. MOVIE_GENRES = (True, 'showGenre')
  34. MOVIE_HD = (URL_MAIN, 'showMovies')
  35.  
  36.  
  37. DOC_NEWS = (URL_MAIN + 'index.php?option=com_content&view=category&id=26', 'showMovies')
  38. DOC_DOCS = ('http://', 'load')
  39.  
  40. URL_SEARCH = (URL_MAIN + 'index.php?ordering=&searchphrase=all&Itemid=1&option=com_search&searchword=', 'showMovies')
  41. FUNCTION_SEARCH = 'showMovies'
  42.  
  43. def load():
  44.     oGui = cGui()
  45.  
  46.     oOutputParameterHandler = cOutputParameterHandler()
  47.     oOutputParameterHandler.addParameter('siteUrl', 'http://venom/')
  48.     oGui.addDir(SITE_IDENTIFIER, 'showSearch', 'Recherche', 'search.png', oOutputParameterHandler)
  49.    
  50.     oOutputParameterHandler = cOutputParameterHandler()
  51.     oOutputParameterHandler.addParameter('siteUrl', MOVIE_NEWS[0])
  52.     oGui.addDir(SITE_IDENTIFIER, MOVIE_NEWS[1], 'Films Nouveautés', 'films.png', oOutputParameterHandler)
  53.    
  54.     oOutputParameterHandler = cOutputParameterHandler()
  55.     oOutputParameterHandler.addParameter('siteUrl', MOVIE_GENRES[0])
  56.     oGui.addDir(SITE_IDENTIFIER, MOVIE_GENRES[1], 'Films Genres', 'genres.png', oOutputParameterHandler)
  57.    
  58.     oOutputParameterHandler = cOutputParameterHandler()
  59.     oOutputParameterHandler.addParameter('siteUrl', DOC_NEWS[0])
  60.     oGui.addDir(SITE_IDENTIFIER, DOC_NEWS[1], 'Documentaires', 'doc.png', oOutputParameterHandler)
  61.            
  62.     oGui.setEndOfDirectory()
  63.  
  64. def showSearch():
  65.     oGui = cGui()
  66.  
  67.     sSearchText = oGui.showKeyBoard()
  68.     if (sSearchText != False):
  69.         sUrl = URL_MAIN + 'index.php?ordering=&searchphrase=all&Itemid=1&option=com_search&searchword=' + sSearchText
  70.         showMovies(sUrl)
  71.         oGui.setEndOfDirectory()
  72.         return  
  73.    
  74.    
  75. def showGenre():
  76.     oGui = cGui()
  77.  
  78.     liste = []
  79.     liste.append( ['A l affiche',URL_MAIN + 'index.php?option=com_content&view=category&id=29'] )
  80.     liste.append( ['Action',URL_MAIN + 'index.php?option=com_content&view=category&id=1'] )
  81.     liste.append( ['Aventure',URL_MAIN + 'index.php?option=com_content&view=category&id=4'] )
  82.     liste.append( ['Comedie',URL_MAIN + 'index.php?option=com_content&view=category&id=6'] )
  83.     liste.append( ['Drame',URL_MAIN + 'index.php?option=com_content&view=category&id=7'] )
  84.     liste.append( ['Epouvante Horreur',URL_MAIN + 'index.php?option=com_content&view=category&id=9'] )
  85.     liste.append( ['Fantastique',URL_MAIN + 'index.php?option=com_content&view=category&id=8'] )  
  86.     liste.append( ['Policier',URL_MAIN + 'index.php?option=com_content&view=category&id=10'] )
  87.     liste.append( ['Science Fiction',URL_MAIN + 'index.php?option=com_content&view=category&id=11'] )
  88.     liste.append( ['Thriller',URL_MAIN + 'index.php?option=com_content&view=category&id=12'] )
  89.     liste.append( ['Animation',URL_MAIN + 'index.php?option=com_content&view=category&id=2'] )
  90.     liste.append( ['Documentaires',URL_MAIN + 'index.php?option=com_content&view=category&id=26'] )  
  91.     liste.append( ['Spectacle',URL_MAIN + 'index.php?option=com_content&view=category&id=3'] )
  92.                
  93.     for sTitle,sUrl in liste:
  94.        
  95.         oOutputParameterHandler = cOutputParameterHandler()
  96.         oOutputParameterHandler.addParameter('siteUrl', sUrl)
  97.         oGui.addDir(SITE_IDENTIFIER, 'showMovies', sTitle, 'genres.png', oOutputParameterHandler)
  98.        
  99.     oGui.setEndOfDirectory()
  100.  
  101. def showMovies(sSearch = ''):
  102.     oGui = cGui()
  103.  
  104.     if sSearch :
  105.         sUrl = sSearch
  106.         sPattern = SEARCHPATTERN
  107.     else :
  108.         oInputParameterHandler = cInputParameterHandler()
  109.         sUrl = oInputParameterHandler.getValue('siteUrl')
  110.         sPattern = NORMALPATTERN
  111.  
  112.     oParser = cParser()
  113.        
  114.     #L'url change tres souvent donc faut la retrouver
  115.     req = urllib2.Request(URL_HOST)
  116.     response = urllib2.urlopen(req)
  117.     data = response.read()
  118.     response.close()
  119.     sMainUrl = ''
  120.     aResult = oParser.parse(data, 'window\.location\.href="([0-9a-zA-Z]+)";')
  121.     if aResult[0]:
  122.         #memorisation pour la suite
  123.         sMainUrl = URL_HOST + aResult[1][0] + '/'
  124.         #correction de l'url
  125.         sUrl = sUrl.replace('URL_MAIN', sMainUrl )
  126.  
  127.    
  128.  
  129.     else :
  130.         oInputParameterHandler = cInputParameterHandler()
  131.         sUrl = oInputParameterHandler.getValue('siteUrl')
  132.         sPattern = NORMALPATTERN
  133.         return
  134.     #print sUrl
  135.    
  136.     oRequestHandler = cRequestHandler(sUrl)
  137.     sHtmlContent = oRequestHandler.request()
  138.    
  139.     #fh = open('c:\\test.txt', "w")
  140.     #fh.write(sHtmlContent)
  141.     #fh.close()
  142.    
  143.     oParser = cParser()
  144.     aResult = oParser.parse(sHtmlContent, sPattern)
  145.    
  146.     aResult = oParser.parse(sHtmlContent, sPattern)
  147.    
  148.     if (aResult[0] == True):
  149.         total = len(aResult[1])
  150.         dialog = cConfig().createDialog(SITE_NAME)
  151.        
  152.         for aEntry in aResult[1]:
  153.             cConfig().updateDialog(dialog, total)
  154.             if dialog.iscanceled():
  155.                 break
  156.            
  157.             sTitle2 = aEntry[1]
  158.             sTitle2 = re.sub('<font color="#[0-9]{6}" *><i>HD<\/i><\/font>', '[HD]',sTitle2)
  159.             sUrl2 = aEntry[0]
  160.            
  161.             #not found better way
  162.             #sTitle = unicode(sTitle, errors='replace')
  163.             #sTitle = sTitle.encode('ascii', 'ignore').decode('ascii')
  164.            
  165.             sDisplayTitle = cUtil().DecoTitle(sTitle2)
  166.            
  167.             oOutputParameterHandler = cOutputParameterHandler()
  168.             oOutputParameterHandler.addParameter('siteUrl', sMainUrl + str(sUrl2))
  169.             oOutputParameterHandler.addParameter('sMovieTitle', str(sTitle2))
  170.             oOutputParameterHandler.addParameter('sMainUrl', sMainUrl)
  171.  
  172.             oGui.addMovie(SITE_IDENTIFIER, 'showHosters', sDisplayTitle, 'films.png', '', '', oOutputParameterHandler)
  173.  
  174.         cConfig().finishDialog(dialog)
  175.            
  176.         sNextPage = __checkForNextPage(sHtmlContent)
  177.         if (sNextPage != False):
  178.             oOutputParameterHandler = cOutputParameterHandler()
  179.             oOutputParameterHandler.addParameter('siteUrl', sMainUrl + sNextPage)
  180.             oGui.addDir(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Next >>>[/COLOR]', 'next.png', oOutputParameterHandler)
  181.  
  182.     if not sSearch:
  183.         oGui.setEndOfDirectory()
  184.    
  185. def __checkForNextPage(sHtmlContent):
  186.     sPattern = NEXTPAGEPATTERN
  187.     oParser = cParser()
  188.     aResult = oParser.parse(sHtmlContent, sPattern)
  189.     if (aResult[0] == True):
  190.         return aResult[1][0]
  191.  
  192.     return False
  193.  
  194. def showHosters():
  195.     oGui = cGui()
  196.    
  197.     sThumb = ''
  198.     sComm = ''
  199.    
  200.     oInputParameterHandler = cInputParameterHandler()
  201.     sUrl = oInputParameterHandler.getValue('siteUrl')
  202.     sMainUrl = oInputParameterHandler.getValue('sMainUrl')
  203.     sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
  204.    
  205.     oRequestHandler = cRequestHandler(sUrl)
  206.     sHtmlContent = oRequestHandler.request()
  207.    
  208.     oParser = cParser()
  209.    
  210.     #Recuperation info film, com et image
  211.     sPattern = FILMPATTERN
  212.     aResult = oParser.parse(sHtmlContent, sPattern)
  213.     sThumb = aResult[1][0][0]
  214.     sComm = cUtil().unescape(aResult[1][0][1])
  215.  
  216.     #Recuperation info lien du stream.
  217.     sLink = None
  218.     sPostUrl = None
  219.     sHtmlContent = sHtmlContent.replace('\r','')
  220.    
  221.     #fh = open('c:\\test.txt', "w")
  222.     #fh.write(sHtmlContent)
  223.     #fh.close()
  224.    
  225.     #Format classique
  226.     sPattern = FRAMEPATTERN
  227.     aResult = oParser.parse(sHtmlContent, sPattern)
  228.     if (aResult[0]):
  229.         sLink = aResult[1][0]
  230.         sPattern = '\/plugins\/([0-9a-zA-Z]+)\/plugins\/GRUDALpluginsphp.js"><\/script>'
  231.         aResult = oParser.parse(sHtmlContent, sPattern)
  232.         if (aResult[0]):
  233.             sPostUrl = sMainUrl + 'plugins/' + aResult[1][0] + '/plugins/GRUDALpluginsphp.php'
  234.            
  235.         if ((sLink) and (sPostUrl)):
  236.  
  237.             oOutputParameterHandler = cOutputParameterHandler()
  238.             oOutputParameterHandler.addParameter('siteUrl', sUrl)
  239.             oOutputParameterHandler.addParameter('sLink', sLink)
  240.             oOutputParameterHandler.addParameter('sPostUrl', sPostUrl)
  241.             oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
  242.            
  243.             sDisplayTitle = cUtil().DecoTitle(sMovieTitle)
  244.            
  245.             oGui.addMovie(SITE_IDENTIFIER, 'showHostersLink', sDisplayTitle, sThumb, sThumb, sComm, oOutputParameterHandler)
  246.            
  247.     #Fomat rare
  248.     if not sLink:
  249.         sPattern = FRAMEPATTERN2
  250.         aResult = oParser.parse(sHtmlContent, sPattern)
  251.         if (aResult[0]):
  252.             sLink = URL_HOST + aResult[1][0]
  253.            
  254.             oOutputParameterHandler = cOutputParameterHandler()
  255.             oOutputParameterHandler.addParameter('siteUrl', sUrl)
  256.             oOutputParameterHandler.addParameter('sLink', sLink)
  257.             oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
  258.            
  259.             sDisplayTitle = cUtil().DecoTitle(sMovieTitle)
  260.            
  261.             oGui.addMovie(SITE_IDENTIFIER, 'showHostersLink2', sDisplayTitle, sThumb, sThumb, sComm, oOutputParameterHandler)
  262.  
  263.     oGui.setEndOfDirectory()
  264.    
  265. def showHostersLink():
  266.     oGui = cGui()
  267.    
  268.     oInputParameterHandler = cInputParameterHandler()
  269.     sUrl = oInputParameterHandler.getValue('siteUrl')
  270.     sLink = oInputParameterHandler.getValue('sLink')
  271.     sPostUrl = oInputParameterHandler.getValue('sPostUrl')
  272.     sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
  273.    
  274.     UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0'
  275.     headers = {'User-Agent': UA ,
  276.                'Host' : 'grudal.com',
  277.                'Referer': sUrl,
  278.                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  279.                'Accept-Language' : 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
  280.                'Accept-Encoding' : 'gzip, deflate',
  281.                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
  282.                
  283.     post_data = {'link' : sLink}
  284.    
  285.     req = urllib2.Request(sPostUrl , urllib.urlencode(post_data), headers)
  286.    
  287.     response = urllib2.urlopen(req)
  288.     data = response.read()
  289.     response.close()
  290.    
  291.     oParser = cParser()
  292.     sPattern = HOSTPATTERN
  293.     aResult = oParser.parse(data, sPattern)
  294.  
  295.     if (aResult[0] == True):
  296.         total = len(aResult[1])
  297.         dialog = cConfig().createDialog(SITE_NAME)
  298.        
  299.         for aEntry in aResult[1]:
  300.             cConfig().updateDialog(dialog, total)
  301.             if dialog.iscanceled():
  302.                 break
  303.  
  304.  
  305.             sLink = aEntry[0]
  306.             Squality = aEntry[1]
  307.             sTitle = sMovieTitle.replace(' [HD]','')
  308.             sTitle = '[' + Squality + '] ' + sTitle
  309.            
  310.             sHosterUrl = str(sLink)
  311.             oHoster = cHosterGui().checkHoster(sHosterUrl)
  312.            
  313.             if (oHoster != False):
  314.                 sDisplayTitle = cUtil().DecoTitle(sTitle)
  315.                
  316.                 oHoster.setDisplayName(sDisplayTitle)
  317.                 oHoster.setFileName(sTitle)
  318.                 cHosterGui().showHoster(oGui, oHoster, sHosterUrl, '')
  319.             cConfig().finishDialog(dialog)
  320.        
  321.     oGui.setEndOfDirectory()
  322.  
  323. def showHostersLink2():
  324.     oGui = cGui()
  325.    
  326.     oInputParameterHandler = cInputParameterHandler()
  327.     sUrl = oInputParameterHandler.getValue('siteUrl')
  328.     sLink = oInputParameterHandler.getValue('sLink')
  329.     sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
  330.    
  331.     UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0'
  332.     headers = {'User-Agent': UA ,
  333.                'Host' : 'grudal.com',
  334.                'Referer': sLink,
  335.                'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
  336.                'Accept-Language' : 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
  337.                'Range' : 'bytes=0-'
  338.                #'Accept-Encoding' : 'gzip, deflate',
  339.                #'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  340.                }
  341.                
  342.     req = urllib2.Request(sLink)
  343.     response = urllib2.urlopen(req)
  344.     data = response.read()
  345.     response.close()
  346.    
  347.     oParser = cParser()
  348.     sPattern = '"file":"(.+?)","type":"mp4","label":"(.+?)"'
  349.     aResult = oParser.parse(data, sPattern)
  350.  
  351.     if (aResult[0] == True):
  352.         total = len(aResult[1])
  353.         dialog = cConfig().createDialog(SITE_NAME)
  354.        
  355.         for aEntry in aResult[1]:
  356.             cConfig().updateDialog(dialog, total)
  357.             if dialog.iscanceled():
  358.                 break
  359.  
  360.  
  361.             sLink = aEntry[0].replace('\/','/')
  362.             Squality = aEntry[1]
  363.             sTitle = sMovieTitle.replace(' [HD]','')
  364.             sTitle = '[' + Squality + '] ' + sTitle
  365.            
  366.             #decodage des liens          
  367.             req = urllib2.Request(sLink,None,headers)
  368.             try:
  369.                 response = urllib2.urlopen(req)
  370.                 #data = response.read()
  371.                 response.close()
  372.             except urllib2.URLError, e:
  373.                 sLink = e.geturl()
  374.            
  375.             sHosterUrl = str(sLink)
  376.             oHoster = cHosterGui().checkHoster(sHosterUrl)
  377.            
  378.             if (oHoster != False):
  379.                 sDisplayTitle = cUtil().DecoTitle(sTitle)
  380.                
  381.                 oHoster.setDisplayName(sDisplayTitle)
  382.                 oHoster.setFileName(sTitle)
  383.                 cHosterGui().showHoster(oGui, oHoster, sHosterUrl, '')
  384.             cConfig().finishDialog(dialog)
  385.        
  386.     oGui.setEndOfDirectory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement