From c08e7bba9cf94cce74613c5dd6ee6110ac68726c Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 7 Oct 2017 03:50:17 +0530 Subject: [PATCH] Added driver choice --- .../youtube.ide.py | 29 +++++++++++------ .../youtube.py | 31 ++++++++++++++----- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Download Youtube Video from cmd using python/youtube.ide.py b/Download Youtube Video from cmd using python/youtube.ide.py index 89954ee..81e36e4 100644 --- a/Download Youtube Video from cmd using python/youtube.ide.py +++ b/Download Youtube Video from cmd using python/youtube.ide.py @@ -5,6 +5,7 @@ import urllib.request import json import time +import argparse import selenium from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary @@ -18,15 +19,27 @@ print(name) try: - # Phantom JS + ap = argparse.ArgumentParser() + ap.add_argument("-d", "--driver", type=str, default="phantomjs", + help="which driver to use [option: phantomjs, firefox, chrome]") - driver = webdriver.PhantomJS(executable_path=r'C:\Users\ankit\Downloads\phantomjs-2.1.1-windows (1)\phantomjs-2.1.1-windows\bin\phantomjs.exe') - driver.set_window_size(1120, 550) + args = vars(ap.parse_args()) + choice = args["driver"] - # FireFox + driver = "" + if choice == "firefox": + binary = FirefoxBinary('firefox') + driver = webdriver.Firefox(firefox_binary=binary) + elif choice == "chrome": + driver = webdriver.Chrome(); + elif choice == "phantomjs": + driver = webdriver.PhantomJS( + executable_path=r'phantomjs') + else: + print("Invalid Choice"); + sys.exit(1); - # binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\Firefox.exe') - # driver = webdriver.Firefox(firefox_binary=binary) + driver.set_window_size(1120, 550) driver.get("http://en.savefrom.net") shURL = driver.find_element_by_xpath('//input[@id="sf_url" and @type="text"]') @@ -40,10 +53,6 @@ url_parse = click.get("href") driver.quit() path = os.getcwd() - # print("Downloading Starts..\n") - # print(url_parse) - # urllib.request.urlretrieve(url_parse, name) - installs = [ 'idman.exe /n /d ' + '"' + url_parse + '"' + ' /p ' + '"' + path + '"' + ' /f ' + '"' + name + '"' + ' /q', diff --git a/Download Youtube Video from cmd using python/youtube.py b/Download Youtube Video from cmd using python/youtube.py index d5c8ba0..0a86c23 100644 --- a/Download Youtube Video from cmd using python/youtube.py +++ b/Download Youtube Video from cmd using python/youtube.py @@ -2,6 +2,7 @@ import requests import json import selenium +import argparse from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.common.keys import Keys @@ -115,22 +116,36 @@ def reporthook(blocknum, blocksize, total): sizeType = '' flag = 0 + + + url = input("Enter the Youtube-url\n") name = input("Enter the name for the video\n") name = name+".mp4" try: - # Phantom JS + ap = argparse.ArgumentParser() + ap.add_argument("-d", "--driver", type=str, default="phantomjs", + help="which driver to use [option: phantomjs, firefox, chrome]") + + args = vars(ap.parse_args()) + choice = args["driver"] + + driver = "" + if choice == "firefox": + binary = FirefoxBinary('firefox') + driver = webdriver.Firefox(firefox_binary=binary) + elif choice == "chrome": + driver = webdriver.Chrome(); + elif choice == "phantomjs": + driver = webdriver.PhantomJS( + executable_path=r'phantomjs') + else: + print("Invalid Choice"); + sys.exit(1); - driver = webdriver.PhantomJS( - executable_path=r'C:\Users\ankit\Downloads\phantomjs-2.1.1-windows (1)\phantomjs-2.1.1-windows\bin\phantomjs.exe') driver.set_window_size(1120, 550) - # FireFox - - # binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\Firefox.exe') - # driver = webdriver.Firefox(firefox_binary=binary) - driver.get("http://en.savefrom.net") shURL = driver.find_element_by_xpath( '//input[@id="sf_url" and @type="text"]') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy