Пример #1
0
    def search(self, keywords, category='210'):
        """
			@param string keywords   
			@param string category

			@return array of Torrent 
		"""
        if category in self.CATEGORY:
            catid = self.CATEGORY[category]
        else:
            catid = '210'

        response = []
        logger.print_info("Recherche en cours ...", eol='')
        json_response = self.__call_json(
            "torrents/search/%s&cid=%s" % (keywords, catid), {
                'offset': '0',
                'limit': '200'
            })
        logger.print_ok()

        for torrent in json_response['torrents']:
            response.append(Torrent(torrent))

        return response
Пример #2
0
	def loadToken(self):
		"""
			Process Authentification
		"""
		logger.print_info("Authentification ... ",eol='')
		json_decode = self.__call_json('auth',{'username':self.USERNAME,'password':self.PASSWORD})
		self.token = json_decode['token']
		logger.print_ok()
Пример #3
0
	def download(self,tid):
		"""
			@param int tid : id of the expected torrent
			@return torrent data
		"""
		logger.print_info("Download torrent ... ",eol='')
		torrent = self.__call("torrents/download/%s" % tid)
		logger.print_ok()
		return torrent
Пример #4
0
    def download(self, tid):
        """
			@param int tid : id of the expected torrent
			@return torrent data
		"""
        logger.print_info("Download torrent ... ", eol='')
        torrent = self.__call("torrents/download/%s" % tid)
        logger.print_ok()
        return torrent
Пример #5
0
    def loadToken(self):
        """
			Process Authentification
		"""
        logger.print_info("Authentification ... ", eol='')
        json_decode = self.__call_json('auth', {
            'username': self.USERNAME,
            'password': self.PASSWORD
        })
        self.token = json_decode['token']
        logger.print_ok()
Пример #6
0
	def search(self,keywords,category='210'):
		"""
			@param string keywords   
			@param string category

			@return array of Torrent 
		"""
		if category in self.CATEGORY:
			catid = self.CATEGORY[ category ]
		else:
			catid = '210'
		
		response = []
		logger.print_info("Recherche en cours ...",eol='')
		json_response = self.__call_json("torrents/search/%s&cid=%s" % (keywords,catid), {'offset':'0', 'limit':'200'})
		logger.print_ok()

		for torrent in json_response['torrents']:
			response.append( Torrent(torrent) )

		return response
Пример #7
0
	def processDownloadTransmission(self,torrent_datas):
		torrent_datas = torrent_replace_announce( torrent_datas, self.config.get('transmission','tracker') )

		logger.print_info('Connexion au server transmission ... ', eol='')
		tc = transmissionrpc.Client( self.config.get('transmission','host') ,
		 	port=self.config.get('transmission','port') ,
		 	user=self.config.get('transmission','username'),
		 	password=self.config.get('transmission','password'))
		logger.print_ok()

		logger.print_info("Upload du torrent ... ",eol='')
		torrent = tc.add_torrent(base64.b64encode(torrent_datas))
		logger.print_ok()

		torrent = tc.get_torrent(torrent.id)
		while torrent.progress < 100:
			sys.stdout.write('\r %.2f%% [%-100s] ' % ( torrent.progress, "="*int(torrent.progress)+">" ))
			sys.stdout.flush()
			torrent = tc.get_torrent(torrent.id)
			time.sleep(1)
		print '\r 100%% [%s]   '%('='*100)
		logger.print_success( 'Download complet' )
		tc.stop_torrent(torrent)
Пример #8
0
	def processDownloadTransmission(self,torrent_datas):
		torrent_datas = torrent_replace_announce( torrent_datas, self.config.get('transmission','tracker') )

		logger.print_info('Connexion au server transmission ... ', eol='')
		tc = transmissionrpc.Client( self.config.get('transmission','host') ,
		 	port=self.config.get('transmission','port') ,
		 	user=self.config.get('transmission','username'),
		 	password=self.config.get('transmission','password'))
		logger.print_ok()

		logger.print_info("Upload du torrent ... ",eol='')
		torrent = tc.add_torrent(base64.b64encode(torrent_datas))
		logger.print_ok()

		torrent = tc.get_torrent(torrent.id)
		while torrent.progress < 100:
			sys.stdout.write('\r %.2f%% [%-100s] ' % ( torrent.progress, "="*int(torrent.progress)+">" ))
			sys.stdout.flush()
			torrent = tc.get_torrent(torrent.id)
			time.sleep(1)
		print '\r 100%% [%s]   '%('='*100)
		logger.print_success( 'Download complet' )
		tc.stop_torrent(torrent)