Esempio n. 1
0
 def query(self, filepath, languages, title, season=None, episode=None, year=None, keywords=None):
     params = {'sXML': 1, 'sK': title, 'sJ': ','.join([str(self.get_code(l)) for l in languages])}
     if season is not None:
         params['sTS'] = season
     if episode is not None:
         params['sTE'] = episode
     if year is not None:
         params['sY'] = year
     if keywords is not None:
         params['sR'] = keywords
     r = self.session.get(self.server_url + '/ppodnapisi/search', params=params)
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' % (r.url, r.status_code)) if sys.platform != 'win32' else logger.debug('Log line suppressed on windows')
         return []
     subtitles = []
     soup = BeautifulSoup(r.content, self.required_features)
     for sub in soup('subtitle'):
         if 'n' in sub.flags:
             logger.debug(u'Skipping hearing impaired') if sys.platform != 'win32' else logger.debug('Log line suppressed on windows')
             continue
         language = self.get_language(sub.languageId.text)
         confidence = float(sub.rating.text) / 5.0
         sub_keywords = set()
         for release in sub.release.text.split():
             sub_keywords |= get_keywords(guessit.guess_file_info(release + '.srt', 'autodetect'))
         sub_path = get_subtitle_path(filepath, language, self.config.multi)
         subtitle = ResultSubtitle(sub_path, language, self.__class__.__name__.lower(),
                                   sub.url.text, confidence=confidence, keywords=sub_keywords)
         subtitles.append(subtitle)
     return subtitles
Esempio n. 2
0
 def query(self, filepath, languages, title, season=None, episode=None, year=None, keywords=None):
     params = {'sXML': 1, 'sK': title, 'sJ': ','.join([str(self.get_code(l)) for l in languages])}
     if season is not None:
         params['sTS'] = season
     if episode is not None:
         params['sTE'] = episode
     if year is not None:
         params['sY'] = year
     if keywords is not None:
         params['sR'] = keywords
     r = self.session.get(self.server_url + '/ppodnapisi/search', params=params)
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' % (r.url, r.status_code))
         return []
     subtitles = []
     soup = BeautifulSoup(r.content, self.required_features)
     for sub in soup('subtitle'):
         if 'n' in sub.flags:
             logger.debug(u'Skipping hearing impaired')
             continue
         language = l
         confidence = float(sub.rating.text) / 5.0
         sub_keywords = set()
         for release in sub.release.text.split():
             sub_keywords |= get_keywords(guessit.guess_file_info(release + '.srt', 'autodetect'))
         sub_path = get_subtitle_path(filepath, language, self.config.multi)
         subtitle = ResultSubtitle(sub_path, language, self.__class__.__name__.lower(),
                                   sub.url.text, confidence=confidence, keywords=sub_keywords)
         subtitles.append(subtitle)
     return subtitles
Esempio n. 3
0
 def query(self, filepath, languages, title, season=None, episode=None, year=None, keywords=None):
     myDB = db.DBConnection()
     myDBcache = db.DBConnection("cache.db")
     sql_show_id = myDB.select("SELECT tvdb_id, show_name FROM tv_shows WHERE show_name LIKE ?", ["%" + title + "%"])
     if sql_show_id[0][0]:
         sql_scene = myDB.select(
             "SELECT scene_season, scene_episode FROM tv_episodes WHERE showid = ? and season = ? and episode = ?",
             [sql_show_id[0][0], season, episode],
         )
         real_name = sql_show_id[0][1]
         if sql_scene[0][0]:
             season = sql_scene[0][0]
             episode = sql_scene[0][1]
         sql_custom_names = myDBcache.select(
             "SELECT show_name FROM scene_exceptions WHERE tvdb_id = ? and show_name<> ? ORDER BY exception_id asc",
             [sql_show_id[0][0], real_name],
         )
         if sql_custom_names:
             title = sql_custom_names[0][0]
     glog.log(
         u"Searching Subtitles on Podnapisiweb with title : %s season : %s episode : %s" % (title, season, episode)
     )
     params = {"sXML": 1, "sK": title, "sJ": ",".join([str(self.get_code(l)) for l in languages])}
     if season is not None:
         params["sTS"] = season
     if episode is not None:
         params["sTE"] = episode
     if year is not None:
         params["sY"] = year
     if keywords is not None:
         params["sR"] = keywords
     r = self.session.get(self.server_url + "/ppodnapisi/search", params=params)
     if r.status_code != 200:
         logger.error(u"Request %s returned status code %d" % (r.url, r.status_code))
         return []
     subtitles = []
     soup = BeautifulSoup(r.content, self.required_features)
     for sub in soup("subtitle"):
         if "n" in sub.flags:
             logger.debug(u"Skipping hearing impaired")
             continue
         language = l
         confidence = float(sub.rating.text) / 5.0
         sub_keywords = set()
         for release in sub.release.text.split():
             sub_keywords |= get_keywords(guessit.guess_file_info(release + ".srt", "autodetect"))
         sub_path = get_subtitle_path(filepath, language, self.config.multi)
         subtitle = ResultSubtitle(
             sub_path,
             language,
             self.__class__.__name__.lower(),
             sub.url.text,
             confidence=confidence,
             keywords=sub_keywords,
         )
         subtitles.append(subtitle)
     return subtitles
