示例#1
0
    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
示例#2
0
    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
示例#3
0
    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 %s at %s' % (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):
                if self._verify_download(filename):
                    logger.log(u'Saved result to %s' % filename, logger.INFO)
                    return True

                logger.log(u'Could not download %s' % url, logger.WARNING)
                remove_file_failed(filename)

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

        return False
示例#4
0
    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
示例#5
0
    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
示例#6
0
    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
    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
示例#8
0
文件: wdtv.py 项目: pjg101/SickRage
    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
    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
示例#10
0
文件: generic.py 项目: feld/SickRage
 def get_episode_file_path(self, ep_obj):
     return replace_extension(ep_obj.location, self._ep_nfo_extension)
示例#11
0
文件: mede8er.py 项目: vlone/SickRage
 def get_episode_thumb_path(ep_obj):
     return replace_extension(ep_obj.location, 'jpg')
示例#12
0
文件: mede8er.py 项目: vlone/SickRage
 def get_episode_file_path(self, ep_obj):
     return replace_extension(ep_obj.location, self._ep_nfo_extension)
示例#13
0
    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)
示例#14
0
 def get_episode_thumb_path(ep_obj):
     return replace_extension(ep_obj.location, 'jpg')
示例#15
0
    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, ''): None,
            (42, ''): 42,
            ('', ''): '',
            ('', None): '',
            ('', ''): '',
            ('', ''): '',
            ('.', ''): '.',
            ('.', 'avi'): '.',
            ('.', None): '.',
            ('.', ''): '.',
            ('.', ''): '.',
            ('.', 'avi'): '.',
            ('.', 'avi'): '.',
            ('filename', ''): 'filename',
            ('filename', 'avi'): 'filename',
            ('filename', None): 'filename',
            ('filename', ''): 'filename',
            ('filename', ''): 'filename',
            ('filename', 'avi'): 'filename',
            ('filename', 'avi'): 'filename',
            ('.bashrc', ''): '.bashrc',
            ('.bashrc', 'avi'): '.bashrc',
            ('.bashrc', None): '.bashrc',
            ('.bashrc', ''): '.bashrc',
            ('.bashrc', ''): '.bashrc',
            ('.bashrc', 'avi'): '.bashrc',
            ('.bashrc', 'avi'): '.bashrc',
            ('file.mkv', ''): 'file.',
            ('file.mkv', 'avi'): 'file.avi',
            ('file.mkv', None): 'file.None',
            ('file.mkv', ''): 'file.',
            ('file.mkv', ''): 'file.',
            ('file.mkv', 'avi'): 'file.avi',
            ('file.mkv', 'avi'): 'file.avi',
            ('file.name.mkv', ''): 'file.name.',
            ('file.name.mkv', 'avi'): 'file.name.avi',
            ('file.name.mkv', None): 'file.name.None',
            ('file.name.mkv', ''): 'file.name.',
            ('file.name.mkv', ''): 'file.name.',
            ('file.name.mkv', 'avi'): 'file.name.avi',
            ('file.name.mkv', 'avi'): 'file.name.avi',
        }

        for tests in test_cases, unicode_test_cases:
            for ((filename, extension), result) in six.iteritems(tests):
                self.assertEqual(replace_extension(filename, extension),
                                 result)