From e0e72866a23bfb6ad7ede83b12fe5a2c9f8acb3b Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 27 Apr 2023 00:17:38 +0200 Subject: [PATCH] Add parameter to choose whether or not to open the given comment in Firefox --- search_in_youtube_video_comments.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/search_in_youtube_video_comments.py b/search_in_youtube_video_comments.py index 8f12253..d80ab53 100755 --- a/search_in_youtube_video_comments.py +++ b/search_in_youtube_video_comments.py @@ -14,6 +14,7 @@ def getContentFromURL(url): VIDEO_ID = input('Video id: ') API_KEY = input('YouTube Data API v3 (empty if use no-key service): ') COMMENT_REGEX = input('Comment regex: ') +OPEN_IN_FIREFOX = input('Open comment in firefox (yes or no): ') == 'yes' nextPageToken = '' commentRegexCompiled = re.compile(COMMENT_REGEX) @@ -23,8 +24,9 @@ def treatComment(comment): textOriginal = comment['snippet']['textOriginal'] if commentRegexCompiled.search(textOriginal): url = f'https://www.youtube.com/watch?v={VIDEO_ID}&lc={id}' - #os.system(f"firefox -new-tab '{url}'") print(f'{url} {textOriginal}') + if OPEN_IN_FIREFOX: + os.system(f"firefox -new-tab '{url}'") while True: data = getContentFromURL(f'commentThreads?part=snippet,replies&videoId={VIDEO_ID}&maxResults=100&pageToken={nextPageToken}')