#31: Add a first search only captions support
This commit is contained in:
parent
8d20327b67
commit
34c0d03587
@ -13,7 +13,8 @@ Access raw data with: <?php echoUrl('channels/'); ?>.
|
|||||||
|
|
||||||
<form id="form">
|
<form id="form">
|
||||||
<input type="text" autofocus id="search" pattern="[A-Za-z0-9-_ ]+" placeholder="Your [A-Za-z0-9-_ ]+ search"></input>
|
<input type="text" autofocus id="search" pattern="[A-Za-z0-9-_ ]+" placeholder="Your [A-Za-z0-9-_ ]+ search"></input>
|
||||||
<input type="submit" value="Search">
|
<input type="submit" id="search" value="Search">
|
||||||
|
<input type="submit" id="search-only-captions" value="Search only captions">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<ul id="channels">
|
<ul id="channels">
|
||||||
@ -64,7 +65,7 @@ Access raw data with: <?php echoUrl('channels/'); ?>.
|
|||||||
function search(event) {
|
function search(event) {
|
||||||
// We don't want to refresh the webpage which is the default behavior.
|
// We don't want to refresh the webpage which is the default behavior.
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const query = document.getElementById('search').value;
|
const query = event.submitter.id + ' ' + document.getElementById('search').value;
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
conn = new WebSocket('wss://crawler.yt.lemnoslife.com/websocket');
|
conn = new WebSocket('wss://crawler.yt.lemnoslife.com/websocket');
|
||||||
|
@ -7,6 +7,9 @@ path = '/mnt/HDD0/YouTube_captions_search_engine/channels/'
|
|||||||
clientId = sys.argv[1]
|
clientId = sys.argv[1]
|
||||||
message = sys.argv[2]
|
message = sys.argv[2]
|
||||||
|
|
||||||
|
searchOnlyCaptions = message.startswith('search-only-captions ')
|
||||||
|
message = message[message.find(' ') + 1:]
|
||||||
|
|
||||||
clientFilePath = f'users/{clientId}.txt'
|
clientFilePath = f'users/{clientId}.txt'
|
||||||
|
|
||||||
def write(s):
|
def write(s):
|
||||||
@ -31,6 +34,8 @@ for file in os.listdir(path):
|
|||||||
if file.endswith('.zip'):
|
if file.endswith('.zip'):
|
||||||
zip = zipfile.ZipFile(path + file)
|
zip = zipfile.ZipFile(path + file)
|
||||||
for fileInZip in zip.namelist():
|
for fileInZip in zip.namelist():
|
||||||
|
if searchOnlyCaptions and not fileInZip.endswith('.vtt'):
|
||||||
|
continue
|
||||||
f = zip.open(fileInZip)
|
f = zip.open(fileInZip)
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if message in str(line):
|
if message in str(line):
|
||||||
|
Loading…
Reference in New Issue
Block a user