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


Python common.replace_extension函数代码示例

本文整理汇总了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;未经允许,请勿转载。