|  | @@ -13,38 +13,92 @@ class TestNyaaEngine(SearxTestCase):
 | 
	
		
			
			| 13 | 13 |          params = nyaa.request(query, dic)
 | 
	
		
			
			| 14 | 14 |          self.assertTrue('url' in params)
 | 
	
		
			
			| 15 | 15 |          self.assertTrue(query in params['url'])
 | 
	
		
			
			| 16 |  | -        self.assertTrue('nyaa.se' in params['url'])
 | 
	
		
			
			|  | 16 | +        self.assertTrue('nyaa.si' in params['url'])
 | 
	
		
			
			| 17 | 17 |  
 | 
	
		
			
			| 18 | 18 |      def test_response(self):
 | 
	
		
			
			| 19 | 19 |          resp = mock.Mock(text='<html></html>')
 | 
	
		
			
			| 20 | 20 |          self.assertEqual(nyaa.response(resp), [])
 | 
	
		
			
			| 21 | 21 |  
 | 
	
		
			
			| 22 | 22 |          html = """
 | 
	
		
			
			| 23 |  | -        <table class="tlist">
 | 
	
		
			
			| 24 |  | -          <tbody>
 | 
	
		
			
			| 25 |  | -            <tr class="trusted tlistrow">
 | 
	
		
			
			| 26 |  | -              <td class="tlisticon">
 | 
	
		
			
			| 27 |  | -                <a href="//www.nyaa.se" title="English-translated Anime">
 | 
	
		
			
			| 28 |  | -                   <img src="//files.nyaa.se" alt="English-translated Anime">
 | 
	
		
			
			| 29 |  | -                </a>
 | 
	
		
			
			| 30 |  | -              </td>
 | 
	
		
			
			| 31 |  | -              <td class="tlistname">
 | 
	
		
			
			| 32 |  | -                <a href="//www.nyaa.se/?page3">
 | 
	
		
			
			| 33 |  | -                  Sample torrent title
 | 
	
		
			
			| 34 |  | -                </a>
 | 
	
		
			
			| 35 |  | -              </td>
 | 
	
		
			
			| 36 |  | -              <td class="tlistdownload">
 | 
	
		
			
			| 37 |  | -                <a href="//www.nyaa.se/?page_dl" title="Download">
 | 
	
		
			
			| 38 |  | -                  <img src="//files.nyaa.se/www-dl.png" alt="DL">
 | 
	
		
			
			| 39 |  | -                </a>
 | 
	
		
			
			| 40 |  | -              </td>
 | 
	
		
			
			| 41 |  | -              <td class="tlistsize">10 MiB</td>
 | 
	
		
			
			| 42 |  | -              <td class="tlistsn">1</td>
 | 
	
		
			
			| 43 |  | -              <td class="tlistln">3</td>
 | 
	
		
			
			| 44 |  | -              <td class="tlistdn">666</td>
 | 
	
		
			
			| 45 |  | -              <td class="tlistmn">0</td>
 | 
	
		
			
			| 46 |  | -            </tr>
 | 
	
		
			
			| 47 |  | -          </tbody>
 | 
	
		
			
			|  | 23 | +        <table class="table table-bordered table-hover table-striped torrent-list">
 | 
	
		
			
			|  | 24 | +        <thead>
 | 
	
		
			
			|  | 25 | +        <tr>
 | 
	
		
			
			|  | 26 | +        <th class="hdr-category text-center" style="width:80px;">
 | 
	
		
			
			|  | 27 | +        <div>Category</div>
 | 
	
		
			
			|  | 28 | +        </th>
 | 
	
		
			
			|  | 29 | +        <th class="hdr-name" style="width:auto;">
 | 
	
		
			
			|  | 30 | +        <div>Name</div>
 | 
	
		
			
			|  | 31 | +        </th>
 | 
	
		
			
			|  | 32 | +        <th class="hdr-comments sorting text-center" title="Comments" style="width:50px;">
 | 
	
		
			
			|  | 33 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=comments&o=desc"></a>
 | 
	
		
			
			|  | 34 | +        <i class="fa fa-comments-o"></i>
 | 
	
		
			
			|  | 35 | +        </th>
 | 
	
		
			
			|  | 36 | +        <th class="hdr-link text-center" style="width:70px;">
 | 
	
		
			
			|  | 37 | +        <div>Link</div>
 | 
	
		
			
			|  | 38 | +        </th>
 | 
	
		
			
			|  | 39 | +        <th class="hdr-size sorting text-center" style="width:100px;">
 | 
	
		
			
			|  | 40 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=size&o=desc"></a>
 | 
	
		
			
			|  | 41 | +        <div>Size</div>
 | 
	
		
			
			|  | 42 | +        </th>
 | 
	
		
			
			|  | 43 | +        <th class="hdr-date sorting_desc text-center" title="In local time" style="width:140px;">
 | 
	
		
			
			|  | 44 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=id&o=asc"></a>
 | 
	
		
			
			|  | 45 | +        <div>Date</div>
 | 
	
		
			
			|  | 46 | +        </th>
 | 
	
		
			
			|  | 47 | +        <th class="hdr-seeders sorting text-center" title="Seeders" style="width:50px;">
 | 
	
		
			
			|  | 48 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=seeders&o=desc"></a>
 | 
	
		
			
			|  | 49 | +        <i class="fa fa-arrow-up" aria-hidden="true"></i>
 | 
	
		
			
			|  | 50 | +        </th>
 | 
	
		
			
			|  | 51 | +        <th class="hdr-leechers sorting text-center" title="Leechers" style="width:50px;">
 | 
	
		
			
			|  | 52 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=leechers&o=desc"></a>
 | 
	
		
			
			|  | 53 | +        <i class="fa fa-arrow-down" aria-hidden="true"></i>
 | 
	
		
			
			|  | 54 | +        </th>
 | 
	
		
			
			|  | 55 | +        <th class="hdr-downloads sorting text-center" title="Completed downloads" style="width:50px;">
 | 
	
		
			
			|  | 56 | +        <a href="/?f=0&c=0_0&q=Death+Parade&s=downloads&o=desc"></a>
 | 
	
		
			
			|  | 57 | +        <i class="fa fa-check" aria-hidden="true"></i>
 | 
	
		
			
			|  | 58 | +        </th>
 | 
	
		
			
			|  | 59 | +        </tr>
 | 
	
		
			
			|  | 60 | +        </thead>
 | 
	
		
			
			|  | 61 | +        <tbody>
 | 
	
		
			
			|  | 62 | +        <tr class="default">
 | 
	
		
			
			|  | 63 | +        <td style="padding:0 4px;">
 | 
	
		
			
			|  | 64 | +        <a href="/?c=1_2" title="Anime - English-translated">
 | 
	
		
			
			|  | 65 | +        <img src="/static/img/icons/nyaa/1_2.png" alt="Anime - English-translated">
 | 
	
		
			
			|  | 66 | +        </a>
 | 
	
		
			
			|  | 67 | +        </td>
 | 
	
		
			
			|  | 68 | +        <td colspan="2">
 | 
	
		
			
			|  | 69 | +        <a href="/view/1" title="Sample title 1">Sample title 1</a>
 | 
	
		
			
			|  | 70 | +        </td>
 | 
	
		
			
			|  | 71 | +        <td class="text-center" style="white-space: nowrap;">
 | 
	
		
			
			|  | 72 | +        <a href="/download/1.torrent"><i class="fa fa-fw fa-download"></i></a>
 | 
	
		
			
			|  | 73 | +        <a href="magnet:?xt=urn:btih:2"><i class="fa fa-fw fa-magnet"></i></a>
 | 
	
		
			
			|  | 74 | +        </td>
 | 
	
		
			
			|  | 75 | +        <td class="text-center">723.7 MiB</td>
 | 
	
		
			
			|  | 76 | +        <td class="text-center" data-timestamp="1503307456" title="1 week 3
 | 
	
		
			
			|  | 77 | +        days 9 hours 44 minutes 39 seconds ago">2017-08-21 11:24</td>
 | 
	
		
			
			|  | 78 | +        <td class="text-center" style="color: green;">1</td>
 | 
	
		
			
			|  | 79 | +        <td class="text-center" style="color: red;">3</td>
 | 
	
		
			
			|  | 80 | +        <td class="text-center">12</td>
 | 
	
		
			
			|  | 81 | +        </tr>
 | 
	
		
			
			|  | 82 | +        <tr class="default">
 | 
	
		
			
			|  | 83 | +        <td style="padding:0 4px;">
 | 
	
		
			
			|  | 84 | +        <a href="/?c=1_2" title="Anime - English-translated">
 | 
	
		
			
			|  | 85 | +        <img src="/static/img/icons/nyaa/1_2.png" alt="Anime - English-translated">
 | 
	
		
			
			|  | 86 | +        </a>
 | 
	
		
			
			|  | 87 | +        </td>
 | 
	
		
			
			|  | 88 | +        <td colspan="2">
 | 
	
		
			
			|  | 89 | +        <a href="/view/2" title="Sample title 2">Sample title 2</a>
 | 
	
		
			
			|  | 90 | +        </td>
 | 
	
		
			
			|  | 91 | +        <td class="text-center" style="white-space: nowrap;">
 | 
	
		
			
			|  | 92 | +        <a href="magnet:?xt=urn:btih:2"><i class="fa fa-fw fa-magnet"></i></a>
 | 
	
		
			
			|  | 93 | +        </td>
 | 
	
		
			
			|  | 94 | +        <td class="text-center">8.2 GiB</td>
 | 
	
		
			
			|  | 95 | +        <td class="text-center" data-timestamp="1491608400" title="4 months 3
 | 
	
		
			
			|  | 96 | +        weeks 4 days 19 hours 28 minutes 55 seconds ago">2017-04-08 01:40</td>
 | 
	
		
			
			|  | 97 | +        <td class="text-center" style="color: green;">10</td>
 | 
	
		
			
			|  | 98 | +        <td class="text-center" style="color: red;">1</td>
 | 
	
		
			
			|  | 99 | +        <td class="text-center">206</td>
 | 
	
		
			
			|  | 100 | +        </tr>
 | 
	
		
			
			|  | 101 | +        </tbody>
 | 
	
		
			
			| 48 | 102 |          </table>
 | 
	
		
			
			| 49 | 103 |          """
 | 
	
		
			
			| 50 | 104 |  
 | 
	
	
		
			
			|  | @@ -52,15 +106,19 @@ class TestNyaaEngine(SearxTestCase):
 | 
	
		
			
			| 52 | 106 |          results = nyaa.response(resp)
 | 
	
		
			
			| 53 | 107 |  
 | 
	
		
			
			| 54 | 108 |          self.assertEqual(type(results), list)
 | 
	
		
			
			| 55 |  | -        self.assertEqual(len(results), 1)
 | 
	
		
			
			|  | 109 | +        self.assertEqual(len(results), 2)
 | 
	
		
			
			| 56 | 110 |  
 | 
	
		
			
			| 57 | 111 |          r = results[0]
 | 
	
		
			
			| 58 |  | -        self.assertTrue(r['url'].find('www.nyaa.se/?page3') >= 0)
 | 
	
		
			
			| 59 |  | -        self.assertTrue(r['torrentfile'].find('www.nyaa.se/?page_dl') >= 0)
 | 
	
		
			
			| 60 |  | -        self.assertTrue(r['content'].find('English-translated Anime') >= 0)
 | 
	
		
			
			| 61 |  | -        self.assertTrue(r['content'].find('Downloaded 666 times.') >= 0)
 | 
	
		
			
			|  | 112 | +        self.assertTrue(r['url'].find('1') >= 0)
 | 
	
		
			
			|  | 113 | +        self.assertTrue(r['torrentfile'].find('1.torrent') >= 0)
 | 
	
		
			
			|  | 114 | +        self.assertTrue(r['content'].find('Anime - English-translated') >= 0)
 | 
	
		
			
			|  | 115 | +        self.assertTrue(r['content'].find('Downloaded 12 times.') >= 0)
 | 
	
		
			
			| 62 | 116 |  
 | 
	
		
			
			| 63 |  | -        self.assertEqual(r['title'], 'Sample torrent title')
 | 
	
		
			
			|  | 117 | +        self.assertEqual(r['title'], 'Sample title 1')
 | 
	
		
			
			| 64 | 118 |          self.assertEqual(r['seed'], 1)
 | 
	
		
			
			| 65 | 119 |          self.assertEqual(r['leech'], 3)
 | 
	
		
			
			| 66 |  | -        self.assertEqual(r['filesize'], 10 * 1024 * 1024)
 | 
	
		
			
			|  | 120 | +        self.assertEqual(r['filesize'], 723700000)
 | 
	
		
			
			|  | 121 | +
 | 
	
		
			
			|  | 122 | +        r = results[1]
 | 
	
		
			
			|  | 123 | +        self.assertTrue(r['url'].find('2') >= 0)
 | 
	
		
			
			|  | 124 | +        self.assertTrue(r['magnetlink'].find('magnet:') >= 0)
 |