Remove some engines : subtitleseeker, seedpeer, swisscows

http://www.subtitleseeker.com and http://www.seedpeer.eu don't exist anymore.
https://swisscows.ch/ has change : the engine needs to be updated
This commit is contained in:
Dalf 2019-04-12 02:42:47 +02:00
parent 6c95ebcff5
commit ffe0972f91
7 changed files with 0 additions and 686 deletions

View file

@ -1,51 +0,0 @@
import mock
from collections import defaultdict
from searx.engines import seedpeer
from searx.testing import SearxTestCase
from datetime import datetime
class TestSeedPeerEngine(SearxTestCase):
html = ''
with open('./tests/unit/engines/seedpeer_fixture.html') as fixture:
html += fixture.read()
def test_request(self):
query = 'test_query'
dicto = defaultdict(dict)
dicto['pageno'] = 1
params = seedpeer.request(query, dicto)
self.assertIn('url', params)
self.assertIn(query, params['url'])
self.assertIn('seedpeer.eu', params['url'])
def test_response_raises_attr_error_on_empty_response(self):
self.assertRaises(AttributeError, seedpeer.response, None)
self.assertRaises(AttributeError, seedpeer.response, [])
self.assertRaises(AttributeError, seedpeer.response, '')
self.assertRaises(AttributeError, seedpeer.response, '[]')
def test_response_returns_empty_list(self):
response = mock.Mock(text='<html></html>')
self.assertEqual(seedpeer.response(response), [])
def test_response_returns_all_results(self):
response = mock.Mock(text=self.html)
results = seedpeer.response(response)
self.assertTrue(isinstance(results, list))
self.assertEqual(len(results), 2)
def test_response_returns_correct_results(self):
response = mock.Mock(text=self.html)
results = seedpeer.response(response)
self.assertEqual(
results[0]['title'], 'Narcos - Season 2 - 720p WEBRiP - x265 HEVC - ShAaNiG '
)
self.assertEqual(
results[0]['url'],
'http://www.seedpeer.eu/details/11685972/Narcos---Season-2---720p-WEBRiP---x265-HEVC---ShAaNiG.html'
)
self.assertEqual(results[0]['content'], '2.48 GB, 1 day')
self.assertEqual(results[0]['seed'], '861')
self.assertEqual(results[0]['leech'], '332')

View file

@ -1,174 +0,0 @@
from collections import defaultdict
import mock
from searx.engines import subtitleseeker
from searx.testing import SearxTestCase
class TestSubtitleseekerEngine(SearxTestCase):
def test_request(self):
query = 'test_query'
dicto = defaultdict(dict)
dicto['pageno'] = 1
dicto['language'] = 'fr-FR'
params = subtitleseeker.request(query, dicto)
self.assertTrue('url' in params)
self.assertTrue(query in params['url'])
self.assertTrue('subtitleseeker.com' in params['url'])
def test_response(self):
dicto = defaultdict(dict)
dicto['language'] = 'fr-FR'
response = mock.Mock(search_params=dicto)
self.assertRaises(AttributeError, subtitleseeker.response, None)
self.assertRaises(AttributeError, subtitleseeker.response, [])
self.assertRaises(AttributeError, subtitleseeker.response, '')
self.assertRaises(AttributeError, subtitleseeker.response, '[]')
response = mock.Mock(text='<html></html>', search_params=dicto)
self.assertEqual(subtitleseeker.response(response), [])
html = """
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
<br><br>
<span class="f10b grey-dark arial" style="padding:0px 0px 5px 20px">
"Alternative Title"
</span>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
<div class="clear"></div>
</div>
"""
response = mock.Mock(text=html, search_params=dicto)
results = subtitleseeker.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the Title')
self.assertEqual(results[0]['url'], 'http://this.is.the.url/French/')
self.assertIn('1998', results[0]['content'])
self.assertIn('1039 Subs', results[0]['content'])
self.assertIn('Alternative Title', results[0]['content'])
dicto['language'] = 'pt-BR'
results = subtitleseeker.response(response)
self.assertEqual(results[0]['url'], 'http://this.is.the.url/Brazilian/')
html = """
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
<div class="clear"></div>
</div>
"""
dicto['language'] = 'all'
response = mock.Mock(text=html, search_params=dicto)
results = subtitleseeker.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the Title')
self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
self.assertIn('1998', results[0]['content'])
self.assertIn('1039 Subs', results[0]['content'])
html = """
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
<div class="clear"></div>
</div>
"""
subtitleseeker.language = 'English'
response = mock.Mock(text=html, search_params=dicto)
results = subtitleseeker.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the Title')
self.assertEqual(results[0]['url'], 'http://this.is.the.url/English/')
self.assertIn('1998', results[0]['content'])
self.assertIn('1039 Subs', results[0]['content'])
html = """
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
"""
response = mock.Mock(text=html, search_params=dicto)
results = subtitleseeker.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 0)

View file

@ -1,157 +0,0 @@
from collections import defaultdict
import mock
from searx.engines import swisscows
from searx.testing import SearxTestCase
class TestSwisscowsEngine(SearxTestCase):
def test_request(self):
swisscows.supported_languages = ['de-AT', 'de-DE']
swisscows.language_aliases = {}
query = 'test_query'
dicto = defaultdict(dict)
dicto['pageno'] = 1
dicto['language'] = 'de-DE'
params = swisscows.request(query, dicto)
self.assertTrue('url' in params)
self.assertTrue(query in params['url'])
self.assertTrue('swisscows.ch' in params['url'])
self.assertTrue('uiLanguage=de' in params['url'])
self.assertTrue('region=de-DE' in params['url'])
dicto['language'] = 'all'
params = swisscows.request(query, dicto)
self.assertTrue('uiLanguage=browser' in params['url'])
self.assertTrue('region=browser' in params['url'])
dicto['category'] = 'images'
params = swisscows.request(query, dicto)
self.assertIn('image', params['url'])
def test_response(self):
self.assertRaises(AttributeError, swisscows.response, None)
self.assertRaises(AttributeError, swisscows.response, [])
self.assertRaises(AttributeError, swisscows.response, '')
self.assertRaises(AttributeError, swisscows.response, '[]')
response = mock.Mock(text=b'<html></html>')
self.assertEqual(swisscows.response(response), [])
response = mock.Mock(text=b'<html></html>')
self.assertEqual(swisscows.response(response), [])
html = b"""
<script>
App.Dispatcher.dispatch("initialize", {
html5history: true,
initialData: {"Request":
{"Page":1,
"ItemsCount":1,
"Query":"This should ",
"NormalizedQuery":"This should ",
"Region":"de-AT",
"UILanguage":"de"},
"Results":{"items":[
{"Title":"\uE000This should\uE001 be the title",
"Description":"\uE000This should\uE001 be the content.",
"Url":"http://this.should.be.the.link/",
"DisplayUrl":"www.\uE000this.should.be.the\uE001.link",
"Id":"782ef287-e439-451c-b380-6ebc14ba033d"},
{"Title":"Datei:This should1.svg",
"Url":"https://i.swisscows.ch/?link=http%3a%2f%2fts2.mm.This/should1.png",
"SourceUrl":"http://de.wikipedia.org/wiki/Datei:This should1.svg",
"DisplayUrl":"de.wikipedia.org/wiki/Datei:This should1.svg",
"Width":950,
"Height":534,
"FileSize":92100,
"ContentType":"image/jpeg",
"Thumbnail":{
"Url":"https://i.swisscows.ch/?link=http%3a%2f%2fts2.mm.This/should1.png",
"ContentType":"image/jpeg",
"Width":300,
"Height":168,
"FileSize":9134},
"Id":"6a97a542-8f65-425f-b7f6-1178c3aba7be"
}
],"TotalCount":55300,
"Query":"This should "
},
"Images":[{"Title":"Datei:This should.svg",
"Url":"https://i.swisscows.ch/?link=http%3a%2f%2fts2.mm.This/should.png",
"SourceUrl":"http://de.wikipedia.org/wiki/Datei:This should.svg",
"DisplayUrl":"de.wikipedia.org/wiki/Datei:This should.svg",
"Width":1280,
"Height":677,
"FileSize":50053,
"ContentType":"image/png",
"Thumbnail":{"Url":"https://i.swisscows.ch/?link=http%3a%2f%2fts2.mm.This/should.png",
"ContentType":"image/png",
"Width":300,
"Height":158,
"FileSize":8023},
"Id":"ae230fd8-a06a-47d6-99d5-e74766d8143a"}]},
environment: "production"
}).then(function (options) {
$('#Search_Form').on('submit', function (e) {
if (!Modernizr.history) return;
e.preventDefault();
var $form = $(this),
$query = $('#Query'),
query = $.trim($query.val()),
path = App.Router.makePath($form.attr('action'), null, $form.serializeObject())
if (query.length) {
options.html5history ?
ReactRouter.HistoryLocation.push(path) :
ReactRouter.RefreshLocation.push(path);
}
else $('#Query').trigger('blur');
});
});
</script>
"""
response = mock.Mock(text=html)
results = swisscows.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 3)
self.assertEqual(results[0]['title'], 'This should be the title')
self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
self.assertEqual(results[0]['content'], 'This should be the content.')
self.assertEqual(results[1]['title'], 'Datei:This should1.svg')
self.assertEqual(results[1]['url'], 'http://de.wikipedia.org/wiki/Datei:This should1.svg')
self.assertEqual(results[1]['img_src'], 'http://ts2.mm.This/should1.png')
self.assertEqual(results[1]['template'], 'images.html')
self.assertEqual(results[2]['title'], 'Datei:This should.svg')
self.assertEqual(results[2]['url'], 'http://de.wikipedia.org/wiki/Datei:This should.svg')
self.assertEqual(results[2]['img_src'], 'http://ts2.mm.This/should.png')
self.assertEqual(results[2]['template'], 'images.html')
def test_fetch_supported_languages(self):
html = """<html></html>"""
response = mock.Mock(text=html)
languages = swisscows._fetch_supported_languages(response)
self.assertEqual(type(languages), list)
self.assertEqual(len(languages), 0)
html = """
<html>
<div id="regions-popup">
<div>
<ul>
<li><a data-search-language="browser"></a></li>
<li><a data-search-language="de-CH"></a></li>
<li><a data-search-language="fr-CH"></a></li>
</ul>
</div>
</div>
</html>
"""
response = mock.Mock(text=html)
languages = swisscows._fetch_supported_languages(response)
self.assertEqual(type(languages), list)
self.assertEqual(len(languages), 3)
self.assertIn('de-CH', languages)
self.assertIn('fr-CH', languages)