예제 #1
0
파일: test.py 프로젝트: pwf115/mylar
    def main(self, torrent_hash=None, filepath=None, check=False):

        torrent = self.client.find_torrent(torrent_hash)
        if torrent:
            if check:
                logger.info(
                    'Successfully located torrent %s by hash on client. Detailed statistics to follow',
                    torrent_hash)
            else:
                logger.warn(
                    "%s Torrent already exists. Not downloading at this time.",
                    torrent_hash)
                return
        else:
            if check:
                logger.warn('Unable to locate torrent with a hash value of %s',
                            torrent_hash)
                return

        if filepath:
            loadit = self.client.load_torrent(filepath)
            if loadit:
                torrent_hash = self.get_the_hash(filepath)
            else:
                return

        torrent = self.client.find_torrent(torrent_hash)
        if torrent is None:
            logger.warn("Couldn't find torrent with hash: %s", torrent_hash)
            sys.exit(-1)

        torrent_info = self.client.get_torrent(torrent)
        if check:
            return torrent_info

        if torrent_info['completed']:
            logger.info("Directory: %s", torrent_info['folder'])
            logger.info("Name: %s", torrent_info['name'])
            logger.info("FileSize: %s",
                        helpers.human_size(torrent_info['total_filesize']))
            logger.info("Completed: %s", torrent_info['completed'])
            logger.info("Downloaded: %s",
                        helpers.human_size(torrent_info['download_total']))
            logger.info("Uploaded: %s",
                        helpers.human_size(torrent_info['upload_total']))
            logger.info("Ratio: %s", torrent_info['ratio'])
            #logger.info("Time Started: %s", torrent_info['time_started'])
            logger.info(
                "Seeding Time: %s",
                helpers.humanize_time(
                    int(time.time()) - torrent_info['time_started']))

            if torrent_info['label']:
                logger.info("Torrent Label: %s", torrent_info['label'])

        #logger.info(torrent_info)
        return torrent_info
예제 #2
0
파일: test.py 프로젝트: rupaschomaker/mylar
    def main(self, torrent_hash=None, filepath=None, check=False):

        torrent = self.client.find_torrent(torrent_hash)
        if torrent:
            if check:
                logger.fdebug('Successfully located torrent %s by hash on client. Detailed statistics to follow', torrent_hash)
            else:
                logger.warn("%s Torrent already exists. Not downloading at this time.", torrent_hash)
                return
        else:
            if check:
                logger.warn('Unable to locate torrent with a hash value of %s', torrent_hash)
                return

        if filepath:
            loadit = self.client.load_torrent(filepath)
            if loadit:
                if filepath.startswith('magnet'):
                    torrent_hash = re.findall("urn:btih:([\w]{32,40})", filepath)[0]
                    if len(torrent_hash) == 32:
                        torrent_hash = b16encode(b32decode(torrent_hash)).lower()
                    torrent_hash = torrent_hash.upper()
                else:
                    torrent_hash = self.get_the_hash(filepath)
            else:
                return

        torrent = self.client.find_torrent(torrent_hash)
        if torrent is None:
            logger.warn("Couldn't find torrent with hash: %s", torrent_hash)
            sys.exit(-1)

        torrent_info = self.client.get_torrent(torrent)
        if check:
            return torrent_info

        if torrent_info['completed']:
            logger.fdebug("Directory: %s", torrent_info['folder'])
            logger.fdebug("Name: %s", torrent_info['name'])
            logger.fdebug("FileSize: %s", helpers.human_size(torrent_info['total_filesize']))
            logger.fdebug("Completed: %s", torrent_info['completed'])
            logger.fdebug("Downloaded: %s", helpers.human_size(torrent_info['download_total']))
            logger.fdebug("Uploaded: %s", helpers.human_size(torrent_info['upload_total']))
            logger.fdebug("Ratio: %s", torrent_info['ratio'])
            #logger.info("Time Started: %s", torrent_info['time_started'])
            logger.fdebug("Seeding Time: %s", helpers.humanize_time(int(time.time()) - torrent_info['time_started']))

            if torrent_info['label']:
                logger.fdebug("Torrent Label: %s", torrent_info['label'])

        #logger.info(torrent_info)
        return torrent_info
