Skip to content

Commit

Permalink
Merge pull request #150 from fa0311/develop-v5
Browse files Browse the repository at this point in the history
v5.9.0
  • Loading branch information
fa0311 authored Nov 28, 2024
2 parents 99abc76 + ce69093 commit 045b9e7
Show file tree
Hide file tree
Showing 11 changed files with 3,029 additions and 1,014 deletions.
14 changes: 11 additions & 3 deletions DMMGamePlayerFastLauncher/lib/DGPSessionV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
urllib3.disable_warnings()


def text_factory(x: bytes):
try:
return x.decode("utf-8")
except Exception:
return x


class DgpSessionUtils:
@staticmethod
def gen_rand_hex():
Expand Down Expand Up @@ -99,6 +106,7 @@ def __init__(self):

def __enter__(self):
self.db = sqlite3.connect(self.DGP5_DATA_PATH.joinpath("Network", "Cookies"))
self.db.text_factory = text_factory
return self

def __exit__(self, exc_type, exc_value, traceback):
Expand All @@ -112,10 +120,10 @@ def write(self):
v10, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
value = cipher.decrypt_and_verify(data, mac)
head, body = value[:32], value[32:]
prefix, body = value[:32], value[32:]

cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
decrypt_data, mac = cipher.encrypt_and_digest(head + cookie.encode())
decrypt_data, mac = cipher.encrypt_and_digest(prefix + cookie.encode())
data = self.join_encrypted_data(v10, nonce, decrypt_data, mac)
self.db.execute(
"update cookies set encrypted_value = ? where name = ?",
Expand All @@ -132,7 +140,7 @@ def read(self):
v10, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
value = cipher.decrypt_and_verify(data, mac)
head, body = value[:32], value[32:]
prefix, body = value[:32], value[32:]

cookie_data = {
"name": cookie_row[3],
Expand Down
2 changes: 1 addition & 1 deletion DMMGamePlayerFastLauncher/static/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Env(Dump):
VERSION = "v5.8.0"
VERSION = "v5.9.0"
RELEASE_VERSION = requests.get(UrlConfig.RELEASE_API).json().get("tag_name", VERSION)

DEVELOP: bool = os.environ.get("ENV") == "DEVELOP"
Expand Down
75 changes: 71 additions & 4 deletions DMMGamePlayerFastLauncher/tab/account.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from pathlib import Path
from tkinter import StringVar
from typing import TypeVar
Expand All @@ -9,6 +10,7 @@
from customtkinter import CTkBaseClass, CTkButton, CTkFrame, CTkLabel, CTkScrollableFrame
from lib.DGPSessionWrap import DgpSessionWrap
from lib.toast import ToastController, error_toast
from selenium import webdriver
from static.config import DataPathConfig
from utils.utils import children_destroy, file_create

Expand All @@ -27,15 +29,19 @@ def __init__(self, master: CTkBaseClass):

def create(self):
self.tab.create()
self.tab.add(text=i18n.t("app.tab.import"), callback=self.import_callback)
self.tab.add(text=i18n.t("app.tab.edit"), callback=self.edit_callback)
self.tab.add(text=i18n.t("app.tab.account_import"), callback=self.import_callback)
self.tab.add(text=i18n.t("app.tab.import_browser"), callback=self.import_browser_callback)
self.tab.add(text=i18n.t("app.tab.account_edit"), callback=self.edit_callback)
self.tab.add(text=i18n.t("app.tab.device"), callback=self.device_callback)
self.tab.add(text=i18n.t("app.tab.device_list"), callback=self.device_list_callback)
return self

def import_callback(self, master: CTkBaseClass):
AccountImport(master).create().pack(expand=True, fill=ctk.BOTH)

def import_browser_callback(self, master: CTkBaseClass):
AccountBrowserImport(master).create().pack(expand=True, fill=ctk.BOTH)

def edit_callback(self, master: CTkBaseClass):
AccountEdit(master).create().pack(expand=True, fill=ctk.BOTH)

Expand Down Expand Up @@ -84,6 +90,67 @@ def callback(self):
self.toast.info(i18n.t("app.account.import_success"))


class AccountBrowserImport(CTkScrollableFrame):
toast: ToastController
name: StringVar
browser: StringVar

def __init__(self, master: CTkBaseClass):
super().__init__(master, fg_color="transparent")
self.toast = ToastController(self)
self.name = StringVar()
self.browser = StringVar()

def create(self):
CTkLabel(self, text=i18n.t("app.account.import_browser_detail"), justify=ctk.LEFT).pack(anchor=ctk.W)
text = i18n.t("app.account.filename")
tooltip = i18n.t("app.account.filename_tooltip")
EntryComponent(self, text=text, tooltip=tooltip, required=True, variable=self.name, alnum_only=True).create()
text = i18n.t("app.account.browser_select")
tooltip = i18n.t("app.account.browser_select_tooltip")
OptionMenuComponent(self, text=text, tooltip=tooltip, values=["Chrome", "Edge", "Firefox"], variable=self.browser).create()
CTkButton(self, text=i18n.t("app.account.import_browser"), command=self.callback).pack(fill=ctk.X, pady=10)
return self

def get_driver(self):
if self.browser.get() == "Chrome":
return webdriver.Chrome()
elif self.browser.get() == "Edge":
return webdriver.Edge()
elif self.browser.get() == "Firefox":
return webdriver.Firefox()
else:
raise Exception(i18n.t("app.account.browser_not_selected"))

@error_toast
def callback(self):
path = DataPathConfig.ACCOUNT.joinpath(self.name.get()).with_suffix(".bytes")
if self.name.get() == "":
raise Exception(i18n.t("app.account.filename_not_entered"))
if path.exists():
raise Exception(i18n.t("app.account.filename_already_exists"))

driver = self.get_driver()
driver.get("https://accounts.dmm.com/service/login/password")
while driver.current_url != "https://www.dmm.com/":
time.sleep(0.2)
with DgpSessionWrap() as session:
cookies = driver.get_cookies()
for cookie in cookies:
cookie_data = {
"name": cookie["name"],
"value": cookie["value"],
"domain": cookie["domain"],
"path": cookie["path"],
"secure": cookie["secure"],
}
session.cookies.set(**cookie_data)
session.write_bytes(str(path))
self.toast.info(i18n.t("app.account.import_browser_success"))

driver.quit()


class AccountEdit(CTkScrollableFrame):
toast: ToastController
values: list[str]
Expand Down Expand Up @@ -237,11 +304,11 @@ def __init__(self, master: CTkBaseClass):
def create(self):
OptionMenuComponent(self, text=i18n.t("app.account.file_select"), values=self.values, variable=self.filename, command=self.select_callback).create()
if self.data:
count = len(self.data["hardwares"])
count = len(self.data["hardwares"] or [])
limit = self.data["device_auth_limit_num"]
CTkLabel(self, text=i18n.t("app.account.device_registrations", count=count, limit=limit), justify=ctk.LEFT).pack(anchor=ctk.W)

for hardware in self.data["hardwares"]:
for hardware in self.data["hardwares"] or []:
for key, value in hardware.items():
EntryComponent(self, text=key, variable=StringVar(value=value), state=ctk.DISABLED).create()

Expand Down
14 changes: 13 additions & 1 deletion assets/i18n/app.en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ en_US:
edit: Edit Shortcut
launch_create: Fast Launch GamePlayer
launch_edit: Edit Fast Launch GamePlayer
import: Import
account_import: Import
account_edit: Edit Account
import_browser: Import from Browser
device: Register Device
device_list: Device List

Expand Down Expand Up @@ -111,6 +113,16 @@ en_US:

file_select: Select File

import_browser_detail: |-
Launch the browser to import account information from DMMGamePlayer.
Do not use accounts imported with this feature for the `GamePlayer Acceleration` settings.
browser_select: Select Browser
browser_select_tooltip: |-
Choose your preferred browser.
The specified browser will launch and open the login screen.
import_browser: Import
import_browser_success: Imported successfully.

edit_detail: |-
Edit your account information.
This is an advanced operation.
Expand Down
14 changes: 13 additions & 1 deletion assets/i18n/app.ja_JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ ja_JP:
edit: ショートカットの編集
launch_create: GamePlayerの高速化
launch_edit: GamePlayer高速化の編集
import: インポート
account_import: インポート
account_edit: アカウントの編集
import_browser: ブラウザからインポート
device: デバイスの登録
device_list: デバイスの一覧

Expand Down Expand Up @@ -109,6 +111,16 @@ ja_JP:

file_select: ファイルの選択

import_browser_detail: |-
ブラウザを起動してDMMGamePlayerのアカウント情報をインポートします。
この機能を使用してインポートしたアカウントは `GamePlayerの高速化` 設定に使用しないでください。
browser_select: ブラウザの選択
browser_select_tooltip: |-
お好みのブラウザを選択してください。
指定されたブラウザを起動してログイン画面を開きます。
import_browser: インポート
import_browser_success: インポートに成功しました。

edit_detail: |-
アカウント情報を編集します。
これは非常に高度な操作になります。
Expand Down
14 changes: 13 additions & 1 deletion assets/i18n/app.zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ zh_CN:
edit: 编辑快捷方式
launch_create: 快速启动 GamePlayer
launch_edit: 编辑快速启动 GamePlayer
import: 导入
account_import: 导入
account_edit: 编辑账户
import_browser: 从浏览器导入
device: 注册设备
device_list: 设备列表

Expand Down Expand Up @@ -110,6 +112,16 @@ zh_CN:

file_select: 选择文件

import_browser_detail: |-
启动浏览器以从DMMGamePlayer导入帐户信息。
请不要将使用此功能导入的帐户用于 `GamePlayer加速` 设置。
browser_select: 选择浏览器
browser_select_tooltip: |-
选择您喜欢的浏览器。
系统将启动指定的浏览器并打开登录页面。
import_browser: 导入
import_browser_success: 导入成功。

edit_detail: |-
编辑您的帐户信息。
这是一项高级操作。
Expand Down
14 changes: 13 additions & 1 deletion assets/i18n/app.zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ zh_TW:
edit: 編輯快捷方式
launch_create: 快速啟動 GamePlayer
launch_edit: 編輯快速啟動 GamePlayer
import: 匯入
account_import: 匯入
account_edit: 編輯帳號
import_browser: 從瀏覽器匯入
device: 註冊設備
device_list: 設備清單

Expand Down Expand Up @@ -109,6 +111,16 @@ zh_TW:

file_select: 選擇檔案

import_browser_detail: |-
啟動瀏覽器以從DMMGamePlayer匯入帳號資訊。
請勿將使用此功能匯入的帳號用於 `GamePlayer加速` 設定。
browser_select: 選擇瀏覽器
browser_select_tooltip: |-
選擇您偏好的瀏覽器。
系統將啟動指定的瀏覽器並開啟登入畫面。
import_browser: 匯入
import_browser_success: 匯入成功。

edit_detail: |-
編輯您的帳戶資訊。
這是一項高級操作。
Expand Down
Loading

0 comments on commit 045b9e7

Please sign in to comment.