-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvideo_to_text.py
79 lines (67 loc) · 2.49 KB
/
video_to_text.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
import os
import time
import requests
import tkinter as tk
from selenium import webdriver
from sys import platform
import urllib.request
from xml.etree import ElementTree
from selenium.webdriver.support.wait import WebDriverWait
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
#BASE_DIR = os.path.dirname("/home/aayushshivam7/")
DRIVER_NAME = "chromedriver.exe" if platform == "win32" else "chromedriver"
DRIVER_DIR = os.path.join(BASE_DIR, "static/plugins", DRIVER_NAME)
converter = "https://www.360converter.com/conversion/video2TextConversion?type=v2t"
duration = '00:00:30'
def wait_for_page_load(driver, timeout=30):
old_page = driver.find_element_by_tag_name('html')
yield
WebDriverWait(driver, timeout).until(
staleness_of(old_page)
)
def convert_to_text(filePath, keyword):
filePath = "/home/priyanshu/Desktop/GTube/static/images/videoplayback.mp4"
driver = webdriver.Chrome(DRIVER_DIR)
driver.get(converter)
radio = driver.find_element_by_id('srcLocal')
radio.click()
chooser = driver.find_element_by_id('myfile')
chooser.send_keys(filePath) ;
option = driver.find_element_by_xpath("//select[@name='language']/option[@value='en-US']").click()
timer = driver.find_element_by_id('to')
timer.clear()
timer.send_keys(duration)
agree = driver.find_element_by_id('agreementCheck')
agree.click()
print(driver.current_url)
submit = driver.find_element_by_id('StartConvert')
submit.click()
element = WebDriverWait(driver, 60).until(
lambda x: x.find_element_by_id("finished"))
new_driver = driver.window_handles[0]
print(driver.current_url)
driver.switch_to_window(new_driver)
button = driver.find_element_by_id('downloadlink_txt')
while not button.is_displayed() :
a = 10
time.sleep(1)
total = driver.find_element_by_xpath('//*[@id="conversion"]/div[2]/div[4]/button[1]')
total.click()
root = tk.Tk()
result = root.clipboard_get()
print(result)
some_list = result.splitlines()
matching = [s for s in some_list if keyword in s]
print(matching)
mylist = []
for x in matching :
mylist.append(some_list[some_list.index(x) + 2].split('-')[0])
final_list = []
for x in mylist:
final_list.append(float(x[1:]))
print(final_list)
time.sleep(1)
driver.quit()
return final_list
# return transcribe_urlip
#\convert_to_text("/home/priyanshu/Desktop/GTube/videoplayback.mp4", "you")