Add parameter to choose whether or not to open the given comment in Firefox

This commit is contained in:
Benjamin Loison 2023-04-27 00:17:38 +02:00
parent 5288cf9280
commit e0e72866a2
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -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}')