Skip to content

Commit

Permalink
修改打包后的命令行输出内容
Browse files Browse the repository at this point in the history
添加配置文件
  • Loading branch information
lipc_1700 committed Mar 7, 2021
1 parent f1fb79b commit ef29ce6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ cached_网易云音乐/
dst/
.idea/
__pycache__/
build/
dist/
chrome_win_80/
decrypt.spec
11 changes: 3 additions & 8 deletions chrome_Daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

class MyChromeDaemon(object):
root_url = "http://www.baidu.com"
# user_data_path = "E:\\workspace\\movie_center_ui\\cache\\chromium_cache_80\\user-data"
# disk_cache_path = "E:\\workspace\\movie_center_ui\\cache\\chromium_cache_80\\disk-cache"
# chrome_exe_path = "E:\\workspace\\movie_center_ui\\chrome-win-80\\chrome.exe"
# chrome_driver_path = "E:\\workspace\\movie_center_ui\\selenium_scraper\\chromedriver_800397.exe"
user_data_path = os.path.abspath("./cache/chromium_cache/user_data") # 传入abs路径后,才不会和 headless flag 冲突
disk_cache_path = os.path.abspath("./cache/chromium_cache/disk_cache")
chrome_exe_path = os.path.abspath("./chrome_win_80/chrome.exe")
Expand All @@ -40,7 +36,8 @@ def __init__(self):

def init(self):
chrome_options=Options()
chrome_options.add_argument("--headless") #设置chrome浏览器无界面模式
chrome_options.add_argument("--headless") #设置chrome浏览器无界面模式 无头模式会又命令行输出
chrome_options.add_argument("log-level=3") # 防止打包后 无头模式的chrome输出console中的内容
# chrome_options.add_argument(f"proxy-server={self.proxy_server_address}")
chrome_options.binary_location = self.chrome_exe_path
chrome_options.add_argument(f"user-data-dir={self.user_data_path}")
Expand All @@ -53,11 +50,9 @@ def init(self):
#建立浏览器实例
browser = webdriver.Chrome(options=chrome_options, executable_path=self.chrome_driver_path)
self.browser = browser
print("2?")
browser.set_script_timeout(120)
# 开始请求
browser.get(self.root_url)
print("??")
# browser.get(self.root_url)

def start_thread(self):
def body():
Expand Down
3 changes: 3 additions & 0 deletions decrypt.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[global]
srcDir=C:/Users/DogEgg/AppData/Local/Netease/CloudMusic/Cache/Cache
desDir=E:/workspace/netease-cached-music/dst/
13 changes: 11 additions & 2 deletions decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from eyed3.id3.frames import ImageFrame
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler, FileSystemEvent, LoggingEventHandler
from selenium.webdriver.remote.remote_connection import LOGGER as seleniumLogger
import logging
from configparser import ConfigParser

from chrome_Daemon import MyChromeDaemon

Expand Down Expand Up @@ -194,16 +196,23 @@ def on_modified(self, event: FileSystemEvent):


if __name__ == '__main__':
config = ConfigParser()
config.read('./decrypt.config')
srcDir = config["global"]["srcDir"]
desDir = config["global"]["desDir"]
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%H:%M:%S')
seleniumLogger.setLevel(logging.WARNING)
logging = logging.getLogger("NeteaseDecrypt")
daemon = MyChromeDaemon()
daemon.listen_ready.acquire() # 等待 监听线程开始运行
# daemon.browser.get("https://music.163.com/")

# handler = Netease_music("E:/workspace/netease-cached-music/cache/", "E:/workspace/netease-cached-music/dst/")
handler = Netease_music("C:\\Users\\DogEgg\\AppData\\Local\\Netease\\CloudMusic\\Cache\\Cache",
"E:/workspace/netease-cached-music/dst/")
# handler = Netease_music("C:\\Users\\DogEgg\\AppData\\Local\\Netease\\CloudMusic\\Cache\\Cache",
# "E:/workspace/netease-cached-music/dst/")
handler = Netease_music(srcDir, desDir)
handler.start_dir_watch()
# handler.getMusic()
# print(handler.getInfoFromWeb("65528"))

0 comments on commit ef29ce6

Please sign in to comment.