In order to avoid to open too many matches with Firefox, as it hasn't worked fine with my potentially current low-end computer and connection.
Maybe just showing whether or not a comment has answers or a parent comment may be a first step. Below is the add-on for 2888f5973d.
diff --git a/search_in_youtube_video_comments.py b/search_in_youtube_video_comments.py
index 1d8a8ca..6e11862 100755
--- a/search_in_youtube_video_comments.py
+++ b/search_in_youtube_video_comments.py
@@ -18,9 +18,16 @@ OPEN_IN_FIREFOX = input('Open comment in firefox (yes or no): ') == 'yes'
nextPageToken = ''
commentRegexCompiled = re.compile(COMMENT_REGEX)
-def treatComment(comment):
+all, avoided = 0, 0
+
+def treatComment(comment, hasMore):
+ global all, avoided
textOriginal = comment['snippet']['textOriginal']
if commentRegexCompiled.search(textOriginal):
+ all += 1
+ if not hasMore:
+ avoided += 1
+ return
id = comment['id']
url = f'https://www.youtube.com/watch?v={VIDEO_ID}&lc={id}'
print(f'{url} {textOriginal}')
@@ -38,16 +45,17 @@ while True:
while True:
commentsData = getContentFromURL(f'comments?part=snippet&parentId={parentId}&maxResults=100&pageToken={commentsNextPageToken}')
for item in commentsData['items']:
- treatComment(item)
+ treatComment(item, True)
if not 'nextPageToken' in commentsData:
break
commentsNextPageToken = commentsData['nextPageToken']
else:
- treatComment(snippet['topLevelComment'])
+ treatComment(snippet['topLevelComment'], totalReplyCount > 0)
if totalReplyCount > 0:
for comment in item['replies']['comments']:
- treatComment(comment)
+ treatComment(comment, True)
if not 'nextPageToken' in data:
break
nextPageToken = data['nextPageToken']
+print(all, avoided)
\ No newline at end of file
In order to avoid to open too many matches with Firefox, as it hasn't worked fine with my potentially current *low-end* computer and connection.
Maybe just showing whether or not a comment has answers or a parent comment may be a first step. Below is the add-on for 2888f5973d85e879c6b1fe045b31c3ad385b87e4.
```diff
diff --git a/search_in_youtube_video_comments.py b/search_in_youtube_video_comments.py
index 1d8a8ca..6e11862 100755
--- a/search_in_youtube_video_comments.py
+++ b/search_in_youtube_video_comments.py
@@ -18,9 +18,16 @@ OPEN_IN_FIREFOX = input('Open comment in firefox (yes or no): ') == 'yes'
nextPageToken = ''
commentRegexCompiled = re.compile(COMMENT_REGEX)
-def treatComment(comment):
+all, avoided = 0, 0
+
+def treatComment(comment, hasMore):
+ global all, avoided
textOriginal = comment['snippet']['textOriginal']
if commentRegexCompiled.search(textOriginal):
+ all += 1
+ if not hasMore:
+ avoided += 1
+ return
id = comment['id']
url = f'https://www.youtube.com/watch?v={VIDEO_ID}&lc={id}'
print(f'{url} {textOriginal}')
@@ -38,16 +45,17 @@ while True:
while True:
commentsData = getContentFromURL(f'comments?part=snippet&parentId={parentId}&maxResults=100&pageToken={commentsNextPageToken}')
for item in commentsData['items']:
- treatComment(item)
+ treatComment(item, True)
if not 'nextPageToken' in commentsData:
break
commentsNextPageToken = commentsData['nextPageToken']
else:
- treatComment(snippet['topLevelComment'])
+ treatComment(snippet['topLevelComment'], totalReplyCount > 0)
if totalReplyCount > 0:
for comment in item['replies']['comments']:
- treatComment(comment)
+ treatComment(comment, True)
if not 'nextPageToken' in data:
break
nextPageToken = data['nextPageToken']
+print(all, avoided)
\ No newline at end of file
```
Could maybe avoid to open answers and associated parent, as loading many tabs is quite heavy compared to just doing some clicks to expand the answers (which we know contain matches). However in the worst case of having two matches in hundreds of answers, it's not a good solution, especially when noticing that all answers don't load at once, and so we can't evaluate the regex directly within the web-browser for treating the loaded answers.
Could maybe avoid to open answers and associated parent, as loading many tabs is quite heavy compared to just doing some clicks to expand the answers (which we know contain matches). However in the worst case of having two matches in hundreds of answers, it's not a good solution, especially when noticing that all answers don't load at once, and so we can't evaluate the regex directly within the web-browser for treating the loaded answers.
This repo is archived. You cannot comment on issues.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In order to avoid to open too many matches with Firefox, as it hasn't worked fine with my potentially current low-end computer and connection.
Maybe just showing whether or not a comment has answers or a parent comment may be a first step. Below is the add-on for
2888f5973d.Could maybe avoid to open answers and associated parent, as loading many tabs is quite heavy compared to just doing some clicks to expand the answers (which we know contain matches). However in the worst case of having two matches in hundreds of answers, it's not a good solution, especially when noticing that all answers don't load at once, and so we can't evaluate the regex directly within the web-browser for treating the loaded answers.