Esempio n. 4
0
 def query(self, filepath, languages, title, season=None, episode=None, year=None, keywords=None):
     myDB = db.DBConnection()
     myDBcache = db.DBConnection("cache.db")
     sql_show_id = myDB.select("SELECT tvdb_id FROM tv_shows WHERE show_name LIKE ?", ['%'+title+'%'])
     if sql_show_id:
         sql_scene = myDB.select("SELECT scene_season, scene_episode FROM tv_episodes WHERE showid = ? and season = ? and episode = ?", [sql_show_id[0][0],season,episode])
         if sql_scene[0][0]:
             season=sql_scene[0][0]
             episode= sql_scene[0][1]
         sql_custom_names = myDBcache.select("SELECT show_name FROM scene_exceptions WHERE tvdb_id = ? ORDER BY exception_id asc", [sql_show_id[0][0]])
         if sql_custom_names:
             title=sql_custom_names[0][0]
     glog.log(u'Searching Subtitles on Podnapisiweb with title : %s season : %s episode : %s' % (title,season,episode))
     params = {'sXML': 1, 'sK': title, 'sJ': ','.join([str(self.get_code(l)) for l in languages])}
     if season is not None:
         params['sTS'] = season
     if episode is not None:
         params['sTE'] = episode
     if year is not None:
         params['sY'] = year
     if keywords is not None:
         params['sR'] = keywords
     r = self.session.get(self.server_url + '/ppodnapisi/search', params=params)
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' % (r.url, r.status_code))
         return []
     subtitles = []
     soup = BeautifulSoup(r.content, self.required_features)
     for sub in soup('subtitle'):
         if 'n' in sub.flags:
             logger.debug(u'Skipping hearing impaired')
             continue
         language = l
         confidence = float(sub.rating.text) / 5.0
         sub_keywords = set()
         for release in sub.release.text.split():
             sub_keywords |= get_keywords(guessit.guess_file_info(release + '.srt', 'autodetect'))
         sub_path = get_subtitle_path(filepath, language, self.config.multi)
         subtitle = ResultSubtitle(sub_path, language, self.__class__.__name__.lower(),
                                   sub.url.text, confidence=confidence, keywords=sub_keywords)
         subtitles.append(subtitle)
     return subtitles
Esempio n. 5
0
 def query(self,
           filepath,
           languages,
           title,
           season=None,
           episode=None,
           year=None,
           keywords=None):
     myDB = db.DBConnection()
     myDBcache = db.DBConnection("cache.db")
     sql_show_id = myDB.select(
         "SELECT tvdb_id, show_name FROM tv_shows WHERE show_name LIKE ?",
         ['%' + title + '%'])
     if sql_show_id[0][0]:
         sql_scene = myDB.select(
             "SELECT scene_season, scene_episode FROM tv_episodes WHERE showid = ? and season = ? and episode = ?",
             [sql_show_id[0][0], season, episode])
         real_name = sql_show_id[0][1]
         if sql_scene[0][0]:
             season = sql_scene[0][0]
             episode = sql_scene[0][1]
         sql_custom_names = myDBcache.select(
             "SELECT show_name FROM scene_exceptions WHERE tvdb_id = ? and show_name<> ? ORDER BY exception_id asc",
             [sql_show_id[0][0], real_name])
         if sql_custom_names:
             title = sql_custom_names[0][0]
     glog.log(
         u'Searching Subtitles on Podnapisiweb with title : %s season : %s episode : %s'
         % (title, season, episode))
     params = {
         'sXML': 1,
         'sK': title,
         'sJ': ','.join([str(self.get_code(l)) for l in languages])
     }
     if season is not None:
         params['sTS'] = season
     if episode is not None:
         params['sTE'] = episode
     if year is not None:
         params['sY'] = year
     if keywords is not None:
         params['sR'] = keywords
     r = self.session.get(self.server_url + '/ppodnapisi/search',
                          params=params)
     if r.status_code != 200:
         logger.error(u'Request %s returned status code %d' %
                      (r.url, r.status_code))
         return []
     subtitles = []
     soup = BeautifulSoup(r.content, self.required_features)
     print soup
     for sub in soup('subtitle'):
         if 'n' in sub.flags:
             logger.debug(u'Skipping hearing impaired')
             continue
         language = l
         confidence = float(sub.rating.text) / 5.0
         sub_keywords = set()
         for release in sub.release.text.split():
             sub_keywords |= get_keywords(
                 guessit.guess_file_info(release + '.srt', 'autodetect'))
         sub_path = get_subtitle_path(filepath, language, self.config.multi)
         subtitle = ResultSubtitle(sub_path,
                                   language,
                                   self.__class__.__name__.lower(),
                                   sub.url.text,
                                   confidence=confidence,
                                   keywords=sub_keywords)
         subtitles.append(subtitle)
     return subtitles