• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.replace_extension函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sickrage.helper.common.replace_extension函数的典型用法代码示例。如果您正苦于以下问题:Python replace_extension函数的具体用法?Python replace_extension怎么用?Python replace_extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: download_result

    def download_result(self, result):
        if not self.login():
            return False

        urls, filename = self._make_url(result)

        for url in urls:
            if 'NO_DOWNLOAD_NAME' in url:
                continue

            if url.startswith('http'):
                self.headers.update({
                    'Referer': '/'.join(url.split('/')[:3]) + '/'
                })

            logger.log(u'Downloading a result from {0} at {1}'.format(self.name, url))

            if url.endswith(GenericProvider.TORRENT) and filename.endswith(GenericProvider.NZB):
                filename = replace_extension(filename, GenericProvider.TORRENT)

            if download_file(url, filename, session=self.session, headers=self.headers, hooks={'response': self.get_url_hook}):
                if self._verify_download(filename):
                    logger.log(u'Saved result to {0}'.format(filename), logger.INFO)
                    return True

                logger.log(u'Could not download {0}'.format(url), logger.WARNING)
                remove_file_failed(filename)

        if urls:
            logger.log(u'Failed to download any results', logger.WARNING)

        return False
开发者ID:NickMolloy,项目名称:SickRage,代码行数:32,代码来源:GenericProvider.py


示例2: download_result

    def download_result(self, result):
        if not self.login():
            return False

        urls, filename = self._make_url(result)

        for url in urls:
            if "NO_DOWNLOAD_NAME" in url:
                continue

            if url.startswith("http"):
                self.headers.update({"Referer": "/".join(url.split("/")[:3]) + "/"})

            logger.log(u"Downloading a result from {0} at {1}".format(self.name, url))

            if url.endswith(GenericProvider.TORRENT) and filename.endswith(GenericProvider.NZB):
                filename = replace_extension(filename, GenericProvider.TORRENT)

            if download_file(
                url, filename, session=self.session, headers=self.headers, hooks={"response": self.get_url_hook}
            ):
                if self._verify_download(filename):
                    logger.log(u"Saved result to {0}".format(filename), logger.INFO)
                    return True

                logger.log(u"Could not download {0}".format(url), logger.WARNING)
                remove_file_failed(filename)

        if urls:
            logger.log(u"Failed to download any results", logger.WARNING)

        return False
开发者ID:Rickol91,项目名称:SickRage,代码行数:32,代码来源:GenericProvider.py


示例3: get_episode_thumb_path

    def get_episode_thumb_path(ep_obj):
        """
        Returns the path where the episode thumbnail should be stored. Defaults to
        the same path as the episode file but with a .metathumb extension.

        ep_obj: a TVEpisode instance for which to create the thumbnail
        """
        if ek(os.path.isfile, ep_obj.location):
            tbn_filename = replace_extension(ep_obj.location, 'metathumb')
        else:
            return None

        return tbn_filename
开发者ID:Eiber,项目名称:SickRage-Medusa,代码行数:13,代码来源:wdtv.py


示例4: get_episode_thumb_path

    def get_episode_thumb_path(ep_obj):
        """
        Returns a full show dir/metadata/episode.jpg path for MediaBrowser
        episode thumbs.

        ep_obj: a TVEpisode object to get the path from
        """

        if ek(os.path.isfile, ep_obj.location):
            tbn_file_name = replace_extension(ek(os.path.basename, ep_obj.location), 'jpg')
            metadata_dir_name = ek(os.path.join, ek(os.path.dirname, ep_obj.location), 'metadata')
            tbn_file_path = ek(os.path.join, metadata_dir_name, tbn_file_name)
        else:
            return None

        return tbn_file_path
开发者ID:Thraxis,项目名称:pymedusa,代码行数:16,代码来源:mediabrowser.py


示例5: get_episode_thumb_path

    def get_episode_thumb_path(ep_obj):
        """
        Returns the path where the episode thumbnail should be stored. Defaults to
        the same path as the episode file but with a .metathumb extension.

        ep_obj: a TVEpisode instance for which to create the thumbnail
        """
        if ek(os.path.isfile, ep_obj.location):
            tbn_filename = replace_extension(ep_obj.location, 'jpg')
        else:
            logger.log(u"GETP: Retuning none on " + ep_obj.location, logger.INFO)
            return None

        tbn_filename = rreplace(tbn_filename, "/", "/.", 1)
        logger.log(u"GETP: Retuning " + tbn_filename + "  on " + ep_obj.location, logger.INFO)
        return tbn_filename
开发者ID:pjg101,项目名称:SickRage,代码行数:16,代码来源:wdtv.py