예제 #3
0
파일: test.py 프로젝트: Mathix/mylar3
    def main(self, torrent_hash=None, filepath=None, check=False):

        torrent = self.client.find_torrent(torrent_hash)
        if torrent:
            if check:
                logger.fdebug('Successfully located torrent %s by hash on client. Detailed statistics to follow' % torrent_hash)
            else:
                logger.warn("%s Torrent already exists. Not downloading at this time." % torrent_hash)
                return
        else:
            if check:
                logger.warn('Unable to locate torrent with a hash value of %s' % torrent_hash)
                return

        if filepath:
            loadit = self.client.load_torrent(filepath)
            if loadit:
                if filepath.startswith('magnet'):
                    torrent_hash = re.findall("urn:btih:([\w]{32,40})", filepath)[0]
                    if len(torrent_hash) == 32:
                        torrent_hash = b16encode(b32decode(torrent_hash)).lower()
                    torrent_hash = torrent_hash.upper()
                else:
                    torrent_hash = self.get_the_hash(filepath)
            else:
                return

        torrent = self.client.find_torrent(torrent_hash)
        if torrent is None:
            logger.warn('Couldn\'t find torrent with hash: %s' % torrent_hash)
            sys.exit(-1)

        torrent_info = self.client.get_torrent(torrent)
        if check:
            return torrent_info

        if torrent_info['completed']:
            logger.fdebug('Directory: %s' % torrent_info['folder'])
            logger.fdebug('Name: %s' % torrent_info['name'])
            logger.fdebug('FileSize: %s' % helpers.human_size(torrent_info['total_filesize']))
            logger.fdebug('Completed: %s' % torrent_info['completed'])
            logger.fdebug('Downloaded: %s' % helpers.human_size(torrent_info['download_total']))
            logger.fdebug('Uploaded: %s' % helpers.human_size(torrent_info['upload_total']))
            logger.fdebug('Ratio: %s' % torrent_info['ratio'])
            #logger.info('Time Started: %s' % torrent_info['time_started'])
            logger.fdebug('Seeding Time: %s' % helpers.humanize_time(int(time.time()) - torrent_info['time_started']))

            if torrent_info['label']:
                logger.fdebug('Torrent Label: %s' % torrent_info['label'])

        #logger.info(torrent_info)
        return torrent_info
예제 #4
0
    def main(self, torrent_hash=None, filepath=None):

        torrent = self.client.find_torrent(torrent_hash)
        if torrent:
            logger.warn(
                "%s Torrent already exists. Not downloading at this time.",
                torrent_hash)
            return

        if filepath:
            loadit = self.client.load_torrent(filepath)
            if loadit:
                torrent_hash = self.get_the_hash(filepath)
            else:
                return

        torrent = self.client.find_torrent(torrent_hash)
        if torrent is None:
            logger.warn("Couldn't find torrent with hash: %s", torrent_hash)
            sys.exit(-1)

        torrent_info = self.client.get_torrent(torrent)
        if torrent_info['completed']:
            logger.info("Directory: %s", torrent_info['folder'])
            logger.info("Name: %s", torrent_info['name'])
            logger.info("FileSize: %s",
                        helpers.human_size(torrent_info['total_filesize']))
            logger.info("Completed: %s", torrent_info['completed'])
            logger.info("Downloaded: %s",
                        helpers.human_size(torrent_info['download_total']))
            logger.info("Uploaded: %s",
                        helpers.human_size(torrent_info['upload_total']))
            logger.info("Ratio: %s", torrent_info['ratio'])
            #logger.info("Time Started: %s", torrent_info['time_started'])
            logger.info(
                "Seeding Time: %s",
                helpers.humanize_time(
                    int(time.time()) - torrent_info['time_started']))

            if torrent_info['label']:
                logger.info("Torrent Label: %s", torrent_info['label'])

        logger.info(torrent_info)
        return torrent_info
예제 #5
0
파일: test.py 프로젝트: Xirg/mylar
    def main(self, torrent_hash=None, filepath=None):

        torrent = self.client.find_torrent(torrent_hash)
        if torrent:
            logger.warn("%s Torrent already exists. Not downloading at this time.", torrent_hash)
            return

        if filepath:
            loadit = self.client.load_torrent(filepath)
            if loadit:
                torrent_hash = self.get_the_hash(filepath)
            else:
                return

        torrent = self.client.find_torrent(torrent_hash)
        if torrent is None:
            logger.warn("Couldn't find torrent with hash: %s", torrent_hash)
            sys.exit(-1)

        torrent_info = self.client.get_torrent(torrent)
        if torrent_info['completed']:
            logger.info("Directory: %s", torrent_info['folder'])
            logger.info("Name: %s", torrent_info['name'])
            logger.info("FileSize: %s", helpers.human_size(torrent_info['total_filesize']))
            logger.info("Completed: %s", torrent_info['completed'])
            logger.info("Downloaded: %s", helpers.human_size(torrent_info['download_total']))
            logger.info("Uploaded: %s", helpers.human_size(torrent_info['upload_total']))
            logger.info("Ratio: %s", torrent_info['ratio'])
            #logger.info("Time Started: %s", torrent_info['time_started'])
            logger.info("Seeding Time: %s", helpers.humanize_time(int(time.time()) - torrent_info['time_started']))

            if torrent_info['label']:
                logger.info("Torrent Label: %s", torrent_info['label'])

        logger.info(torrent_info)
        return torrent_info