Advertisement
MrTruth

italiafilmgratis.py

May 21st, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """
  4.    Exodus Add-on
  5.    Copyright (C) 2016 Exodus
  6.  
  7.    This program is free software: you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation, either version 3 of the License, or
  10.    (at your option) any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. """
  20.  
  21. import re
  22. import urllib
  23. import urlparse
  24.  
  25. from resources.lib.modules import cleantitle
  26. from resources.lib.modules import client
  27. from resources.lib.modules import dom_parser
  28. from resources.lib.modules import source_utils
  29.  
  30.  
  31. class source:
  32.     def __init__(self):
  33.         self.priority = 1
  34.         self.language = ['it']
  35.         self.domains = ['italia-film.gratis']
  36.         self.base_link = 'http://www.italia-film.gratis'
  37.         self.search_link = '/?s=%s'
  38.  
  39.     def movie(self, imdb, title, localtitle, aliases, year):
  40.         try:
  41.             url = self.__search(localtitle)
  42.             if not url and title != localtitle: url = self.__search(title)
  43.             return url
  44.         except:
  45.             return
  46.  
  47.     def sources(self, url, hostDict, hostprDict):
  48.         sources = []
  49.  
  50.         try:
  51.             if not url:
  52.                 return sources
  53.  
  54.             url = urlparse.urljoin(self.base_link, url)
  55.  
  56.             r = client.request(url)
  57.             r = re.compile('<article(.*?)</article>', re.DOTALL).findall(r)
  58.             r = dom_parser.parse_dom(r, 'a', req='href')
  59.             r = [i.attrs['href'] for i in r]
  60.  
  61.             for url in r:
  62.                 valid, hoster = source_utils.is_host_valid(url, hostDict)
  63.                 if not valid: continue
  64.                 sources.append({'source': hoster, 'quality': 'HD', 'language': 'it', 'url': url, 'direct': False, 'debridonly': False, 'checkquality': True})
  65.             return sources
  66.         except:
  67.             return sources
  68.  
  69.     def resolve(self, url):
  70.         return url
  71.  
  72.     def __search(self, title):
  73.         try:
  74.             query = self.search_link % (urllib.quote_plus(cleantitle.query(title)))
  75.             query = urlparse.urljoin(self.base_link, query)
  76.  
  77.             t = cleantitle.get(title)
  78.  
  79.             r = client.request(query)
  80.             r = dom_parser.parse_dom(r, 'div', attrs={'class': ['entry-summary']})
  81.             r = dom_parser.parse_dom(r, 'a', req='href')
  82.             r = [(i.attrs['href'], i.attrs['title']) for i in r]
  83.             r = [(i[0], i[1]) for i in r if i[1]]
  84.             r = [i[0] for i in r if t == cleantitle.get(i[1])][0]
  85.  
  86.             return source_utils.strip_domain(r)
  87.         except:
  88.             return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement