-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTangView.py
More file actions
40 lines (28 loc) · 903 Bytes
/
TangView.py
File metadata and controls
40 lines (28 loc) · 903 Bytes
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
import time
from selenium import webdriver
videoFileName = "VideoList.txt"
btPlaySelector = "#movie_player > div.ytp-cued-thumbnail-overlay > button"
videoFile = open(videoFileName)
listVideo = videoFile.readlines()
videoIndex = 0
tabIndex = 0
# Open browser
browers = webdriver.Chrome()
# Open url 1st => tabIndex = 0
browers.get(listVideo[videoIndex])
# Click play button
time.sleep(1)
playButton = browers.find_element_by_css_selector(btPlaySelector)
playButton.click()
# Open new tab with 2nd video => tabIndex = 1
time.sleep(0.5)
videoIndex = videoIndex + 1
js = "window.open('"+listVideo[videoIndex].strip()+"')"
browers.execute_script(js)
# Go to previous tab and open new video
time.sleep(2)
tabIndex = 0
handle = browers.window_handles[tabIndex]
browers.switch_to.window(handle)
videoIndex = videoIndex + 1
browers.get(listVideo[videoIndex])