Make the website support regex for both search and path filtering
This commit is contained in:
parent
d3c87d3b6f
commit
65bc8853e6
@ -13,8 +13,8 @@ Access raw data with: <?php echoUrl('channels/'); ?>.<br/>
|
||||
Access found channels with: <?php echoUrl('channels.txt'); ?>.
|
||||
|
||||
<form id="form">
|
||||
<input type="text" autofocus id="search" size="23" placeholder="Your search"></input><br/>
|
||||
<input type="text" autofocus id="path-search" size="23" placeholder="In path containing (default: *empty*)"></input><br/>
|
||||
<input type="text" autofocus id="search" size="23" placeholder="Your search regex"></input><br/>
|
||||
<input type="text" autofocus id="path-search" size="23" placeholder="Your path regex (default: *empty*)"></input><br/>
|
||||
<input type="submit" id="search" value="Search">
|
||||
<input type="submit" id="search-only-captions" value="Search only captions">
|
||||
</form>
|
||||
|
@ -42,14 +42,14 @@ for fileIndex, file in enumerate(files):
|
||||
if searchOnlyCaptions and not endsWithVtt:
|
||||
continue
|
||||
toWrite = f'{file}/{fileInZip}'
|
||||
if not pathSearch in toWrite:
|
||||
if not bool(re.search(pathSearch, toWrite)):
|
||||
continue
|
||||
with zip.open(fileInZip) as f:
|
||||
if endsWithVtt:
|
||||
content = f.read().decode('utf-8')
|
||||
stringIOf = StringIO(content)
|
||||
wholeCaption = ' '.join([cleanCaption(caption.text) for caption in webvtt.read_buffer(stringIOf)])
|
||||
messagePositions = [m.start() for m in re.finditer(f'(?={message})', wholeCaption)]
|
||||
messagePositions = [m.start() for m in re.finditer(message, wholeCaption)]
|
||||
if messagePositions != []:
|
||||
timestamps = []
|
||||
for messagePosition in messagePositions:
|
||||
|
Loading…
Reference in New Issue
Block a user