costaplus

animeforge

May 30th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.83 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # ------------------------------------------------------------
  3. # streamondemand.- XBMC Plugin
  4. # Canal para itafilmtv
  5. # http://blog.tvalacarta.info/plugin-xbmc/streamondemand.
  6. #  By Costaplus
  7. # ------------------------------------------------------------
  8. import re
  9. import sys
  10. import urlparse
  11. import urllib2
  12. import xbmc
  13. from core import config
  14. from core import logger
  15. from core import scrapertools
  16. from core.item import Item
  17. from servers import servertools
  18.  
  19.  
  20.  
  21.  
  22. __channel__ = "animeforge"
  23. __category__ = "F"
  24. __type__ = "generic"
  25. __title__ = "animeforge.org"
  26. __language__ = "IT"
  27.  
  28. DEBUG = True #config.get_setting("debug")
  29.  
  30. host = "http://www.animeforce.org/"
  31. hostlista = host + "lista-anime/"
  32.  
  33. def isGeneric():
  34.     return True
  35.  
  36. #-----------------------------------------------------------------
  37. def mainlist(item):
  38.     log("animeforge","mainlist")
  39.     itemlist =[]
  40.     itemlist.append(Item(channel=__channel__,action="lista_anime",title="[COLOR azure]Lista Serie[/COLOR]"    ,url=hostlista,thumbnail=AnimeThumbnail,fanart=AnimeFanart))
  41.     itemlist.append(Item(channel=__channel__,action="lista_generi"  ,title="[COLOR azure]Categorie[/COLOR]",url=hostlista+"ListaGeneri.php" ,thumbnail=CategoriaThumbnail,fanart=CategoriaFanart))
  42.     itemlist.append(Item(channel=__channel__,action="search"     ,title="[COLOR orange]Cerca...[/COLOR]",url="http://www.leserie.tv/index.php?do=search",thumbnail=CercaThumbnail,fanart=CercaFanart))
  43.  
  44.     return itemlist
  45. #=================================================================
  46.  
  47. #-----------------------------------------------------------------
  48. def lista_anime(item):
  49.     log("lista_anime", "lista_anime")
  50.     itemlist = []
  51.     patron = '<li><strong.*?href="(.*?)">(.*?)</a></strong></li>'
  52.     for scrapedurl,scrapedtitle in scrapedAll(item.url, patron):
  53.         scrapedtitle=elimina_superfluo(scrapedtitle)
  54.         log("lista_anime"," scrapedurl:" + scrapedurl + " scrapedtitle:" + scrapedtitle)
  55.         itemlist.append(Item(channel=__channel__, action="episodi", title=scrapedtitle, url=scrapedurl,thumbnail="", fulltitle=scrapedtitle, show=scrapedtitle,fanart=""))
  56.  
  57.     return itemlist
  58. #=================================================================
  59.  
  60. #-----------------------------------------------------------------
  61. def episodi(item):
  62.     log("episodi", "episodi")
  63.     itemlist =[]
  64.     single='<i>.*?</i>'
  65.     patron= '<td style="text-align: left;"><strong>(.*?)</strong></td>\s*.*?href="(.*?)"'
  66.     for scrapedtitle,scrapedurl in scrapedAll(item.url,patron):
  67.        log("episodi", "scrapedurl: " +  scrapedurl)
  68.        #if DEBUG: logger.info("scrapedurl: " + scrapedurl + " scrapedtitle:" + scrapedtitle)
  69.        scrapedtitle = scrapertools.htmlclean(scrapedtitle)
  70.        itemlist.append(Item(channel=__channel__, action="player", title=scrapedtitle, url=scrapedurl,thumbnail=item.thumbnail, fulltitle=scrapedtitle, show=scrapedtitle,fanart=item.thumbnail))
  71.  
  72.     return itemlist
  73. #=================================================================
  74.  
  75. #-----------------------------------------------------------------
  76. def player(item):
  77.     itemlist =[]
  78.     xbmc.log(item.url)
  79.     #patron='<a href="(.*?)">Streaming Alternativo.*?</a>'
  80.     patron='<source.*?src="(.*?)".*?>'
  81.     for scrapedurl in scrapedAll(item.url, patron):
  82.         log("player","url Video:"+scrapedurl)
  83.         itemlist.append(Item(channel=__channel__, action="play", title=item.title, url=host + scrapedurl, thumbnail=item.thumbnail,plot=item.plot,fanart=item.fanart, folder=False))
  84.         itemlist.append(Item(channel=__channel__, action="play", title=item.title, url=host + "dsOLD16.php?file ="+ scrapedurl, thumbnail=item.thumbnail,plot=item.plot, fanart=item.fanart, folder=False))
  85.  
  86.     return itemlist
  87. #=================================================================
  88.  
  89.  
  90. #=================================================================
  91. # Funzioni di servizio
  92. #-----------------------------------------------------------------
  93. def scrapedAll(url="",patron=""):
  94.     matches = []
  95.     data = scrapertools.cache_page(url)
  96.     if DEBUG: logger.info("data:"+data)
  97.     xbmc.log("data:" + data)
  98.     MyPatron = patron
  99.     matches = re.compile(MyPatron, re.DOTALL).findall(data)
  100.     scrapertools.printMatches(matches)
  101.  
  102.     return matches
  103. #=================================================================
  104.  
  105. #-----------------------------------------------------------------
  106. def scrapedAllPost(url="",Post="",patron=""):
  107.     matches = []
  108.     data = scrapertools.cache_page(url,post=Post)
  109.     if DEBUG: logger.info("data:"+data)
  110.     xbmc.log("data:" + data)
  111.     MyPatron = patron
  112.     matches = re.compile(MyPatron, re.DOTALL).findall(data)
  113.     scrapertools.printMatches(matches)
  114.  
  115.     return matches
  116. #=================================================================
  117.  
  118. #-----------------------------------------------------------------
  119. def scrapedSingle(url="",single="",patron=""):
  120.     matches =[]
  121.     data = scrapertools.cache_page(url)
  122.     elemento = scrapertools.find_single_match(data, single)
  123.     xbmc.log("trovato:" + elemento)
  124.     matches = re.compile(patron, re.DOTALL).findall(elemento)
  125.     scrapertools.printMatches(matches)
  126.  
  127.     return matches
  128. #=================================================================
  129.  
  130. #-----------------------------------------------------------------
  131. def log(funzione="",stringa="",canale=__channel__):
  132.     if DEBUG:logger.info("[" + canale + "].[" + funzione + "] " + stringa)
  133.     xbmc.log("[" + canale + "].[" + funzione + "] " + stringa)
  134.  
  135. #=================================================================
  136.  
  137. def elimina_superfluo(titolo):
  138.     titolo=scrapertools.decodeHtmlentities(titolo)
  139.     titolo=titolo.lower()
  140.     titolo = titolo.split("sub")
  141.  
  142.  
  143.     return titolo[0]
  144.  
  145. #-----------------------------------------------------------------
  146. def HomePage(item):
  147.     xbmc.executebuiltin("ReplaceWindow(10024,plugin://plugin.video.streamondemand)")
  148. #=================================================================
  149.  
  150.  
  151. #=================================================================
  152. # riferimenti di servizio
  153. #-----------------------------------------------------------------
  154. AnimeThumbnail="http://img15.deviantart.net/f81c/i/2011/173/7/6/cursed_candies_anime_poster_by_careko-d3jnzg9.jpg"
  155. AnimeFanart="https://i.ytimg.com/vi/IAlbvyBdYdY/maxresdefault.jpg"
  156. CategoriaThumbnail="http://static.europosters.cz/image/750/poster/street-fighter-anime-i4817.jpg"
  157. CategoriaFanart="https://i.ytimg.com/vi/IAlbvyBdYdY/maxresdefault.jpg"
  158. CercaThumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"
  159. CercaFanart="https://i.ytimg.com/vi/IAlbvyBdYdY/maxresdefault.jpg"
  160. HomeTxt = "[COLOR yellow]Torna Home[/COLOR]"
  161. AvantiTxt="[COLOR orange]Successivo>>[/COLOR]"
  162. AvantiImg="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png"
Advertisement
Add Comment
Please, Sign In to add comment