Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DedInc committed Nov 20, 2022
1 parent 5aa62a2 commit e912019
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='ytty',
version='1.0.1',
version='1.0.2',
author='Maehdakvan',
author_email='[email protected]',
description='Ytty - Powerful tool for parsing, downloading and uploading videos from youtube based on selenium.',
Expand All @@ -27,6 +27,6 @@
],
packages=find_packages(),
include_package_data=True,
install_requires=['vidspinner', 'pyperclip', 'undetected-chromedriver', 'requests'],
install_requires=['vidspinner', 'pyperclip', 'undetected-chromedriver', 'requests', 'keyboard', 'pythread'],
python_requires='>=3.6'
)
44 changes: 25 additions & 19 deletions ytty/ytty.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from subprocess import Popen
from sys import platform
from time import sleep
from threading import Thread
from undetected_chromedriver import Chrome, ChromeOptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Expand All @@ -13,6 +12,8 @@
from requests import get
from vidspinner import unique
from pyperclip import copy as copy2clip
from keyboard import write, press
from pythread import createThread, stopThread

CDIR = abspath(dirname(__file__))

Expand Down Expand Up @@ -92,16 +93,19 @@ def googleSession(login, password, ver=None):
driver = initer()
driver.get('https://accounts.google.com/signin')
loginField = driver.find_element(By.ID, 'identifierId')
nextButton = driver.find_elements(By.CSS_SELECTOR, 'button')[2]
actions = ActionChains(driver)
actions.move_to_element(loginField).click().send_keys(login).perform()
actions.move_to_element(nextButton).click().perform()
sleep(3)
passwordField = driver.find_element(By.ID, 'password')
actions.move_to_element(passwordField).click().send_keys(password).perform()
nextButton = driver.find_elements(By.CSS_SELECTOR, 'button')[2]
actions.move_to_element(nextButton).click().perform()
sleep(3)
actions.move_to_element(loginField).click().perform()
write(login)
sleep(0.5)
press('enter')

actions = ActionChains(driver)
passwordField = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.ID, 'password')))
actions.move_to_element(passwordField).click().perform()
write(password)
sleep(0.5)
press('enter')
sleep(5)
return driver

def getYTDlp():
Expand Down Expand Up @@ -141,12 +145,11 @@ def getThumbnail(vid):
return fname

def notifyCloser():
while True:
try:
closeNotify = WebDriverWait(driver, 0.1).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#close-button')))
click(driver, closeNotify)
except:
pass
try:
closeNotify = WebDriverWait(driver, 0.1).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#close-button')))
click(driver, closeNotify)
except:
pass

def uploadVideo(driver, options):
driver.get('https://youtube.com/upload')
Expand All @@ -157,23 +160,24 @@ def uploadVideo(driver, options):
except:
pass

t = Thread(target=notifyCloser)
t = createThread('NotifyCloser', notifyCloser, 0.1)
t.start()

inputs = driver.find_elements(By.TAG_NAME, 'input')
for input in inputs:
if input.get_attribute('type') == 'file':
picker = input
break

picker.send_keys(abspath(options.upload.video))

WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div#textbox')))

textboxes = driver.find_elements(By.CSS_SELECTOR, 'div#textbox')
titleElem = textboxes[len(textboxes) - 2]
driver.execute_script('arguments[0].innerText = \'\'', titleElem)
descriptionElem = textboxes[len(textboxes) - 3]

driver.execute_script('arguments[0].innerText = \'\'', titleElem)
setValue(driver, titleElem, options.upload.title)
setValue(driver, descriptionElem, options.upload.description)

Expand Down Expand Up @@ -223,9 +227,11 @@ def uploadVideo(driver, options):

publish = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#done-button:not([disabled])')))
click(driver, publish)

while len(driver.find_elements(By.CSS_SELECTOR, 'ytcp-video-upload-progress[uploading]')) != 0:
pass
t.join()

stopThread(t)

def parseVideos(driver, options):
parseList = []
Expand Down

0 comments on commit e912019

Please sign in to comment.