costaplus

tnt_village

May 10th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.14 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #------------------------------------------------------------
  3. # streamondemand.- XBMC Plugin
  4. # Canale Video Corsi Programmazione
  5. # Creato dall'utente costaplus
  6. # http://www.mimediacenter.info/foro/viewforum.php?f=36.
  7. #------------------------------------------------------------
  8. import os
  9. import re
  10. import urllib2
  11. import urlparse
  12. import xbmc
  13. import xbmcgui
  14. from core import config
  15. from core import logger
  16. from core import scrapertools
  17. from core.item import Item
  18. #from servers import servertools
  19. from lib import transmissionrpc
  20.  
  21. __channel__ = "tntvillage"
  22. __category__ = "D"
  23. __type__ = "generic"
  24. __title__ = "tntvillage (IT)"
  25. __language__ = "IT"
  26.  
  27. DEBUG = config.get_setting("debug")
  28.  
  29.  
  30. tutti = "http://www.tntvillage.scambioetico.org/rss.php?c=4&p=900"
  31.  
  32. def isGeneric():
  33.     return True
  34.  
  35. def mainlist(item):
  36.     logger.info("streamondemand.tntvillage mainlist")
  37.     itemlist = []
  38.  
  39.  
  40.  
  41.  
  42.  
  43.     itemlist.append(Item(channel=__channel__, title="[COLOR azure]TnTVillage - Film[/COLOR]", action="elenca",url=tutti,thumbnail="http://forum.tntvillage.scambioetico.org/style_images/mkportal-636/tntlogo2012.png"))
  44.     #itemlist.append(Item(channel=__channel__, title="[COLOR orange]Elenco Torrent attivi n: %s[/COLOR]" % conta(), action="elenca_torrent", url="", thumbnail="https://raymii.org/s/inc/img/transmission.png"))
  45.     itemlist.append(Item(channel=__channel__, title="[COLOR azure]cerca ...[/COLOR]", action="search", url=tutti,thumbnail="http://forum.tntvillage.scambioetico.org/style_images/mkportal-636/tntlogo2012.png"))
  46.     #itemlist.append(Item(channel=__channel__, title="[COLOR orange]Elenco Torrent attivi n: %s[/COLOR]",action="elenca_torrent", url="", thumbnail="https://raymii.org/s/inc/img/transmission.png"))
  47.  
  48.     return itemlist
  49.  
  50. def elenca(item):
  51.     itemlist = []
  52.     data = scrapertools.cache_page(item.url,timeout=10)
  53.  
  54.     patron = '<item>\s*<title>(.*?)</title>\s*<link>(.*?)</link>'
  55.     matches = re.compile(patron, re.DOTALL).findall(data)
  56.     scrapertools.printMatches(matches)
  57.     #a =scrapertools.find_single_match("<enclosure>")
  58.     #xbmc.log(a)
  59.     # scrapedTorrent
  60.     for scrapedtitle,scraperurl in matches:
  61.         xbmc.log(scrapedtitle)
  62.         scrapedthumbnail=""
  63.         scrapedplot =""
  64.         scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
  65.         itemlist.append(Item(channel=__channel__,action="", fulltitle=scrapedtitle,show=scrapedtitle,title=scrapedtitle, url=scraperurl, thumbnail="",  plot="", folder=True))
  66.  
  67.  
  68.     try:
  69.         plot, fanart, poster, extrameta = info(title)
  70.  
  71.         itemlist.append(Item(channel=__channel__, action="play", fulltitle=scrapedtitle, show=scrapedtitle,
  72.                              title="[COLOR darkkhaki].torrent [/COLOR]""[COLOR azure]" + scrapedtitle + "[/COLOR]",
  73.                              url=scraperurl, thumbnail=poster, plot=str(plot), extrameta=extrameta,
  74.                              fanart=fanart if fanart != "" else poster, folder=True))
  75.     except:
  76.         itemlist.append(Item(channel=__channel__, action="play", fulltitle=scrapedtitle, show=scrapedtitle,
  77.                              title="[COLOR darkkhaki].torrent [/COLOR]""[COLOR azure]" + scrapedtitle + "[/COLOR]",
  78.                              url=scraperurl, thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True))
  79.  
  80.     return itemlist
  81.  
  82.  
  83.  
  84. def search(item,text):
  85.     logger.info("streamondemand.tntvillage cerca")
  86.     itemlist = []
  87.     item.url= "%s&f=%s" % (item.url,text +str("%"))
  88.     xbmc.log(item.url)
  89.     return elenca(item)
  90.  
  91.  
  92.  
  93.  
  94. def rss(item):
  95.     logger.info("streamondemand.tntvillage rss")
  96.     itemlist = []
  97.  
  98.     numero=xbmcgui.Dialog().numeric(0, 'quantità ?','10')
  99.  
  100.     pagina = item.url % numero
  101.     data = scrapertools.cache_page(pagina)
  102.  
  103.     patron = '<enclosure url="(.*?)"'
  104.     matches = re.compile(patron, re.DOTALL).findall(data)
  105.     scrapertools.printMatches(matches)
  106.  
  107.     #scrapedTorrent
  108.     for  scrapedtitle in matches:
  109.         xbmc.log(scrapedtitle)
  110.         scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
  111.         itemlist.append(Item(channel=__channel__,
  112.                              action="scarica",
  113.                              fulltitle=scrapedtitle,
  114.                              show=scrapedtitle,
  115.                              title=scrapedtitle,
  116.                              url=scrapedtitle,
  117.                              thumbnail="",
  118.                              plot="",
  119.                              folder=True))
  120.  
  121.  
  122.     return itemlist
  123.  
  124.  
  125. def info(title):
  126.     logger.info("streamondemand.tntvillate info")
  127.     try:
  128.         from core.tmdb import Tmdb
  129.         oTmdb = Tmdb(texto_buscado=title, tipo="movie", include_adult="false", idioma_busqueda="it")
  130.         if oTmdb.total_results > 0:
  131.             extrameta = {"Year": oTmdb.result["release_date"][:4],
  132.                          "Genre": ", ".join(oTmdb.result["genres"]),
  133.                          "Rating": float(oTmdb.result["vote_average"])}
  134.             fanart = oTmdb.get_backdrop()
  135.             poster = oTmdb.get_poster()
  136.             plot = oTmdb.get_sinopsis()
  137.             return plot, fanart, poster, extrameta
  138.     except:
  139.         pass
Advertisement
Add Comment
Please, Sign In to add comment