-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathnotifications.py
598 lines (558 loc) · 54.7 KB
/
notifications.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
from .download.windows_info import get_drive_letter
class Common:
'''
This class contains messages that are common regardless of whether the package is being run as a module using the -m option from the CLI or as a module from within the Python interpreter (or another Python script).
'''
indent = ' ' * 4 # 4 spaces
ds = ' ' * 2 # 2 spaces ("double spaces")
offset = '\n\n\n'
error = '===>ERROR!<===\n'
not_writing_to_any_files = '\nBased on your provided settings, yt_videos_list will not be writing to a csv file, nor a txt file, nor a md file, nor to memory.'
no_videos_found = 'No videos were found for the channel you provided. Are you sure you entered the url correctly?\n\n'
invalid_response = 'The response you entered was invalid.'
invalid_driver = f'The driver you specified is invalid. Please try rerunning the last command after specifying a valid driver. Supported drivers include:\n{indent}Firefox\n{indent}Opera\n{indent}Safari\n{indent}Chrome\n{indent}Brave\n{indent}Edge'
unsupported_opera_headless = '\nHeadless mode is unsupported in OperaDriver. This will be updated when support is added...\n:)\n\n\n'
unsupported_safari_headless = '\nHeadless mode is unsupported in SafariDriver. This will be updated when support is added...\n:)\n\n\n'
unsupported_brave_headless = '\nHeadless mode is unsupported in BraveDriver. This will be updated when support is added...\n:)\n\n\n'
unsupported_edge_headless = '\nHeadless mode is unsupported in EdgeDriver. This will be updated when support is added...\n:)\n\n\n'
unsupported_edge = 'ERROR! Selenium automation with msedgedriver (Microsoft Edge) is unsupported on your platform. Please use a different browser!'
automated_driver_update = '\n=====> Now updating Selenium driver binaries and fixing any version incompatibility problems. <=====\nThis will update all corresponding Selenium drivers for browsers (which are installed in their default locations and) supported by the yt_videos_list package...'
url_prefix_geckodriver = 'https://github.com/mozilla/geckodriver/releases/download'
url_prefix_operadriver = 'https://github.com/operasoftware/operachromiumdriver/releases/download'
url_prefix_chromedriver = 'https://chromedriver.storage.googleapis.com'
url_prefix_msedgedriver = 'https://msedgedriver.azureedge.net'
chromedriver_source_code_urls = 'https://chromium.googlesource.com/chromium/src/ or\nhttps://source.chromium.org/chromium/chromium/src'
more_driver_info = {
# 'driver': ['driverName', 'url for more driver info', 'url for driver releases', 'browser name', 'url for browser download']
'firefox': ['geckodriver', 'https://github.com/mozilla/geckodriver', 'https://github.com/mozilla/geckodriver/releases', 'Mozilla Firefox', 'https://www.mozilla.org/en-US/firefox/new/'],
'opera': ['operadriver', 'https://github.com/operasoftware/operachromiumdriver', 'https://github.com/operasoftware/operachromiumdriver/releases', 'Opera Browser', 'https://www.opera.com/'],
'chrome': ['chromedriver', chromedriver_source_code_urls, 'https://sites.google.com/chromium.org/driver/downloads', 'Google Chrome', 'https://www.google.com/chrome/'],
'brave': ['bravedriver', 'https://github.com/operasoftware/operachromiumdriver', 'https://github.com/operasoftware/operachromiumdriver/releases', 'Brave Browser', 'https://brave.com/'],
'edge': ['msedgedriver', 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/', 'https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver?comp=list&timeout=60000', 'Microsoft Edge', 'https://www.microsoft.com/en-us/edge']
}
url_error = 'The url you provided could not be parsed properly. Please check the url you provided to make sure there are no typos!'
selenium_launch_error = 'The program was unable to launch a Selenium driver instance! Please follow the suggestions above the stack trace to fix the issue.'
possible_topic_channel_in_headless_error = 'There was a problem running the selenium webdriver!\n\nTo better debug the problem, try running the program again with headless=False if you are currently running the program with headless=True to see what is happening.'
selenium_unable_to_load_elements_error = 'The page did not load elements! If you\'ve scraped many channels within a short period of time, please try rerunning the program after waiting to make sure YouTube isn\'t throttling your IP address!'
def __init__(self, list_creator_configuration=None):
self.list_creator_configuration = list_creator_configuration
self.driver_downloads_for_os = {
'firefox': {
'macos': self.create_list_for('macos', 'geckodriver'),
'linux': self.create_list_for('linux64', 'geckodriver') + self.create_list_for('linux32', 'geckodriver'),
'windows': self.create_list_for('win32', 'geckodriver') + self.create_list_for('win64', 'geckodriver')
},
'opera': {
'macos': self.create_list_for('mac64', 'operadriver'),
'linux': self.create_list_for('linux64', 'operadriver'),
'windows': self.create_list_for('win32', 'operadriver') + self.create_list_for('win64', 'operadriver')
},
'safari': {
'macos': self.create_list_for('macos', 'safaridriver'),
'linux': self.create_list_for('linux', 'safaridriver'),
'windows': self.create_list_for('windows', 'safaridriver')
},
'chrome': {
'macos': self.create_list_for('mac64', 'chromedriver'),
'linux': self.create_list_for('linux64', 'chromedriver'),
'windows': self.create_list_for('win32', 'chromedriver')
},
'brave': {
'macos': self.create_list_for('mac64', 'bravedriver'),
'linux': self.create_list_for('linux64', 'bravedriver'),
'windows': self.create_list_for('win64', 'bravedriver')
},
'edge': {
'macos': self.create_list_for('mac64', 'msedgedriver'),
'linux': ['There is currently no dedicated msedgedriver for Linux.\nHere are possible commands for an arm64 operating system.\nPlease visit https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ for more information.'] + \
self.create_list_for('arm64', 'msedgedriver'),
'windows': self.create_list_for('win32', 'msedgedriver') + self.create_list_for('win64', 'msedgedriver')
}
}
@classmethod
def create_list_for(cls, operating_system, driver):
formatter_function = getattr(cls, f'format_{driver}_list')
return formatter_function(operating_system)
@classmethod
def format_geckodriver_list(cls, operating_system):
driver_name = 'geckodriver'
browser_name = 'Mozilla Firefox'
return [
cls.format_driver_information (operating_system, 'v0.32.0', '≥ 104', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.32.0'),
cls.format_driver_information (operating_system, 'v0.31.0', '≥ 99', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.31.0'),
cls.format_driver_information (operating_system, 'v0.30.0', '≥ 92', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.30.0'),
cls.format_driver_information (operating_system, 'v0.29.1', '≥ 87', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.29.1'),
cls.format_driver_information (operating_system, 'v0.29.0', '≥ 84', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.29.0'),
cls.format_driver_information (operating_system, 'v0.28.0', '≥ 82', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.28.0'),
cls.format_driver_information (operating_system, 'v0.27.0', '≥ 78', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.27.0'),
cls.format_driver_information (operating_system, 'v0.26.0', '≥ 60', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v0.26.0')
]
@classmethod
def format_operadriver_list(cls, operating_system):
driver_name = 'operadriver'
browser_name = 'Opera Browser'
return [
cls.format_driver_information (operating_system, 'v.107.0.5304.88', 'Stable 93', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.107.0.5304.88'),
cls.format_driver_information (operating_system, 'v.106.0.5249.119', 'Stable 92', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.106.0.5249.119'),
cls.format_driver_information (operating_system, 'v.105.0.5195.102', 'Stable 91', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.105.0.5195.102'),
cls.format_driver_information (operating_system, 'v.104.0.5112.81', 'Stable 90', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.104.0.5112.81'),
cls.format_driver_information (operating_system, 'v.103.0.5060.66', 'Stable 89', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.103.0.5060.66'),
cls.format_driver_information (operating_system, 'v.102.0.5005.61', 'Stable 88', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.102.0.5005.61'),
# there was no operdriver v.101.#.####.##
# there was no operdriver v.100.#.####.##
cls.format_driver_information (operating_system, 'v.99.0.4844.51', 'Stable 85', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.99.0.4844.51'),
cls.format_driver_information (operating_system, 'v.98.0.4758.82', 'Stable 84', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.98.0.4758.82'),
cls.format_driver_information (operating_system, 'v.97.0.4692.71', 'Stable 83', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.97.0.4692.71'),
cls.format_driver_information (operating_system, 'v.96.0.4664.45', 'Stable 82', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.96.0.4664.45'),
cls.format_driver_information (operating_system, 'v.95.0.4638.54', 'Stable 81', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.95.0.4638.54'),
cls.format_driver_information (operating_system, 'v.94.0.4606.61', 'Stable 80', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.94.0.4606.61'),
cls.format_driver_information (operating_system, 'v.93.0.4577.63', 'Stable 79', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.93.0.4577.63'),
cls.format_driver_information (operating_system, 'v.92.0.4515.107', 'Stable 78', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.92.0.4515.107'),
cls.format_driver_information (operating_system, 'v.91.0.4472.77', 'Stable 77', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.91.0.4472.77'),
cls.format_driver_information (operating_system, 'v.90.0.4430.85', 'Stable 76', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.90.0.4430.85'),
cls.format_driver_information (operating_system, 'v.89.0.4389.82', 'Stable 75', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.89.0.4389.82'),
cls.format_driver_information (operating_system, 'v.88.0.4324.104', 'Stable 74', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.88.0.4324.104'),
cls.format_driver_information (operating_system, 'v.87.0.4280.67', 'Stable 73', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.87.0.4280.67'),
cls.format_driver_information (operating_system, 'v.86.0.4240.80', 'Stable 72', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.86.0.4240.80'),
cls.format_driver_information (operating_system, 'v.85.0.4183.102', 'Stable 71', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.85.0.4183.102'),
cls.format_driver_information (operating_system, 'v.84.0.4147.89', 'Stable 70', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.84.0.4147.89'),
cls.format_driver_information (operating_system, 'v.83.0.4103.97', 'Stable 69', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.83.0.4103.97'),
# there was no operdriver v.82.#.####.##
cls.format_driver_information (operating_system, 'v.81.0.4044.113', 'Stable 68', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.81.0.4044.113'),
cls.format_driver_information (operating_system, 'v.80.0.3987.100', 'Stable 67', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.80.0.3987.100'),
cls.format_driver_information (operating_system, 'v.79.0.3945.79', 'Stable 66', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.79.0.3945.79'),
cls.format_driver_information (operating_system, 'v.78.0.3904.87', 'Stable 65', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.78.0.3904.87'),
cls.format_driver_information (operating_system, 'v.77.0.3865.120', '64', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.77.0.3865.120'),
cls.format_driver_information (operating_system, 'v.76.0.3809.132', '63', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.76.0.3809.132'),
cls.format_driver_information (operating_system, 'v.75.0.3770.100', '62', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.75.0.3770.100'),
cls.format_driver_information (operating_system, 'v.2.45', '60', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.45'),
cls.format_driver_information (operating_system, 'v.2.42', '58', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.42'),
cls.format_driver_information (operating_system, 'v.2.41', '57', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.41'),
cls.format_driver_information (operating_system, 'v.2.40', '56', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.40'),
cls.format_driver_information (operating_system, 'v.2.38', '55', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.38'),
cls.format_driver_information (operating_system, 'v.2.37', '54', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.37'),
cls.format_driver_information (operating_system, 'v.2.36', '53', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.36'),
cls.format_driver_information (operating_system, 'v.2.35', '52', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.35'),
# there was no operdriver release specifically for Opera 51
# there was no operadriver v.2.34
cls.format_driver_information (operating_system, 'v.2.33', '50', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.33'),
cls.format_driver_information (operating_system, 'v.2.32', '49', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.32'),
# there was no operadriver v.2.31
cls.format_driver_information (operating_system, 'v.2.30', '48', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.30'),
# there was no operdriver release specifically for Opera 47
cls.format_driver_information (operating_system, 'v.2.29', '46', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.2.29'),
]
@classmethod
def format_chromedriver_list(cls, operating_system):
driver_name = 'chromedriver'
browser_name = 'Google Chrome'
return [
cls.format_driver_information (operating_system, '108.0.5359.22', '108', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '108.0.5359.22'),
cls.format_driver_information (operating_system, '107.0.5304.62', '107', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '107.0.5304.62'),
cls.format_driver_information (operating_system, '106.0.5249.61', '106', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '106.0.5249.61'),
cls.format_driver_information (operating_system, '105.0.5195.52', '105', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '105.0.5195.52'),
cls.format_driver_information (operating_system, '104.0.5112.79', '104', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '104.0.5112.79'),
cls.format_driver_information (operating_system, '103.0.5060.134', '103', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '103.0.5060.134'),
cls.format_driver_information (operating_system, '102.0.5005.61', '102', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '102.0.5005.61'),
cls.format_driver_information (operating_system, '101.0.4951.41', '101', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '101.0.4951.41'),
cls.format_driver_information (operating_system, '100.0.4896.60', '100', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '100.0.4896.60'),
cls.format_driver_information (operating_system, '99.0.4844.51', '99', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '99.0.4844.51'),
cls.format_driver_information (operating_system, '98.0.4758.102', '98', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '98.0.4758.102'),
cls.format_driver_information (operating_system, '97.0.4692.71', '97', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '97.0.4692.71'),
cls.format_driver_information (operating_system, '96.0.4664.45', '96', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '96.0.4664.45'),
cls.format_driver_information (operating_system, '95.0.4638.69', '95', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '95.0.4638.69'),
cls.format_driver_information (operating_system, '94.0.4606.113', '94', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '94.0.4606.113'),
cls.format_driver_information (operating_system, '93.0.4577.63', '93', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '93.0.4577.63'),
cls.format_driver_information (operating_system, '92.0.4515.107', '92', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '92.0.4515.107'),
cls.format_driver_information (operating_system, '91.0.4472.101', '91', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '91.0.4472.101'),
cls.format_driver_information (operating_system, '90.0.4430.24', '90', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '90.0.4430.24'),
cls.format_driver_information (operating_system, '89.0.4389.23', '89', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '89.0.4389.23'),
cls.format_driver_information (operating_system, '88.0.4324.96', '88', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '88.0.4324.96'),
cls.format_driver_information (operating_system, '87.0.4280.88', '87', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '87.0.4280.88'),
cls.format_driver_information (operating_system, '86.0.4240.22', '86', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '86.0.4240.22'),
cls.format_driver_information (operating_system, '85.0.4183.87', '85', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '85.0.4183.87'),
cls.format_driver_information (operating_system, '84.0.4147.30', '84', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '84.0.4147.30'),
cls.format_driver_information (operating_system, '83.0.4103.39', '83', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '83.0.4103.39'),
# there was no Google Chrome release for version 82
# there was no chromedriver v.82.#.####.##
cls.format_driver_information (operating_system, '81.0.4044.138', '81', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '81.0.4044.138'),
cls.format_driver_information (operating_system, '80.0.3987.106', '80', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '80.0.3987.106'),
cls.format_driver_information (operating_system, '79.0.3945.36', '79', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '79.0.3945.36'),
cls.format_driver_information (operating_system, '78.0.3904.105', '78', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '78.0.3904.105'),
cls.format_driver_information (operating_system, '77.0.3865.40', '77', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '77.0.3865.40'),
cls.format_driver_information (operating_system, '76.0.3809.126', '76', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '76.0.3809.126'),
cls.format_driver_information (operating_system, '75.0.3770.140', '75', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '75.0.3770.140'),
cls.format_driver_information (operating_system, '74.0.3729.6', '74', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '74.0.3729.6'),
cls.format_driver_information (operating_system, '73.0.3683.68', '73', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '73.0.3683.68'),
cls.format_driver_information (operating_system, '2.46', 'v71-73', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.46'),
cls.format_driver_information (operating_system, '2.45', 'v70-72', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.45'),
cls.format_driver_information (operating_system, '2.44', 'v69-71', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.44'),
cls.format_driver_information (operating_system, '2.43', 'v69-71 (use chromedriver 2.44)', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.43'),
cls.format_driver_information (operating_system, '2.42', 'v68-70', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.42'),
cls.format_driver_information (operating_system, '2.41', 'v67-69', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '2.41'),
]
@classmethod
def format_bravedriver_list(cls, operating_system):
driver_name = 'bravedriver (operadriver based)'
browser_name = 'Brave Browser'
return [
cls.format_driver_information (operating_system, 'v.107.0.5304.88', '107', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.107.0.5304.88'),
cls.format_driver_information (operating_system, 'v.106.0.5249.119', '106', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.106.0.5249.119'),
cls.format_driver_information (operating_system, 'v.105.0.5195.102', '105', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.105.0.5195.102'),
cls.format_driver_information (operating_system, 'v.104.0.5112.81', '104', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.104.0.5112.81'),
cls.format_driver_information (operating_system, 'v.103.0.5060.66', '103', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.103.0.5060.66'),
cls.format_driver_information (operating_system, 'v.102.0.5005.61', '102', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.102.0.5005.61'),
# there was no operdriver v.101.#.####.## - therefore no bravedriver v.101.#.####.## since bravedriver just uses the operadriver binary renamed as ** bravedriver **
# there was a Brave Browser release for version 101, BUT there was no corresponding operadriver
# there was no operdriver v.100.#.####.## - therefore no bravedriver v.100.#.####.## since bravedriver just uses the operadriver binary renamed as ** bravedriver **
# there was a Brave Browser release for version 100, BUT there was no corresponding operadriver
cls.format_driver_information (operating_system, 'v.99.0.4844.51', '99', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.99.0.4844.51'),
cls.format_driver_information (operating_system, 'v.98.0.4758.82', '98', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.98.0.4758.82'),
cls.format_driver_information (operating_system, 'v.97.0.4692.71', '97', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.97.0.4692.71'),
cls.format_driver_information (operating_system, 'v.96.0.4664.45', '96', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.96.0.4664.45'),
cls.format_driver_information (operating_system, 'v.95.0.4638.54', '95', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.95.0.4638.54'),
cls.format_driver_information (operating_system, 'v.94.0.4606.61', '94', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.94.0.4606.61'),
cls.format_driver_information (operating_system, 'v.93.0.4577.63', '93', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.93.0.4577.63'),
cls.format_driver_information (operating_system, 'v.92.0.4515.107', '92', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.92.0.4515.107'),
cls.format_driver_information (operating_system, 'v.91.0.4472.77', '91', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.91.0.4472.77'),
cls.format_driver_information (operating_system, 'v.90.0.4430.85', '90', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.90.0.4430.85'),
cls.format_driver_information (operating_system, 'v.89.0.4389.82', '89', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.89.0.4389.82'),
cls.format_driver_information (operating_system, 'v.88.0.4324.104', '88', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.88.0.4324.104'),
cls.format_driver_information (operating_system, 'v.87.0.4280.67', '87', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.87.0.4280.67'),
cls.format_driver_information (operating_system, 'v.86.0.4240.80', '86', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.86.0.4240.80'),
cls.format_driver_information (operating_system, 'v.85.0.4183.102', '85', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.85.0.4183.102'),
cls.format_driver_information (operating_system, 'v.84.0.4147.89', '84', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.84.0.4147.89'),
cls.format_driver_information (operating_system, 'v.83.0.4103.97', '83', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.83.0.4103.97'),
# there was no Brave Browser release for version 82
# there was no operdriver v.82.#.####.## - therefore no bravedriver v.82.#.####.## since bravedriver just uses the operadriver binary renamed as ** bravedriver **
cls.format_driver_information (operating_system, 'v.81.0.4044.113', '81', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.81.0.4044.113'),
cls.format_driver_information (operating_system, 'v.80.0.3987.100', '80', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.80.0.3987.100'),
cls.format_driver_information (operating_system, 'v.79.0.3945.79', '79', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.79.0.3945.79'),
cls.format_driver_information (operating_system, 'v.78.0.3904.87', '78', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.78.0.3904.87'),
cls.format_driver_information (operating_system, 'v.77.0.3865.120', '77', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.77.0.3865.120'),
cls.format_driver_information (operating_system, 'v.76.0.3809.132', '76', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.76.0.3809.132'),
cls.format_driver_information (operating_system, 'v.75.0.3770.100', '75', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, 'v.75.0.3770.100')
]
@classmethod
def format_msedgedriver_list(cls, operating_system):
driver_name = 'msedgedriver'
browser_name = 'Microsoft Edge'
return [
cls.format_driver_information (operating_system, '109.0.1481.0', '109', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '109.0.1481.0'),
cls.format_driver_information (operating_system, '108.0.1462.15', '108', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '108.0.1462.15'),
cls.format_driver_information (operating_system, '107.0.1418.42', '107', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '107.0.1418.42'),
cls.format_driver_information (operating_system, '106.0.1370.52', '106', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '106.0.1370.52'),
cls.format_driver_information (operating_system, '105.0.1343.53', '105', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '105.0.1343.53'),
cls.format_driver_information (operating_system, '104.0.1293.91', '104', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '104.0.1293.91'),
cls.format_driver_information (operating_system, '103.0.1264.77', '103', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '103.0.1264.77'),
cls.format_driver_information (operating_system, '102.0.1245.62', '102', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '102.0.1245.62'),
cls.format_driver_information (operating_system, '101.0.1210.53', '101', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '101.0.1210.53'),
cls.format_driver_information (operating_system, '100.0.1185.60', '100', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '100.0.1185.60'),
# there was no msedgedriver 99.#.####.##
cls.format_driver_information (operating_system, '98.0.1085.0', '98', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '98.0.1085.0'),
cls.format_driver_information (operating_system, '97.0.1072.76', '97', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '97.0.1072.76'),
cls.format_driver_information (operating_system, '96.0.1054.75', '96', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '96.0.1054.75'),
cls.format_driver_information (operating_system, '95.0.1020.53', '95', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '95.0.1020.53'),
cls.format_driver_information (operating_system, '94.0.992.58', '94', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '94.0.992.58'),
cls.format_driver_information (operating_system, '93.0.961.52', '93', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '93.0.961.52'),
cls.format_driver_information (operating_system, '92.0.902.84', '92', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '92.0.902.84'),
cls.format_driver_information (operating_system, '91.0.864.71', '91', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '91.0.864.71'),
cls.format_driver_information (operating_system, '90.0.818.66', '90', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '90.0.818.66'),
cls.format_driver_information (operating_system, '89.0.774.77', '89', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '89.0.774.77'),
cls.format_driver_information (operating_system, '88.0.705.74', '88', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '88.0.705.74'),
cls.format_driver_information (operating_system, '87.0.669.0', '87', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '87.0.669.0'),
cls.format_driver_information (operating_system, '86.0.622.58', '86', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '86.0.622.58'),
cls.format_driver_information (operating_system, '85.0.564.68', '85', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '85.0.564.68'),
cls.format_driver_information (operating_system, '84.0.524.0', '84', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '84.0.524.0'),
cls.format_driver_information (operating_system, '83.0.478.58', '83', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '83.0.478.58'),
cls.format_driver_information (operating_system, '82.0.459.1', '82', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '82.0.459.1'),
cls.format_driver_information (operating_system, '81.0.409.0', '81', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '81.0.409.0'),
cls.format_driver_information (operating_system, '80.0.361.111', '80', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '80.0.361.111'),
cls.format_driver_information (operating_system, '79.0.313.0', '79', driver_name, browser_name),
cls.format_download_command(driver_name, operating_system, '79.0.313.0')
]
@staticmethod
def format_safaridriver_list(operating_system):
return {
'macos': [
'In order to run safaridriver, you need to enable remote automation. To do so, open up the Safari browser and in the menu bar, go to\n"Safari" -> "Preferences" -> "Advanced" tab -> click "Show develop menu in menu bar"\nOnce you do that, "Develop" should appear in your menu bar. Click on the "Develop" bar, and then enable "Allow Remote Automation" (should be near the bottom of the list).\n\nAfter doing that, try rerunning the last command!\n :)'
],
'linux': [
'Safari is probably not supported on Linux operating systems. In order for the safaridriver to run on a Linux OS, you will likely need to do many manual configurations. For this reason, this package does not provide built in support for safaridriver on a Linux OS.'
],
'windows': [
'Safari is probably not supported on Windows operating systems. In order for the safaridriver to run on a Windows OS, you will likely need to do many manual configurations. For this reason, this package does not provide built in support for safaridriver on a Windows OS.'
]
}.get(operating_system)
@staticmethod
def format_driver_information(operating_system, version, major_version, driver, browser):
return f'# {operating_system} {driver} {version} (supports {browser} version: {major_version})'
@classmethod
def format_download_command(cls, driver, operating_system, version):
### NOTE that Brave Browser doesn't have its own bravedriver, but since it's chromium we can just download operadriver (a chromium based driver) and use the corresponding operadriver for the Brave version (with it renamed to "bravedriver" in order to avoud conflict with different versions of Chrome/Opera and Brave installed at the same time) ###
if operating_system.startswith('win'):
if driver.startswith('geckodriver'): return cls.format_windows_download(f'{cls.url_prefix_geckodriver}/{version}/geckodriver-{version}-{operating_system}.zip', 'geckodriver')
elif driver.startswith('bravedriver'): return cls.format_windows_download(f'{cls.url_prefix_operadriver}/{version}/operadriver_{operating_system}.zip', 'bravedriver')
elif driver.startswith('msedgedriver'): return cls.format_windows_download(f'{cls.url_prefix_msedgedriver}/{version}/edgedriver_{operating_system}.zip', 'msedgedriver')
else: return cls.format_windows_download(f'''{getattr(cls, 'url_prefix_' + driver)}/{version}/{driver}_{operating_system}.zip''', driver)
else:
if driver.startswith('geckodriver'): return cls.format_unix_download (f'{cls.url_prefix_geckodriver}/{version}/geckodriver-{version}-{operating_system}.tar.gz', 'geckodriver')
elif driver.startswith('bravedriver'): return cls.format_unix_download (f'{cls.url_prefix_operadriver}/{version}/operadriver_{operating_system}.zip', 'bravedriver')
elif driver.startswith('msedgedriver'): return cls.format_unix_download (f'{cls.url_prefix_msedgedriver}/{version}/edgedriver_{operating_system}.zip', 'msedgedriver')
else: return cls.format_unix_download (f'''{getattr(cls, 'url_prefix_' + driver)}/{version}/{driver}_{operating_system}.zip''', driver)
strip_component = '--strip-components=1'
@classmethod
def format_unix_download(cls, url, driver):
if driver == 'operadriver': driver_specific_command = f'-C /usr/local/bin/ {cls.strip_component} && rm /usr/local/bin/sha512_sum'
elif driver == 'bravedriver': driver_specific_command = f'-O > /usr/local/bin/{driver} {cls.strip_component}'
else: driver_specific_command = '-C /usr/local/bin/'
return f'curl -SL {url} | tar -xzvf - {driver_specific_command} && chmod +x /usr/local/bin/{driver}' + '\n'
@classmethod
def format_windows_download(cls, url, driver):
drive = get_drive_letter()
if driver == 'operadriver': driver_specific_command = rf'-C {drive}:\Windows {cls.strip_component} && del {drive}:\Windows\sha512_sum'
elif driver == 'bravedriver': driver_specific_command = rf'-O > {drive}:\Windows\bravedriver.exe {cls.strip_component}'
else: driver_specific_command = rf'-C {drive}:\Windows'
return rf'curl -SL --ssl-no-revoke {url} -o {drive}:\Windows\{driver} && tar -xzvf {drive}:\Windows\{driver} {driver_specific_command} && del {drive}:\Windows\{driver}' + '\n'
def display_current_configuration(self):
return f'\n\nFor reference, here is your current configuration:\n\n{self.list_creator_configuration}\n'
@staticmethod
def display_unsupported_os(user_os):
return f'\n\nThe system you are using has not yet been tested and verified for full program support.\nCurrently tested, verified, and supported systems include macOS (Darwin Kernel), Windows, and Linux.\nYou can still use this program on your current system, but be aware the program may not behave as expected due to potential OS differences.\nYour current system has been detected as:\n{user_os}\n\n'
@staticmethod
def display_browser_found_information(browser, full_version_number):
print(f'\nFound an installed version of {browser}.\nYou are currently running {browser} version: {full_version_number}')
@staticmethod
def display_browser_not_found_information(browser, user_os):
print(f'\nDid not find an installed version of {browser}.\nIf you DO have {browser} installed but it was not detected, it may be because your {browser} was installed in a non-default location.\n')
def display_dependency_setup_instructions(self, user_driver, user_os):
terminal_copy_paste_directions = 'Once you determine the right version to download, copy the command, open a new terminal session (usually possible with CMD+N or CMD+T (or CTRL+N or CTRL+D depending on your keyboard/OS) from an active terminal session), and paste the command you just copied. Once you\'ve done that, you should be able to come back to this session and rerun the last command without an error!\n\n'
if user_os != 'windows' and user_driver != 'safari':
print(terminal_copy_paste_directions)
geckodriver_download_instructions = '(The given command downloads a geckodriver ("Firefoxdriver") version that is compatible with Firefox versions ≥ 60. To see more information about the differences compared to older versions, please visit https://github.com/mozilla/geckodriver/releases)'
operadriver_download_instructions = '(Your Opera browser version should match the "supports Opera ## release" below)'
chromedriver_download_instructions = '(Your Chrome browser version should match the first numbers before the decimal place of the chromedriver version below)'
bravedriver_download_instructions = '(Your Brave browser version should match the first numbers before the decimal place of the bravedriver version below. Note that there is currently no dedicated bravedriver, so this package substitutes the chromium operadriver.)'
edgedriver_download_instructions = '(Your Edge browser version should match the first numbers before the decimal place of the msedgedriver version below)'
if user_driver == 'firefox': print(geckodriver_download_instructions)
elif user_driver == 'opera': print(operadriver_download_instructions)
elif user_driver == 'safari': print('This is an MacOS specific driver.')
elif user_driver == 'chrome': print(chromedriver_download_instructions)
elif user_driver == 'brave': print(bravedriver_download_instructions)
elif user_driver == 'edge': print(edgedriver_download_instructions)
for driver_version_download in self.driver_downloads_for_os[user_driver][user_os]:
print(driver_version_download)
def display_more_dependency_information(user_driver):
driver_name, driver_source_code_url, driver_releases_page_url, browser_name, browser_url = self.more_driver_info[user_driver]
print(f'\n\n# For more information about the {driver_name}, please visit\n{driver_source_code_url}\n{driver_releases_page_url}{self.indent}{self.ds}(all supported versions)\n\nNOTE! You must also have the {browser_name} browser installed to use this. If you don\'t have it installed, install it from\n{browser_url}')
print('=' * 130)
print('\n' * 7)
if user_driver != 'safari':
display_more_dependency_information(user_driver)
@classmethod
def display_selenium_dependency_error(cls, error_message):
print(f'{cls.offset}{cls.offset}\n{cls.error}There was an error while trying to open up the remote selenium instance. The exact error was:\n{error_message}\nDon\'t worry though, this is an easy fix!')
@staticmethod
def tell_user_to_download_driver(user_driver):
print('\n' * 3 + '=' * 130)
print(f'It looks like you don\'t have the correct Selenium dependency set up to run this program using the remote {user_driver}driver.\nThe version of your {user_driver.title()} browser - usually found by going to {user_driver.title()} -> \"About browser\" in the menu bar within a {user_driver.title()} window - should match the comment for the corresponding command.\nPlease download it using the relevant command from the list of commands below.\n')
@classmethod
def display_unable_to_update_driver_automatically(cls, user_driver):
print('\n' + '*' * 81)
print('*****The package could not automatically update the dependencies.*****')
print('Please try running the following commands to update the package (newer package versions will support newer drivers) before retrying, and if that doesn\'t work, follow the directions given above.')
print(f'pip{cls.ds}install -U yt-videos-list #Windows\npip3 install -U yt-videos-list #MacOS/Linux\n\n')
print('If that doesn\'t work, try:')
print(f'python{cls.ds}-m pip install -U yt-videos-list #Windows\npython3 -m pip install -U yt-videos-list #MacOS/Linux\n')
print('If this still doesn\'t fix the problem, try using a different driver or file an issue!')
print(f'The problem is likely caused by trying to run yt_videos_list with a more updated version of the driver than what yt_videos_list currently supports (we update the binaries a few weeks after the initial release to allow time for bug fixing). If this is the case, the version of the driver downloaded won\'t match the output of\n"You are currently running {user_driver} version: " above.\n')
print('To see other drivers you can use (and other options), run:\n')
print('import yt_videos_list\nhelp(yt_videos_list)')
print('*' * 81)
@classmethod
def display_cookie_redirection(cls):
print(f'{cls.offset}Redirected to consent.youtube.com!')
@classmethod
def display_blocking_cookie_consent(cls):
print(f'Blocking consent for all cookies since program running with cookie_consent=False ...{cls.offset}')
@classmethod
def display_accepting_cookie_consent(cls):
print(f'Accepting consent for all cookies since program running with cookie_consent=True ...{cls.offset}')
@staticmethod
def display_invalid_cookie_consent_option(cookie_consent):
print(f'YouTube redircted to youtube.consent.com, but you entered an invalid argument for the cookie_consent instance attrribute!\nPlease use cookie_consent=True or cookie_consent=False.\nYour current setting is: cookie_consent={cookie_consent}')
@staticmethod
def no_new_videos_found(pause_time):
return f'No new videos found since the last scroll. Waiting another {pause_time} seconds to see if more videos can be loaded....\n'
class ModuleMessage(Common):
'''
This class contains messages that are relevant for the package when it is being run as a module from within the Python interpreter (or another Python script).
'''
indent = ' ' * 4 # 4 spaces
not_writing_to_any_files_hint = f'{Common.not_writing_to_any_files}\nIf you want to run this program, please change (at least) one of the csv OR txt OR md OR all_video_data_in_memory attributes to True.'
running_default_driver = '\nNo driver specified during ListCreator instantiation, so running program using the Firefox driver.'
show_driver_options = f'''To use a different driver, specify the driver in the driver argument during the ListCreator instantiation. For example:
{indent}lc = ListCreator(driver='firefox')
{indent}lc = ListCreator(driver='opera')
{indent}lc = ListCreator(driver='safari')
{indent}lc = ListCreator(driver='chrome')
{indent}lc = ListCreator(driver='brave')
{indent}lc = ListCreator(driver='edge')'''
class ScriptMessage(Common):
'''
This class contains messages that relevant for the package it is being run as a module using the -m option from the CLI.
'''
not_writing_to_any_files_hint = f'{Common.not_writing_to_any_files}\nIf you want to run this program, please change (at least) one of the csv OR txt OR md OR all_video_data_in_memory attributes to True.'
running_default_driver = '\nNo driver flag used, so running program using the Firefox driver.'
input_message = "What is the name of the YouTube channel you want to generate the list for?\n\nIf you're unsure, click on the channel and look at the URL.\nIt should be in the format:\nhttps://www.youtube.com/user/YourChannelName\nOR\nhttps://www.youtube.com/channel/YourChannelName\n\nSubstitute what you see for YourChannelName and type it in below:\n"
show_driver_options = 'To use a different driver, specify the driver in the driver flag. For example:'