From dfeb059dee7313358ade25d90b2f1f1a8393051b Mon Sep 17 00:00:00 2001
From: CXwudi <1113421658@qq.com>
Date: Thu, 7 May 2020 23:57:59 -0400
Subject: [PATCH] :fire: use webdriver manager dep to replace pain old
webdriver plugin
---
.classpath | 20 +-
.idea/inspectionProfiles/Project_Default.xml | 36 +++
data/system_config.properties | 6 -
lib/selenium_drivers/.gitignore | 2 -
lib/selenium_drivers/repo.xml | 217 ------------------
niconico-video-downloader.eml | 20 +-
niconico-video-downloader.iml | 8 +-
pom.xml | 117 +---------
.../setup/Config.java | 8 +-
.../setup/WriteConfigFileByMaven.java | 70 ------
10 files changed, 76 insertions(+), 428 deletions(-)
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
delete mode 100644 lib/selenium_drivers/.gitignore
delete mode 100644 lib/selenium_drivers/repo.xml
delete mode 100644 src/main/java/com/cxwudi/niconico_videodownloader/setup/WriteConfigFileByMaven.java
diff --git a/.classpath b/.classpath
index f65bf2b..a951d9c 100644
--- a/.classpath
+++ b/.classpath
@@ -33,16 +33,9 @@
-
-
-
-
-
-
+
-
-
@@ -53,8 +46,17 @@
+
+
+
+
+
+
+
+
+
+
-
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..6560a98
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/system_config.properties b/data/system_config.properties
index 8b8ac92..a48ca41 100644
--- a/data/system_config.properties
+++ b/data/system_config.properties
@@ -1,11 +1,5 @@
#Niconico Video Downloader Selenium drivers location
-#selenium driver location
-#these properties will be set to system property when niconico video downloader launch
-webdriver.chrome.driver=lib\\selenium_drivers\\bin\\windows\\googlechrome\\64bit\\chromedriver.exe
-webdriver.edge.driver=lib\\selenium_drivers\\bin\\windows\\edge\\64bit\\MicrosoftWebDriver.exe
-webdriver.opera.driver=lib\\selenium_drivers\\bin\\windows\\operachromium\\64bit\\operadriver.exe
-
#base dirs
data.dir=data
lib.dir=lib
diff --git a/lib/selenium_drivers/.gitignore b/lib/selenium_drivers/.gitignore
deleted file mode 100644
index 811b628..0000000
--- a/lib/selenium_drivers/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/zips/
diff --git a/lib/selenium_drivers/repo.xml b/lib/selenium_drivers/repo.xml
deleted file mode 100644
index ac84ca7..0000000
--- a/lib/selenium_drivers/repo.xml
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
-
-
-
-
- http://selenium-release.storage.googleapis.com/3.9/IEDriverServer_x64_3.9.0.zip
-
- c9f885b6a339f3f0039d670a23f998868f539e65
- sha1
-
-
- http://selenium-release.storage.googleapis.com/3.9/IEDriverServer_Win32_3.9.0.zip
-
- dab42d7419599dd311d4fba424398fba2f20e883
- sha1
-
-
-
-
-
-
- https://download.microsoft.com/download/D/4/1/D417998A-58EE-4EFE-A7CC-39EF9E020768/MicrosoftWebDriver.exe
-
- 60c4b6d859ee868ba5aa29c1e5bfa892358e3f96
- sha1
-
-
-
-
-
-
- https://chromedriver.storage.googleapis.com/80.0.3987.106/chromedriver_win32.zip
-
- fe708aac4eeb919a4ce26cf4aa52a2dacc666a2f
- sha1
-
-
-
-
-
-
- https://github.com/operasoftware/operachromiumdriver/releases/download/v.2.35/operadriver_win64.zip
-
- 180a876f40dbc9734ebb81a3b6f2be35cadaf0cc
- sha1
-
-
- https://github.com/operasoftware/operachromiumdriver/releases/download/v.2.35/operadriver_win32.zip
-
- 55d43156716d7d1021733c2825e99896fea73815
- sha1
-
-
-
-
-
-
- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-windows.zip
-
- 4531bd64df101a689ac7ac7f3e11bb7e77af8eff
- sha1
-
-
-
-
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-win64.zip
-
- e96a24cf4147d6571449bdd279be65a5e773ba4c
- sha1
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-win32.zip
-
- 9aa5bbdc68acc93c244a7ba5111a3858d8cbc41d
- sha1
-
-
-
-
-
-
- https://www.firefox-usb.com/download/FirefoxPortable32-68.0.1.zip
-
- a532d642686d6e1dfca8ddc97c52565d
- md5
-
-
- https://www.firefox-usb.com/download/FirefoxPortable64-68.0.1.zip
-
- 8b8b5679e23531ae562993e08e869a01
- md5
-
-
-
-
-
-
-
-
- https://chromedriver.storage.googleapis.com/80.0.3987.106/chromedriver_linux64.zip
-
- b8515d09bb2d533ca3b85174c85cac1e062d04c6
- sha1
-
-
-
-
-
-
- https://github.com/operasoftware/operachromiumdriver/releases/download/v.2.35/operadriver_linux64.zip
-
- f75845a7e37e4c1a58c61677a2d6766477a4ced2
- sha1
-
-
-
-
-
-
- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
-
- d29487b2701bcbe3c0a52bc176247ceda4d09d2d
- sha1
-
-
- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2
-
- efac5ae5b84a4b2b3fa845e8390fca39e6e637f2
- sha1
-
-
-
-
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-linux64.tar.gz
-
- e23a6ae18bec896afe00e445e0152fba9ed92007
- sha1
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-linux32.tar.gz
-
- c80eb7a07ae3fe6eef2f52855007939c4b655a4c
- sha1
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-arm7hf.tar.gz
-
- 2776db97a330c38bb426034d414a01c7bf19cc94
- sha1
-
-
-
-
-
-
- https://ftp.mozilla.org/pub/firefox/releases/68.0.1/linux-x86_64/en-US/firefox-68.0.1.tar.bz2
-
- 2daf7f9e8dbc3e5c083b4eef923051cdca5fed3a
- sha1
-
-
- https://ftp.mozilla.org/pub/firefox/releases/68.0.1/linux-i686/en-US/firefox-68.0.1.tar.bz2
-
- 3808f8b852a20d748dd17cd69963f804bb1371ec
- sha1
-
-
-
-
-
-
-
-
- https://chromedriver.storage.googleapis.com/80.0.3987.106/chromedriver_mac64.zip
-
- 714e7abb1a7aeea9a8997b64a356a44fb48f5ef4
- sha1
-
-
-
-
-
-
- https://github.com/operasoftware/operachromiumdriver/releases/download/v.2.35/operadriver_mac64.zip
-
- 66a88c856b55f6c89ff5d125760d920e0d4db6ff
- sha1
-
-
-
-
-
-
- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-macosx.zip
-
- d70bbefd857f21104c5961b9dd081781cb4d999a
- sha1
-
-
-
-
-
-
- https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-macos.tar.gz
-
- 87a63f8adc2767332f2eadb24dedff982ac4f902
- sha1
-
-
-
-
-
\ No newline at end of file
diff --git a/niconico-video-downloader.eml b/niconico-video-downloader.eml
index 99f363f..44e7c1e 100644
--- a/niconico-video-downloader.eml
+++ b/niconico-video-downloader.eml
@@ -22,16 +22,9 @@
-
-
-
-
-
-
+
-
-
@@ -42,8 +35,17 @@
+
+
+
+
+
+
+
+
+
+
-
diff --git a/niconico-video-downloader.iml b/niconico-video-downloader.iml
index 240f3e9..7fd00fc 100644
--- a/niconico-video-downloader.iml
+++ b/niconico-video-downloader.iml
@@ -1,2 +1,8 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6af83fc..186a4e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,6 @@
${lib.dir}/selenium_drivers
release
package
- com.cxwudi.niconico_videodownloader.setup.WriteConfigFileByMaven
com.cxwudi.niconico_videodownloader.setup.CopyFilesForRelease
com.cxwudi.niconico_videodownloader.Main
@@ -44,10 +43,17 @@
org.seleniumhq.selenium
- selenium-java
+ selenium-chrome-driver
3.141.59
+
+
+ io.github.bonigarcia
+ webdrivermanager
+ 3.8.1
+
+
org.apache.commons
@@ -118,102 +124,6 @@
-
- com.lazerycode.selenium
- driver-binary-downloader-maven-plugin
- 1.0.17
-
-
- ${selenium.rootDir}/bin
-
- ${selenium.rootDir}/zips
-
- ${selenium.rootDir}/repo.xml
-
- true
-
-
- true
- false
- false
-
-
- true
-
- true
-
- true
-
-
- false
-
- 2
-
- 20000
-
- 10000
-
- false
-
- false
-
-
- true
-
-
-
- download-selenium
- generate-sources
-
- selenium
-
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.6.0
-
-
- setup-selenium-properties
- generate-sources
-
- java
-
-
- ${init.mainClass}
-
-
-
-
-
- webdriver.edge.driver
-
- ${webdriver.edge.driver}
-
-
- webdriver.opera.driver
-
- ${webdriver.opera.driver}
-
-
- webdriver.chrome.driver
-
- ${webdriver.chrome.driver}
-
-
-
-
-
-
org.apache.maven.plugins
@@ -235,17 +145,8 @@
-
-
- org.codehaus.mojo
- versions-maven-plugin
- 2.7
-
- false
-
-
-
maven-compiler-plugin
3.8.1
diff --git a/src/main/java/com/cxwudi/niconico_videodownloader/setup/Config.java b/src/main/java/com/cxwudi/niconico_videodownloader/setup/Config.java
index 5063bc1..023ddeb 100644
--- a/src/main/java/com/cxwudi/niconico_videodownloader/setup/Config.java
+++ b/src/main/java/com/cxwudi/niconico_videodownloader/setup/Config.java
@@ -2,6 +2,7 @@
import com.cxwudi.niconico_videodownloader.solve_tasks.downloader.DLMethodNamesEnum;
import com.cxwudi.niconico_videodownloader.util.LazyVar;
+import io.github.bonigarcia.wdm.WebDriverManager;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.FileBasedConfiguration;
import org.apache.commons.configuration2.PropertiesConfiguration;
@@ -92,12 +93,7 @@ public static final void touch() {/*simply invoke the static block above*/}
setupUserConfig(params);
//setup selenium system properties
- var webDriverProperties = systemConfig.getKeys("webdriver");
- webDriverProperties.forEachRemaining(keyStr -> {
- var value = systemConfig.getString(keyStr);
- logger.debug("Selenium system property set: {} -> {}", keyStr, value);
- System.setProperty(keyStr, value);
- });
+ WebDriverManager.chromedriver().setup();
}
private static void setupUserConfig(Parameters params) {
diff --git a/src/main/java/com/cxwudi/niconico_videodownloader/setup/WriteConfigFileByMaven.java b/src/main/java/com/cxwudi/niconico_videodownloader/setup/WriteConfigFileByMaven.java
deleted file mode 100644
index dd50bb0..0000000
--- a/src/main/java/com/cxwudi/niconico_videodownloader/setup/WriteConfigFileByMaven.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.cxwudi.niconico_videodownloader.setup;
-
-import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.configuration2.FileBasedConfiguration;
-import org.apache.commons.configuration2.PropertiesConfiguration;
-import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
-import org.apache.commons.configuration2.builder.fluent.Parameters;
-import org.apache.commons.configuration2.ex.ConfigurationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.lang.invoke.MethodHandles;
-
-/**
- * A scripting class just for writing our selenium drivers location
- * @author CX无敌
- */
-public class WriteConfigFileByMaven {
-
- private static File systemConfigFile = new File("data/system_config.properties");
-
- private FileBasedConfigurationBuilder builder;
- private Configuration config;
-
- public WriteConfigFileByMaven() {
- Parameters params = new Parameters();
- builder = new FileBasedConfigurationBuilder(PropertiesConfiguration.class)
- .configure(params.properties()
- .setFileName(systemConfigFile.getPath()));
- try
- {
- config = builder.getConfiguration();
- logger.info("successfully load {}", systemConfigFile);
- }
- catch(ConfigurationException cex)
- {
- logger.error("Can not get configuration\n", cex);
- }
- }
-
- public void writeSeleniumDriverLocation(){
- var sysProp = System.getProperties();
- var currentDir = sysProp.getProperty("user.dir");
- for (var property: sysProp.entrySet()) {
- var keyStr = String.valueOf(property.getKey());
- var valueStr = String.valueOf(property.getValue());
-// logger.debug("get property: {} = {}", keyStr, valueStr);
- if (keyStr.contains("driver")){
- var resolvedStr = valueStr.replace(currentDir + "\\", "");
- config.setProperty(keyStr, resolvedStr);
- logger.info("saving new selenium property: {} = {}", keyStr, resolvedStr);
- }
- }
-
- try {
- builder.save();
- } catch (ConfigurationException e) {
- logger.error("Can not save config file\n", e);
- }
- }
-
- public static void main(String[] args) {
- var obj = new WriteConfigFileByMaven();
- obj.writeSeleniumDriverLocation();
- }
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-}