def read(self):
        self.__init()
        cw = self.cw
        if cw:
            cw._torrent_s = None
        title = self.url
        self._dn = self.get_dn(self.url)
        info = getattr(cw, 'info?', None)
        if info is not None:
            self.print_('cached info')
            self._info = info
        if self._info is None:
            try:
                self._info = torrent.get_info(self.url,
                                              cw,
                                              timeout=TIMEOUT,
                                              callback=self.callback)
                if CACHE_INFO:
                    setattr(cw, 'info?', self._info)
            except Exception as e:
                self.update_pause()
                if not cw.paused:
                    raise errors.Invalid('Faild to read metadata: {}'.format(
                        self.url),
                                         fail=True)
        if self._info is None:
            cw.paused = True
        if cw.paused:
            return
        hash_ = self._info.hash.hex()
        self.print_('v2: {}'.format(self._info.v2))
        self.print_('Hash: {}'.format(hash_))
        if not self._info.v2:
            self.url = 'magnet:?xt=urn:btih:{}'.format(hash_)  #
        date = datetime.fromtimestamp(self._info.creation_date())
        date = date.strftime('%y-%m-%d %H:%M:%S')
        self.print_('Created on: {}'.format(date))
        self.print_('Total size: {}'.format(fs.size(self._info.total_size())))
        self.print_('Pieces: {} x {}'.format(
            self._info.num_pieces(), fs.size(self._info.piece_length())))
        self.print_('Creator: {}'.format(self._info.creator()))
        self.print_('Comment: {}'.format(self._info.comment()))
        cw.setTotalFileSize(self._info.total_size())

        cw.imgs.clear()
        cw.dones.clear()

        self.urls = [self.url]
        self.title = self.name
        self.update_files()

        if not self.single and not os.path.isdir(self.dir):  #4698
            downloader.makedir_event(self.dir, cw)

        cw.pbar.show()
示例#2
0
    def read(self):
        cw = self.customWidget
        try:
            self._info = torrent.get_info(self.url, cw)
        except Exception as e:
            return self.Invalid((u'Faild to read metadata: torrent_{}').format(self.url), e, fail=True)

        self.urls = [self.url]
        self.title = self.name
        files = torrent.get_files(self._info)
        if not files:
            raise Exception('No files')
        cw.single = self.single = len(files) == 1
        for file in files:
            filename = os.path.join(self.dir, file)
            cw.imgs.append(filename)
    def read(self):
        cw = self.cw
        title = self.url
        if self.url.startswith('magnet:'):
            qs = utils.query_url(self.url)
            if 'dn' in qs:
                self._dn = qs['dn'][0]
        info = getattr(cw, 'info?', None)
        if info is not None:
            self.print_('cached info')
            self._info = info
        if self._info is None:
            try:
                self._info = torrent.get_info(self.url, cw, timeout=TIMEOUT, callback=self.callback)
                if CACHE_INFO:
                    setattr(cw, 'info?', self._info)
            except Exception as e:
                self.update_pause()
                if not cw.paused:
                    raise errors.Invalid('Faild to read metadata: {}'.format(self.url), fail=True)
        if self._info is None:
            cw.paused = True
        if cw.paused:
            return
        hash_ = self._info.hash.hex()
        self.print_('v2: {}'.format(self._info.v2))
        self.print_('Hash: {}'.format(hash_))
        if not self._info.v2:
            self.url = 'magnet:?xt=urn:btih:{}'.format(hash_)#
        date = datetime.fromtimestamp(self._info.creation_date())
        date = date.strftime('%y-%m-%d %H:%M:%S')
        self.print_('Created on: {}'.format(date))
        self.print_('Total size: {}'.format(fs.size(self._info.total_size())))
        self.print_('Pieces: {} x {}'.format(self._info.num_pieces(), fs.size(self._info.piece_length())))
        self.print_('Creator: {}'.format(self._info.creator()))
        self.print_('Comment: {}'.format(self._info.comment()))
        cw.setTotalFileSize(self._info.total_size())
        
        cw.imgs.clear()
        cw.dones.clear()

        self.urls = [self.url]
        self.title = self.name
        self.update_files()
        
        cw.pbar.show()
示例#4
0
    def read(self):
        cw = self.cw
        try:
            self._info = torrent.get_info(self.url, cw, timeout=TIMEOUT)
        except Exception as e:
            return self.Invalid('Faild to read metadata: {}'.format(self.url),
                                e,
                                fail=True)
        hash_ = self._info._hash.hex()
        self.print_('Hash: {}'.format(hash_))
        self.url = 'magnet:?xt=urn:btih:{}'.format(hash_)  #

        self.urls = [self.url]
        self.title = self.name
        files = torrent.get_files(self._info)
        if not files:
            raise Exception('No files')
        cw.single = self.single = len(files) == 1
        for file in files:
            filename = os.path.join(self.dir, file)
            cw.imgs.append(filename)