当前位置: 首页>>代码示例>>Python>>正文


Python Language.fromaddic7ed方法代码示例

本文整理汇总了Python中babelfish.Language.fromaddic7ed方法的典型用法代码示例。如果您正苦于以下问题:Python Language.fromaddic7ed方法的具体用法?Python Language.fromaddic7ed怎么用?Python Language.fromaddic7ed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在babelfish.Language的用法示例。


在下文中一共展示了Language.fromaddic7ed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: query

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromaddic7ed [as 别名]
    def query(self, series, season, year=None, country=None):
        # get the show id
        show_id = self.get_show_id(series, year, country)
        if show_id is None:
            logger.error('No show id found for %r (%r)', series, {'year': year, 'country': country})
            return []

        # get the page of the season of the show
        logger.info('Getting the page of show id %d, season %d', show_id, season)
        r = self.session.get(self.server_url + 'show/%d' % show_id, params={'season': season}, timeout=10)
        r.raise_for_status()

        if not r.content:
            # Provider returns a status of 304 Not Modified with an empty content
            # raise_for_status won't raise exception for that status code
            logger.debug('No data returned from provider')
            return []

        soup = ParserBeautifulSoup(r.content, ['lxml', 'html.parser'])

        # loop over subtitle rows
        match = series_year_re.match(soup.select('#header font')[0].text.strip()[:-10])
        series = match.group('series')
        year = int(match.group('year')) if match.group('year') else None
        subtitles = []
        for row in soup.select('tr.epeven'):
            cells = row('td')

            # ignore incomplete subtitles
            status = cells[5].text
            if status != 'Completed':
                logger.debug('Ignoring subtitle with status %s', status)
                continue

            # read the item
            language = Language.fromaddic7ed(cells[3].text)
            hearing_impaired = bool(cells[6].text)
            page_link = self.server_url + cells[2].a['href'][1:]
            season = int(cells[0].text)
            episode = int(cells[1].text)
            title = cells[2].text
            version = cells[4].text
            download_link = cells[9].a['href'][1:]

            subtitle = self.subtitle_class(language, hearing_impaired, page_link, series, season, episode, title, year,
                                           version, download_link)
            logger.debug('Found subtitle %r', subtitle)
            subtitles.append(subtitle)

        return subtitles
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:52,代码来源:addic7ed.py

示例2: query

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromaddic7ed [as 别名]
    def query(self, series, season, year=None, country=None):
        # get the show id
        show_id = self.get_show_id(series, year, country)
        if show_id is None:
            logger.error("No show id found for %r (%r)", series, {"year": year, "country": country})
            return []

        # get the page of the season of the show
        logger.info("Getting the page of show id %d, season %d", show_id, season)
        r = self.session.get(self.server_url + "show/%d" % show_id, params={"season": season}, timeout=10)
        r.raise_for_status()
        if r.status_code == 304:
            raise TooManyRequests()
        soup = ParserBeautifulSoup(r.content, ["lxml", "html.parser"])

        # loop over subtitle rows
        match = series_year_re.match(soup.select("#header font")[0].text.strip()[:-10])
        series = match.group("series")
        year = int(match.group("year")) if match.group("year") else None
        subtitles = []
        for row in soup.select("tr.epeven"):
            cells = row("td")

            # ignore incomplete subtitles
            status = cells[5].text
            if status != "Completed":
                logger.debug("Ignoring subtitle with status %s", status)
                continue

            # read the item
            language = Language.fromaddic7ed(cells[3].text)
            hearing_impaired = bool(cells[6].text)
            page_link = self.server_url + cells[2].a["href"][1:]
            season = int(cells[0].text)
            episode = int(cells[1].text)
            title = cells[2].text
            version = cells[4].text
            download_link = cells[9].a["href"][1:]

            subtitle = Addic7edSubtitle(
                language, hearing_impaired, page_link, series, season, episode, title, year, version, download_link
            )
            logger.debug("Found subtitle %r", subtitle)
            subtitles.append(subtitle)

        return subtitles
开发者ID:pedro2d10,项目名称:SickRage-FR,代码行数:48,代码来源:addic7ed.py


注:本文中的babelfish.Language.fromaddic7ed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。