Test suite: supporto a ricerca e test specifico eurostreaming
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
# by Greko
|
# by Greko
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
from core import httptools, support
|
from core import support
|
||||||
from core.item import Item
|
from core.item import Item
|
||||||
|
|
||||||
# def findhost(url):
|
# def findhost(url):
|
||||||
@@ -99,4 +99,10 @@ def newest(categoria):
|
|||||||
|
|
||||||
def findvideos(item):
|
def findvideos(item):
|
||||||
support.info()
|
support.info()
|
||||||
return support.server(item, item.other)
|
itemlist = support.server(item, item.other)
|
||||||
|
# testo che tutti i link siano stati risolti
|
||||||
|
if support.logger.testMode:
|
||||||
|
if len(itemlist) < len(support.match(item.other, patron='<a href="([^"]+)').matches):
|
||||||
|
raise Exception('Manca qualche server')
|
||||||
|
return itemlist
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -592,6 +592,7 @@ def scrape(func):
|
|||||||
nextArgs['item'] = item
|
nextArgs['item'] = item
|
||||||
itemlist = newFunc()
|
itemlist = newFunc()
|
||||||
itemlist = [i for i in itemlist if i.action not in ['add_pelicula_to_library', 'add_serie_to_library']]
|
itemlist = [i for i in itemlist if i.action not in ['add_pelicula_to_library', 'add_serie_to_library']]
|
||||||
|
logger.debug(item.channel + ' scraping time ' + ':', time()-scrapingTime)
|
||||||
|
|
||||||
if anime and inspect.stack()[1][3] not in ['find_episodes']:
|
if anime and inspect.stack()[1][3] not in ['find_episodes']:
|
||||||
from platformcode import autorenumber
|
from platformcode import autorenumber
|
||||||
@@ -650,7 +651,6 @@ def scrape(func):
|
|||||||
if config.get_setting('trakt_sync'):
|
if config.get_setting('trakt_sync'):
|
||||||
from core import trakt_tools
|
from core import trakt_tools
|
||||||
trakt_tools.trakt_check(itemlist)
|
trakt_tools.trakt_check(itemlist)
|
||||||
logger.debug(item.channel + ' scraping time ' + ':', time()-scrapingTime)
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
+28
-15
@@ -74,10 +74,6 @@ chNumRis = {
|
|||||||
'Film': 16,
|
'Film': 16,
|
||||||
'Serie TV': 16,
|
'Serie TV': 16,
|
||||||
},
|
},
|
||||||
'altadefinizionecommunity': {
|
|
||||||
'Film': 22,
|
|
||||||
'Serie TV': 22,
|
|
||||||
},
|
|
||||||
'altadefinizioneclick': {
|
'altadefinizioneclick': {
|
||||||
'Film': 36,
|
'Film': 36,
|
||||||
'Serie TV': 36,
|
'Serie TV': 36,
|
||||||
@@ -163,6 +159,7 @@ for chItem in channel_list:
|
|||||||
error = None
|
error = None
|
||||||
menuItemlist = {}
|
menuItemlist = {}
|
||||||
serversFound = {}
|
serversFound = {}
|
||||||
|
firstContent = None # to check search
|
||||||
logMenu = {}
|
logMenu = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -180,18 +177,25 @@ for chItem in channel_list:
|
|||||||
if it.action == 'channel_config':
|
if it.action == 'channel_config':
|
||||||
hasChannelConfig = True
|
hasChannelConfig = True
|
||||||
continue
|
continue
|
||||||
if it.action == 'search': # channel-specific
|
|
||||||
continue
|
|
||||||
menuItemlist[it.title] = []
|
|
||||||
|
|
||||||
|
if it.action == 'search':
|
||||||
|
# no title to search
|
||||||
|
if not firstContent:
|
||||||
|
continue
|
||||||
|
itemlist = module.search(it, firstContent.fulltitle)
|
||||||
|
else:
|
||||||
itemlist = getattr(module, it.action)(it)
|
itemlist = getattr(module, it.action)(it)
|
||||||
menuItemlist[it.title] = itemlist
|
|
||||||
|
if itemlist and itemlist[0].action in ('findvideos', 'episodios'):
|
||||||
|
firstContent = itemlist[0]
|
||||||
|
|
||||||
# some sites might have no link inside, but if all results are without servers, there's something wrong
|
# some sites might have no link inside, but if all results are without servers, there's something wrong
|
||||||
for resIt in itemlist:
|
for resIt in itemlist:
|
||||||
if resIt.action == 'findvideos':
|
if resIt.action == 'findvideos' or resIt.action == 'episodios':
|
||||||
if hasattr(module, resIt.action):
|
if hasattr(module, resIt.action):
|
||||||
serversFound[it.title] = getattr(module, resIt.action)(resIt)
|
serversFound[it.title] = getattr(module, resIt.action)(resIt)
|
||||||
|
if resIt.action == 'episodios':
|
||||||
|
getattr(module, serversFound[it.title][0].action)(serversFound[it.title][0])
|
||||||
else:
|
else:
|
||||||
serversFound[it.title] = [resIt]
|
serversFound[it.title] = [resIt]
|
||||||
|
|
||||||
@@ -208,9 +212,13 @@ for chItem in channel_list:
|
|||||||
srv.foundOn = ch + ' --> ' + it.title + ' --> ' + resIt.title
|
srv.foundOn = ch + ' --> ' + it.title + ' --> ' + resIt.title
|
||||||
servers.append({'name': srv.server.lower(), 'server': srv})
|
servers.append({'name': srv.server.lower(), 'server': srv})
|
||||||
break
|
break
|
||||||
except:
|
menuItemlist[it.title] = itemlist
|
||||||
|
except Exception as ex:
|
||||||
import traceback
|
import traceback
|
||||||
logger.error(traceback.format_exc())
|
menuItemlist[it.title] = {
|
||||||
|
'traceback': traceback.format_exc(),
|
||||||
|
'exception': ex
|
||||||
|
}
|
||||||
|
|
||||||
logMenu[it.title] = logger.recordedLog
|
logMenu[it.title] = logger.recordedLog
|
||||||
logger.recordedLog = ''
|
logger.recordedLog = ''
|
||||||
@@ -220,9 +228,9 @@ for chItem in channel_list:
|
|||||||
# 'menuItemlist': {k: [it.tojson() if type(it) == Item else it for it in menuItemlist[k]] for k in menuItemlist.keys()},
|
# 'menuItemlist': {k: [it.tojson() if type(it) == Item else it for it in menuItemlist[k]] for k in menuItemlist.keys()},
|
||||||
# 'serversFound': {k: [it.tojson() if type(it) == Item else it for it in menuItemlist[k]] for k in menuItemlist.keys()},
|
# 'serversFound': {k: [it.tojson() if type(it) == Item else it for it in menuItemlist[k]] for k in menuItemlist.keys()},
|
||||||
# 'module': str(module), 'logMenu': logMenu, 'error': error})
|
# 'module': str(module), 'logMenu': logMenu, 'error': error})
|
||||||
channels.append(
|
channels.append({'ch': ch, 'hasChannelConfig': hasChannelConfig, 'mainlist': mainlist,
|
||||||
{'ch': ch, 'hasChannelConfig': hasChannelConfig, 'mainlist': mainlist, 'menuItemlist': menuItemlist,
|
'menuItemlist': menuItemlist, 'serversFound': serversFound, 'module': module,
|
||||||
'serversFound': serversFound, 'module': module, 'logMenu': logMenu, 'error': error})
|
'logMenu': logMenu, 'error': error})
|
||||||
|
|
||||||
logger.record = False
|
logger.record = False
|
||||||
|
|
||||||
@@ -276,6 +284,10 @@ class GenericChannelMenuItemTest(unittest.TestCase):
|
|||||||
print('testing ' + self.ch + ' --> ' + self.title)
|
print('testing ' + self.ch + ' --> ' + self.title)
|
||||||
|
|
||||||
logger.info(self.log)
|
logger.info(self.log)
|
||||||
|
# returned an error
|
||||||
|
if type(self.itemlist) == dict and self.itemlist['exception']:
|
||||||
|
logger.error(self.itemlist['traceback'])
|
||||||
|
raise self.itemlist['exception']
|
||||||
|
|
||||||
self.assertTrue(self.module.host, 'channel ' + self.ch + ' has not a valid hostname')
|
self.assertTrue(self.module.host, 'channel ' + self.ch + ' has not a valid hostname')
|
||||||
self.assertTrue(self.itemlist, 'channel ' + self.ch + ' -> ' + self.title + ' is empty')
|
self.assertTrue(self.itemlist, 'channel ' + self.ch + ' -> ' + self.title + ' is empty')
|
||||||
@@ -286,6 +298,7 @@ class GenericChannelMenuItemTest(unittest.TestCase):
|
|||||||
for content in chNumRis[self.ch]:
|
for content in chNumRis[self.ch]:
|
||||||
if content in self.title:
|
if content in self.title:
|
||||||
risNum = len([i for i in self.itemlist if i.title != typo(config.get_localized_string(30992), 'color kod bold')]) # not count nextpage
|
risNum = len([i for i in self.itemlist if i.title != typo(config.get_localized_string(30992), 'color kod bold')]) # not count nextpage
|
||||||
|
if 'Search' not in self.title:
|
||||||
self.assertEqual(chNumRis[self.ch][content], risNum,
|
self.assertEqual(chNumRis[self.ch][content], risNum,
|
||||||
'channel ' + self.ch + ' -> ' + self.title + ' returned wrong number of results<br>'
|
'channel ' + self.ch + ' -> ' + self.title + ' returned wrong number of results<br>'
|
||||||
+ str(risNum) + ' but should be ' + str(chNumRis[self.ch][content]) + '<br>' +
|
+ str(risNum) + ' but should be ' + str(chNumRis[self.ch][content]) + '<br>' +
|
||||||
@@ -319,7 +332,7 @@ class GenericServerTest(unittest.TestCase):
|
|||||||
def test_get_video_url(self):
|
def test_get_video_url(self):
|
||||||
module = __import__('servers.%s' % self.name, fromlist=["servers.%s" % self.name])
|
module = __import__('servers.%s' % self.name, fromlist=["servers.%s" % self.name])
|
||||||
page_url = self.server.url
|
page_url = self.server.url
|
||||||
httptools.default_headers['Referer'] = self.server.referer
|
# httptools.default_headers['Referer'] = self.server.referer
|
||||||
print('testing ' + page_url)
|
print('testing ' + page_url)
|
||||||
print('Found on ' + self.server.foundOn)
|
print('Found on ' + self.server.foundOn)
|
||||||
print()
|
print()
|
||||||
|
|||||||
Reference in New Issue
Block a user