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


Python ServerProxy.appendurl方法代码示例

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


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

示例1: on_task_output

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import appendurl [as 别名]
    def on_task_output(self, task, config):
        from xmlrpc.client import ServerProxy

        params = dict(config)

        server = ServerProxy(params["url"])

        for entry in task.accepted:
            if task.options.test:
                log.info('Would add into nzbget: %s', entry['title'])
                continue

            # allow overriding the category
            if 'category' in entry:
                params['category'] = entry['category']

            try:
                server.appendurl(
                    entry['title'] + '.nzb',
                    params['category'],
                    params['priority'],
                    params['top'],
                    entry['url'],
                )
                log.info('Added `%s` to nzbget', entry['title'])
            except Exception as e:
                log.critical('rpc call to nzbget failed: %s', e)
                entry.fail('could not call appendurl via RPC')
开发者ID:Flexget,项目名称:Flexget,代码行数:30,代码来源:nzbget.py

示例2: sendNZB

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import appendurl [as 别名]

#.........这里部分代码省略.........
                dupekey = 'Medusa-tvr' + text_type(cur_ep.series.indexerid)
        dupekey += '-' + text_type(cur_ep.season) + '.' + text_type(cur_ep.episode)
        if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
            addToTop = True
            nzbgetprio = app.NZBGET_PRIORITY
        else:
            category = app.NZBGET_CATEGORY_BACKLOG
            if nzb.series.is_anime:
                category = app.NZBGET_CATEGORY_ANIME_BACKLOG

    if nzb.quality != Quality.UNKNOWN:
        dupescore = nzb.quality * 100
    if proper:
        dupescore += 10

    nzbcontent64 = None
    if nzb.result_type == 'nzbdata':
        data = nzb.extra_info[0]
        nzbcontent64 = standard_b64encode(data)

    log.info('Sending NZB to NZBget')
    log.debug('URL: {}', url)

    try:
        # Find out if nzbget supports priority (Version 9.0+),
        # old versions beginning with a 0.x will use the old command
        nzbget_version_str = nzbGetRPC.version()
        nzbget_version = try_int(
            nzbget_version_str[:nzbget_version_str.find('.')]
        )
        if nzbget_version == 0:
            if nzbcontent64:
                nzbget_result = nzbGetRPC.append(
                    nzb.name + '.nzb',
                    category,
                    addToTop,
                    nzbcontent64
                )
            else:
                if nzb.result_type == 'nzb':
                    if not nzb.provider.login():
                        return False

                    # TODO: Check if this needs exception handling
                    data = nzb.provider.session(nzb.url).content
                    if data is None:
                        return False

                    nzbcontent64 = standard_b64encode(data)

                nzbget_result = nzbGetRPC.append(
                    nzb.name + '.nzb',
                    category,
                    addToTop,
                    nzbcontent64
                )
        elif nzbget_version == 12:
            if nzbcontent64 is not None:
                nzbget_result = nzbGetRPC.append(
                    nzb.name + '.nzb', category, nzbgetprio, False,
                    nzbcontent64, False, dupekey, dupescore, 'score'
                )
            else:
                nzbget_result = nzbGetRPC.appendurl(
                    nzb.name + '.nzb', category, nzbgetprio, False, nzb.url,
                    False, dupekey, dupescore, 'score'
                )
        # v13+ has a new combined append method that accepts both (url and
        # content) also the return value has changed from boolean to integer
        # (Positive number representing NZBID of the queue item. 0 and negative
        # numbers represent error codes.)
        elif nzbget_version >= 13:
            nzbget_result = nzbGetRPC.append(
                nzb.name + '.nzb',
                nzbcontent64 if nzbcontent64 is not None else nzb.url,
                category, nzbgetprio, False, False, dupekey, dupescore,
                'score'
            ) > 0
        else:
            if nzbcontent64 is not None:
                nzbget_result = nzbGetRPC.append(
                    nzb.name + '.nzb', category, nzbgetprio, False,
                    nzbcontent64
                )
            else:
                nzbget_result = nzbGetRPC.appendurl(
                    nzb.name + '.nzb', category, nzbgetprio, False, nzb.url
                )

        if nzbget_result:
            log.debug('NZB sent to NZBget successfully')
            return True
        else:
            log.warning('NZBget could not add {name}.nzb to the queue',
                        {'name': nzb.name})
            return False
    except Exception:
        log.warning('Connect Error to NZBget: could not add {name}.nzb to the'
                    ' queue', {'name': nzb.name})
        return False
开发者ID:pymedusa,项目名称:SickRage,代码行数:104,代码来源:nzbget.py


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