Example #1
0
 def query(self, filepath, languages, keywords, series, season, episode):
     request_series = series.lower().replace(' ', '_')
     if isinstance(request_series, unicode):
         request_series = unicodedata.normalize('NFKD', request_series).encode('ascii', 'ignore')
     logger.debug(u'Getting subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
     r = self.session.get('%s/%s/%sx%.2d' % (self.server_url, urllib.quote(request_series), season, episode))
     if r.status_code == 404:
         logger.debug(u'Could not find subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
         return []
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' % (r.url, r.status_code))
         return []
     soup = BeautifulSoup.BeautifulSoup(r.content)
     subtitles = []
     for sub in soup('div', {'id': 'version'}):
         sub_keywords = split_keyword(self.release_pattern.search(sub.find('p', {'class': 'title-sub'}).contents[1]).group(1).lower())
         if not keywords & sub_keywords:
             logger.debug(u'None of subtitle keywords %r in %r' % (sub_keywords, keywords))
             continue
         for html_language in sub.findAllNext('ul', {'class': 'sslist'}):
             language = self.get_revert_language(html_language.findNext('li', {'class': 'li-idioma'}).find('strong').contents[0].string.strip())
             if not language in languages:
                 logger.debug(u'Language %r not in wanted languages %r' % (language, languages))
                 continue
             html_status = html_language.findNext('li', {'class': 'li-estado green'})
             status = html_status.contents[0].string.strip()
             if status != 'Completado':
                 logger.debug(u'Wrong subtitle status %s' % status)
                 continue
             path = get_subtitle_path(filepath, language, self.config.multi)
             subtitle = ResultSubtitle(path, language, service=self.__class__.__name__.lower(), link=html_status.findNext('span', {'class': 'descargar green'}).find('a')['href'], keywords=sub_keywords)
             subtitles.append(subtitle)
     return subtitles
Example #2
0
 def query(self, filepath, languages, keywords, series, season, episode):
     request_series = series.lower().replace(" ", "_")
     if isinstance(request_series, unicode):
         request_series = unicodedata.normalize("NFKD", request_series).encode("ascii", "ignore")
     logger.debug(
         u"Getting subtitles for %s season %d episode %d with languages %r" % (series, season, episode, languages)
     )
     r = self.session.get("%s/%s/%sx%.2d" % (self.server_url, urllib.quote(request_series), season, episode))
     if r.status_code == 404:
         logger.debug(
             u"Could not find subtitles for %s season %d episode %d with languages %r"
             % (series, season, episode, languages)
         )
         return []
     if r.status_code != 200:
         logger.error(u"Request %s returned status code %d" % (r.url, r.status_code))
         return []
     soup = BeautifulSoup(r.content, self.required_features)
     subtitles = []
     for sub in soup("div", {"id": "version"}):
         sub_keywords = split_keyword(
             self.release_pattern.search(sub.find("p", {"class": "title-sub"}).contents[1]).group(1).lower()
         )
         if not keywords & sub_keywords:
             logger.debug(u"None of subtitle keywords %r in %r" % (sub_keywords, keywords))
             continue
         for html_language in sub.findAllNext("ul", {"class": "sslist"}):
             language = self.get_language(
                 html_language.findNext("li", {"class": "li-idioma"}).find("strong").contents[0].string.strip()
             )
             if language not in languages:
                 logger.debug(u"Language %r not in wanted languages %r" % (language, languages))
                 continue
             html_status = html_language.findNext("li", {"class": "li-estado green"})
             status = html_status.contents[0].string.strip()
             if status != "Completado":
                 logger.debug(u"Wrong subtitle status %s" % status)
                 continue
             path = get_subtitle_path(filepath, language, self.config.multi)
             subtitle = ResultSubtitle(
                 path,
                 language,
                 self.__class__.__name__.lower(),
                 html_status.findNext("span", {"class": "descargar green"}).find("a")["href"],
                 keywords=sub_keywords,
             )
             subtitles.append(subtitle)
     return subtitles
Example #3
0
 def query(self, filepath, languages, keywords=None, series=None, season=None, episode=None, movie=None, year=None):
     if series and season and episode:
         request_series = series.lower().replace(' ', '_')
         if isinstance(request_series, unicode):
             request_series = request_series.encode('utf-8')
         logger.debug(u'Getting subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
         r = self.session.get('%s/serie/%s/%s/%s/' % (self.server_url, urllib.quote(request_series), season, episode))
         if r.status_code == 404:
             logger.debug(u'Could not find subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
             return []
     elif movie and year:
         request_movie = movie.title().replace(' ', '_')
         if isinstance(request_movie, unicode):
             request_movie = request_movie.encode('utf-8')
         logger.debug(u'Getting subtitles for %s (%d) with languages %r' % (movie, year, languages))
         r = self.session.get('%s/film/%s_(%d)' % (self.server_url, urllib.quote(request_movie), year))
         if r.status_code == 404:
             logger.debug(u'Could not find subtitles for %s (%d) with languages %r' % (movie, year, languages))
             return []
     else:
         raise ServiceError('One or more parameter missing')
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' % (r.url, r.status_code))
         return []
     soup = BeautifulSoup(r.content, self.required_features)
     subtitles = []
     for sub in soup('td', {'class': 'NewsTitle'}):
         sub_keywords = split_keyword(self.release_pattern.search(sub.contents[1]).group(1).lower())
         if not keywords & sub_keywords:
             logger.debug(u'None of subtitle keywords %r in %r' % (sub_keywords, keywords))
             continue
         for html_language in sub.parent.parent.findAll('td', {'class': 'language'}):
             language = self.get_language(html_language.string.strip())
             if language not in languages:
                 logger.debug(u'Language %r not in wanted languages %r' % (language, languages))
                 continue
             html_status = html_language.findNextSibling('td')
             status = html_status.find('strong').string.strip()
             if status != 'Completed':
                 logger.debug(u'Wrong subtitle status %s' % status)
                 continue
             path = get_subtitle_path(filepath, language, self.config.multi)
             subtitle = ResultSubtitle(path, language, service=self.__class__.__name__.lower(), link='%s%s' % (self.server_url, html_status.findNext('td').find('a')['href']))
             subtitles.append(subtitle)
     return subtitles