示例6: get_episode_file_path

    def get_episode_file_path(self, ep_obj):
        """
        Returns a full show dir/metadata/episode.xml path for MediaBrowser
        episode metadata files

        ep_obj: a TVEpisode object to get the path for
        """

        if ek(os.path.isfile, ep_obj.location):
            xml_file_name = replace_extension(ek(os.path.basename, ep_obj.location), self._ep_nfo_extension)
            metadata_dir_name = ek(os.path.join, ek(os.path.dirname, ep_obj.location), 'metadata')
            xml_file_path = ek(os.path.join, metadata_dir_name, xml_file_name)
        else:
            logger.log("Episode location doesn't exist: " + str(ep_obj.location), logger.DEBUG)
            return ''

        return xml_file_path
开发者ID:Elettronik,项目名称:SickRage,代码行数:17,代码来源:mediabrowser.py


示例7: get_episode_file_path

 def get_episode_file_path(self, ep_obj):
     return replace_extension(ep_obj.location, self._ep_nfo_extension)
开发者ID:feld,项目名称:SickRage,代码行数:2,代码来源:generic.py


示例8: test_replace_extension

    def test_replace_extension(self):
        """
        Test replace extension
        """
        test_cases = {
            (None, None): None,
            (None, ''): None,
            (42, None): 42,
            (42, ''): 42,
            ('', None): '',
            ('', ''): '',
            ('.', None): '.',
            ('.', ''): '.',
            ('.', 'avi'): '.',
            ('filename', None): 'filename',
            ('filename', ''): 'filename',
            ('filename', 'avi'): 'filename',
            ('.bashrc', None): '.bashrc',
            ('.bashrc', ''): '.bashrc',
            ('.bashrc', 'avi'): '.bashrc',
            ('file.mkv', None): 'file.None',
            ('file.mkv', ''): 'file.',
            ('file.mkv', 'avi'): 'file.avi',
            ('file.name.mkv', None): 'file.name.None',
            ('file.name.mkv', ''): 'file.name.',
            ('file.name.mkv', 'avi'): 'file.name.avi',
        }

        unicode_test_cases = {
            (None, u''): None,
            (42, u''): 42,
            ('', u''): '',
            (u'', None): u'',
            (u'', ''): u'',
            (u'', u''): u'',
            ('.', u''): '.',
            ('.', u'avi'): '.',
            (u'.', None): u'.',
            (u'.', ''): u'.',
            (u'.', u''): u'.',
            (u'.', 'avi'): u'.',
            (u'.', u'avi'): u'.',
            ('filename', u''): 'filename',
            ('filename', u'avi'): 'filename',
            (u'filename', None): u'filename',
            (u'filename', ''): u'filename',
            (u'filename', u''): u'filename',
            (u'filename', 'avi'): u'filename',
            (u'filename', u'avi'): u'filename',
            ('.bashrc', u''): '.bashrc',
            ('.bashrc', u'avi'): '.bashrc',
            (u'.bashrc', None): u'.bashrc',
            (u'.bashrc', ''): u'.bashrc',
            (u'.bashrc', u''): u'.bashrc',
            (u'.bashrc', 'avi'): u'.bashrc',
            (u'.bashrc', u'avi'): u'.bashrc',
            ('file.mkv', u''): 'file.',
            ('file.mkv', u'avi'): 'file.avi',
            (u'file.mkv', None): u'file.None',
            (u'file.mkv', ''): u'file.',
            (u'file.mkv', u''): u'file.',
            (u'file.mkv', 'avi'): u'file.avi',
            (u'file.mkv', u'avi'): u'file.avi',
            ('file.name.mkv', u''): 'file.name.',
            ('file.name.mkv', u'avi'): 'file.name.avi',
            (u'file.name.mkv', None): u'file.name.None',
            (u'file.name.mkv', ''): u'file.name.',
            (u'file.name.mkv', u''): u'file.name.',
            (u'file.name.mkv', 'avi'): u'file.name.avi',
            (u'file.name.mkv', u'avi'): u'file.name.avi',
        }

        for tests in test_cases, unicode_test_cases:
            for ((filename, extension), result) in tests.iteritems():
                self.assertEqual(replace_extension(filename, extension), result)
开发者ID:miigotu,项目名称:sickrage-readynas,代码行数:75,代码来源:common_tests.py


示例9: get_episode_thumb_path

 def get_episode_thumb_path(ep_obj):
     return replace_extension(ep_obj.location, 'jpg')
开发者ID:bitzorro,项目名称:SickRage,代码行数:2,代码来源:mede8er.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.sanitize_filename函数代码示例发布时间:2022-05-27
下一篇:
Python common.episode_num函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap