Ejemplo n.º 1
0
    def testInvalidArgs(self):
        # Check invalid args
        output = json.loads( ktorrent.search(search='Linux', strict=404, category='book') )
        self.assertEqual(output['status'], 400)

        output = json.loads( ktorrent.search(category='books') )
        self.assertEqual(output['status'], 400)

        output = json.loads( ktorrent.top(category='movies', page='2') )
        self.assertEqual(output['status'], 400)
Ejemplo n.º 2
0
    def testInvalidArgs(self):
        # Check invalid args
        output = json.loads(
            ktorrent.search(search='Linux', strict=404, category='book'))
        self.assertEqual(output['status'], 400)

        output = json.loads(ktorrent.search(category='books'))
        self.assertEqual(output['status'], 400)

        output = json.loads(ktorrent.top(category='movies', page='2'))
        self.assertEqual(output['status'], 400)
Ejemplo n.º 3
0
    async def torrent(self, ctx, *, text):
        """Search for various torrents"""
        if text == ():
            await send_cmd_help(ctx)
            return
        text = "".join(text)
        #print(text)
        # Basic Search
        search = ktorrent.search(search=text)
        # Complex Search
        #search = ktorrent.search(search='Linux Shell script', strict=1, category='books', field='age', sorder='desc', page=2)
        #print (search)
        # Top books
        #search = ktorrent.top(category=text)
        # Top movies
        #search = ktorrent.top(category=text, page=2)
        #print (top_books)
        """
        "meta"
            "pageCurrent"
            "pageResult"
            "pageTotal"
            //
			"age"
			"category"
			"files"
			"leech"
			"link"
			"magnet"
			"name"
			"seed"
			"size"
			"verified"
			"web"
        """

        #print (search)
        d = json.loads(search)

        if len(d) > 1:
            list = "\n"
            index = 0
            for items in range(0, len(d)):
                index += 1
                item = d["torrent"][items]
                name = item["name"][:200]
                emoij_index = self.replace_text(str(index))
                list = list + "{6}\n       **Name: **{0}\n       **Age: **{1}\n**       Leech/Seed: **{2}/{3}\n**       Size: **{4}\n**       Link: **{5}\n\n".format(
                    name, item["age"], item["seed"], item["leech"],
                    item["size"], item["link"], emoij_index)
            await self.bot.say(list)
        else:
            await self.bot.say("shrug")
Ejemplo n.º 4
0
    async def torrent(self, ctx, *, text):
        """Search for various torrents"""
        if text == ():
            await send_cmd_help(ctx)
            return
        text = "".join(text)
        #print(text)        
        # Basic Search
        search = ktorrent.search(search=text)
        # Complex Search
        #search = ktorrent.search(search='Linux Shell script', strict=1, category='books', field='age', sorder='desc', page=2)
        #print (search)
        # Top books
        #search = ktorrent.top(category=text)
        # Top movies
        #search = ktorrent.top(category=text, page=2)
        #print (top_books)
        """
        "meta"
            "pageCurrent"
            "pageResult"
            "pageTotal"
            //
			"age"
			"category"
			"files"
			"leech"
			"link"
			"magnet"
			"name"
			"seed"
			"size"
			"verified"
			"web"
        """
        
        #print (search)
        d = json.loads(search)
            
        if len(d) > 1:
            list = "\n"
            index = 0
            for items in range(0, len(d)):
                index += 1
                item = d["torrent"][items]
                name = item["name"][:200] 
                emoij_index = self.replace_text(str(index))
                list = list + "{6}\n       **Name: **{0}\n       **Age: **{1}\n**       Leech/Seed: **{2}/{3}\n**       Size: **{4}\n**       Link: **{5}\n\n".format(name, item["age"], item["seed"], item["leech"], item["size"], item["link"], emoij_index)
            await self.bot.say(list)
        else:      
            await self.bot.say("shrug")
Ejemplo n.º 5
0
def search_results(adv):

    search = click.prompt('Enter Search Query')

    params = {
        'search':   search,
        'strict':   0,
        'safe':     0,
        'verified': 0,
        'subtract': '',
        'user':     '',
        'category': 'all',
        'field':    'seed',
        'sorder':   'desc',
        'page':     1
    }

    if adv:
        params = get_params(**params)

    data = json.loads( ktorrent.search(**params) )

    if check_status( data['status'] ):
        print_data( data['torrent'] )
Ejemplo n.º 6
0
def search_results(adv):

    search = click.prompt('Enter Search Query')

    params = {
        'search': search,
        'strict': 0,
        'safe': 0,
        'verified': 0,
        'subtract': '',
        'user': '',
        'category': 'all',
        'field': 'seed',
        'sorder': 'desc',
        'page': 1
    }

    if adv:
        params = get_params(**params)

    data = json.loads(ktorrent.search(**params))

    if check_status(data['status']):
        print_data(data['torrent'])
Ejemplo n.º 7
0
 def testSearch(self):
     # search: Validate JSON
     output = ktorrent.search(search='linux')
     self.assertEqual(type(json.loads(output)) is dict, True)
Ejemplo n.º 8
0
 def testSearch(self):
     # search: Validate JSON
     output = ktorrent.search(search='linux')
     self.assertEqual( type( json.loads(output) ) is dict , True)