ottimizzazioni
This commit is contained in:
@@ -40,7 +40,10 @@ def printMatches(matches):
|
|||||||
|
|
||||||
def find_single_match(data, patron, index=0):
|
def find_single_match(data, patron, index=0):
|
||||||
try:
|
try:
|
||||||
matches = re.findall(patron, data, flags=re.DOTALL)
|
if index == 0:
|
||||||
|
matches = re.search(patron, data, flags=re.DOTALL)
|
||||||
|
else:
|
||||||
|
matches = re.findall(patron, data, flags=re.DOTALL)
|
||||||
return matches[index]
|
return matches[index]
|
||||||
except:
|
except:
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
+3
-2
@@ -489,8 +489,8 @@ def scrape(func):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
if (pagination and len(matches) <= pag * pagination) or not pagination: # next page with pagination
|
if (pagination and len(matches) <= pag * pagination) or not pagination: # next page with pagination
|
||||||
if patronNext and inspect.stack()[1][3] != 'newest':
|
if patronNext and inspect.stack()[1][3] not in ['newest', 'search']:
|
||||||
nextPage(itemlist, item, data, patronNext, function)
|
nextPage(itemlist, item, data, patronNext, function)
|
||||||
|
|
||||||
# next page for pagination
|
# next page for pagination
|
||||||
@@ -1105,6 +1105,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
|
|||||||
def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page='', resub=[]):
|
def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page='', resub=[]):
|
||||||
# Function_level is useful if the function is called by another function.
|
# Function_level is useful if the function is called by another function.
|
||||||
# If the call is direct, leave it blank
|
# If the call is direct, leave it blank
|
||||||
|
log()
|
||||||
action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level
|
action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level
|
||||||
if next_page == '':
|
if next_page == '':
|
||||||
next_page = scrapertools.find_single_match(data, patron)
|
next_page = scrapertools.find_single_match(data, patron)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class GenericChannelTest(unittest.TestCase):
|
|||||||
self.assertLess(len(resIt.fulltitle), 100, 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong titles\n' + resIt.fulltitle)
|
self.assertLess(len(resIt.fulltitle), 100, 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong titles\n' + resIt.fulltitle)
|
||||||
if resIt.url:
|
if resIt.url:
|
||||||
self.assertIsNotNone(re.match(validUrlRegex, resIt.url), 'channel ' + self.ch + ' -> ' + it.title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url)
|
self.assertIsNotNone(re.match(validUrlRegex, resIt.url), 'channel ' + self.ch + ' -> ' + it.title + ' -> ' + resIt.title + ' might contain wrong url\n' + resIt.url)
|
||||||
if 'year' in resIt.infoLabels:
|
if 'year' in resIt.infoLabels and resIt.infoLabels['year']:
|
||||||
msgYear = 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong infolabels year\n' + str(resIt.infoLabels['year'])
|
msgYear = 'channel ' + self.ch + ' -> ' + it.title + ' might contain wrong infolabels year\n' + str(resIt.infoLabels['year'])
|
||||||
self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(), msgYear)
|
self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(), msgYear)
|
||||||
self.assert_(int(resIt.infoLabels['year']) > 1900 and int(resIt.infoLabels['year']) < 2100, msgYear)
|
self.assert_(int(resIt.infoLabels['year']) > 1900 and int(resIt.infoLabels['year']) < 2100, msgYear)
|
||||||
|
|||||||
Reference in New Issue
Block a user