mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 16:53:47 +03:00
Merge branch 'feat/migration-to-scss-3-remake' of https://github.com/hydralauncher/hydra into feat/migration-to-scss-3-remake
This commit is contained in:
commit
2e85363966
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,3 +14,5 @@ aria2/
|
||||
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
|
||||
*storybook.log
|
||||
|
@ -37,6 +37,13 @@ export default defineConfig(({ mode }) => {
|
||||
build: {
|
||||
sourcemap: true,
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
api: "modern",
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@renderer": resolve("src/renderer/src"),
|
||||
|
@ -44,6 +44,7 @@
|
||||
"auto-launch": "^5.0.6",
|
||||
"axios": "^1.7.9",
|
||||
"better-sqlite3": "^11.7.0",
|
||||
"classic-level": "^2.0.0",
|
||||
"classnames": "^2.5.1",
|
||||
"color": "^4.2.3",
|
||||
"color.js": "^1.2.0",
|
||||
@ -71,7 +72,6 @@
|
||||
"sound-play": "^1.1.0",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"tar": "^7.4.3",
|
||||
"typeorm": "^0.3.20",
|
||||
"user-agents": "^1.1.387",
|
||||
"yaml": "^2.6.1",
|
||||
"yup": "^1.5.0",
|
||||
|
@ -11,11 +11,12 @@ class HttpDownloader:
|
||||
)
|
||||
)
|
||||
|
||||
def start_download(self, url: str, save_path: str, header: str):
|
||||
def start_download(self, url: str, save_path: str, header: str, out: str = None):
|
||||
if self.download:
|
||||
self.aria2.resume([self.download])
|
||||
else:
|
||||
downloads = self.aria2.add(url, options={"header": header, "dir": save_path})
|
||||
downloads = self.aria2.add(url, options={"header": header, "dir": save_path, "out": out})
|
||||
|
||||
self.download = downloads[0]
|
||||
|
||||
def pause_download(self):
|
||||
|
@ -28,14 +28,14 @@ if start_download_payload:
|
||||
torrent_downloader = TorrentDownloader(torrent_session)
|
||||
downloads[initial_download['game_id']] = torrent_downloader
|
||||
try:
|
||||
torrent_downloader.start_download(initial_download['url'], initial_download['save_path'], "")
|
||||
torrent_downloader.start_download(initial_download['url'], initial_download['save_path'])
|
||||
except Exception as e:
|
||||
print("Error starting torrent download", e)
|
||||
else:
|
||||
http_downloader = HttpDownloader()
|
||||
downloads[initial_download['game_id']] = http_downloader
|
||||
try:
|
||||
http_downloader.start_download(initial_download['url'], initial_download['save_path'], initial_download.get('header'))
|
||||
http_downloader.start_download(initial_download['url'], initial_download['save_path'], initial_download.get('header'), initial_download.get("out"))
|
||||
except Exception as e:
|
||||
print("Error starting http download", e)
|
||||
|
||||
@ -45,7 +45,7 @@ if start_seeding_payload:
|
||||
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
|
||||
downloads[seed['game_id']] = torrent_downloader
|
||||
try:
|
||||
torrent_downloader.start_download(seed['url'], seed['save_path'], "")
|
||||
torrent_downloader.start_download(seed['url'], seed['save_path'])
|
||||
except Exception as e:
|
||||
print("Error starting seeding", e)
|
||||
|
||||
@ -94,7 +94,7 @@ def seed_status():
|
||||
|
||||
@app.route("/healthcheck", methods=["GET"])
|
||||
def healthcheck():
|
||||
return "", 200
|
||||
return "ok", 200
|
||||
|
||||
@app.route("/process-list", methods=["GET"])
|
||||
def process_list():
|
||||
@ -140,18 +140,18 @@ def action():
|
||||
|
||||
if url.startswith('magnet'):
|
||||
if existing_downloader and isinstance(existing_downloader, TorrentDownloader):
|
||||
existing_downloader.start_download(url, data['save_path'], "")
|
||||
existing_downloader.start_download(url, data['save_path'])
|
||||
else:
|
||||
torrent_downloader = TorrentDownloader(torrent_session)
|
||||
downloads[game_id] = torrent_downloader
|
||||
torrent_downloader.start_download(url, data['save_path'], "")
|
||||
torrent_downloader.start_download(url, data['save_path'])
|
||||
else:
|
||||
if existing_downloader and isinstance(existing_downloader, HttpDownloader):
|
||||
existing_downloader.start_download(url, data['save_path'], data.get('header'))
|
||||
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
|
||||
else:
|
||||
http_downloader = HttpDownloader()
|
||||
downloads[game_id] = http_downloader
|
||||
http_downloader.start_download(url, data['save_path'], data.get('header'))
|
||||
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
|
||||
|
||||
downloading_game_id = game_id
|
||||
|
||||
@ -167,7 +167,7 @@ def action():
|
||||
elif action == 'resume_seeding':
|
||||
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
|
||||
downloads[game_id] = torrent_downloader
|
||||
torrent_downloader.start_download(data['url'], data['save_path'], "")
|
||||
torrent_downloader.start_download(data['url'], data['save_path'])
|
||||
elif action == 'pause_seeding':
|
||||
downloader = downloads.get(game_id)
|
||||
if downloader:
|
||||
|
@ -102,7 +102,7 @@ class TorrentDownloader:
|
||||
"http://bvarf.tracker.sh:2086/announce",
|
||||
]
|
||||
|
||||
def start_download(self, magnet: str, save_path: str, header: str):
|
||||
def start_download(self, magnet: str, save_path: str):
|
||||
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers, 'flags': self.flags}
|
||||
self.torrent_handle = self.session.add_torrent(params)
|
||||
self.torrent_handle.resume()
|
||||
|
@ -236,13 +236,13 @@
|
||||
"behavior": "السلوك",
|
||||
"download_sources": "مصادر التنزيل",
|
||||
"language": "اللغة",
|
||||
"real_debrid_api_token": "رمز API",
|
||||
"api_token": "رمز API",
|
||||
"enable_real_debrid": "تفعيل Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid هو أداة تنزيل غير مقيدة تتيح لك تنزيل الملفات بسرعة، مقيدة فقط بسرعة الإنترنت لديك.",
|
||||
"real_debrid_invalid_token": "رمز API غير صالح",
|
||||
"real_debrid_api_token_hint": "يمكنك الحصول على رمز API الخاص بك <0>هنا</0>",
|
||||
"debrid_invalid_token": "رمز API غير صالح",
|
||||
"debrid_api_token_hint": "يمكنك الحصول على رمز API الخاص بك <0>هنا</0>",
|
||||
"real_debrid_free_account_error": "الحساب \"{{username}}\" هو حساب مجاني. يرجى الاشتراك في Real-Debrid",
|
||||
"real_debrid_linked_message": "تم ربط الحساب \"{{username}}\"",
|
||||
"debrid_linked_message": "تم ربط الحساب \"{{username}}\"",
|
||||
"save_changes": "حفظ التغييرات",
|
||||
"changes_saved": "تم حفظ التغييرات بنجاح",
|
||||
"download_sources_description": "سيقوم Hydra بجلب روابط التنزيل من هذه المصادر. يجب أن يكون عنوان URL المصدر رابطًا مباشرًا لملف .json يحتوي على روابط التنزيل.",
|
||||
|
@ -230,13 +230,13 @@
|
||||
"behavior": "Поведение",
|
||||
"download_sources": "Източници за изтегляне",
|
||||
"language": "Език",
|
||||
"real_debrid_api_token": "API Токен",
|
||||
"api_token": "API Токен",
|
||||
"enable_real_debrid": "Включи Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid е неограничен даунлоудър, който ви позволява бързо да изтегляте файлове, ограничени само от скоростта на интернет..",
|
||||
"real_debrid_invalid_token": "Невалиден API токен",
|
||||
"real_debrid_api_token_hint": "Вземете своя API токен <0>тук</0>",
|
||||
"debrid_invalid_token": "Невалиден API токен",
|
||||
"debrid_api_token_hint": "Вземете своя API токен <0>тук</0>",
|
||||
"real_debrid_free_account_error": "Акаунтът \"{{username}}\" е безплатен акаунт. Моля абонирай се за Real-Debrid",
|
||||
"real_debrid_linked_message": "Акаунтът \"{{username}}\" е свързан",
|
||||
"debrid_linked_message": "Акаунтът \"{{username}}\" е свързан",
|
||||
"save_changes": "Запази промените",
|
||||
"changes_saved": "Промените са успешно запазни",
|
||||
"download_sources_description": "Hydra ще извлича връзките за изтегляне от тези източници. URL адресът на източника трябва да е директна връзка към .json файл, съдържащ връзките за изтегляне.",
|
||||
|
@ -161,13 +161,13 @@
|
||||
"behavior": "Comportament",
|
||||
"download_sources": "Fonts de descàrrega",
|
||||
"language": "Idioma",
|
||||
"real_debrid_api_token": "Testimoni API",
|
||||
"api_token": "Testimoni API",
|
||||
"enable_real_debrid": "Activa el Real Debrid",
|
||||
"real_debrid_description": "Real-Debrid és un programa de descàrrega sense restriccions que us permet descarregar fitxers a l'instant i al màxim de la vostra velocitat d'Internet.",
|
||||
"real_debrid_invalid_token": "Invalida el testimoni de l'API",
|
||||
"real_debrid_api_token_hint": "Pots obtenir la teva clau de l'API <0>aquí</0>.",
|
||||
"debrid_invalid_token": "Invalida el testimoni de l'API",
|
||||
"debrid_api_token_hint": "Pots obtenir la teva clau de l'API <0>aquí</0>.",
|
||||
"real_debrid_free_account_error": "L'usuari \"{{username}}\" és un compte gratuït. Si us plau subscriu-te a Real-Debrid",
|
||||
"real_debrid_linked_message": "Compte \"{{username}}\" vinculat",
|
||||
"debrid_linked_message": "Compte \"{{username}}\" vinculat",
|
||||
"save_changes": "Desa els canvis",
|
||||
"changes_saved": "Els canvis s'han desat correctament",
|
||||
"download_sources_description": "Hydra buscarà els enllaços de descàrrega d'aquestes fonts. L'URL d'origen ha de ser un enllaç directe a un fitxer .json que contingui els enllaços de descàrrega.",
|
||||
|
@ -214,13 +214,13 @@
|
||||
"behavior": "Chování",
|
||||
"download_sources": "Zdroje stahování",
|
||||
"language": "Jazyk",
|
||||
"real_debrid_api_token": "API Token",
|
||||
"api_token": "API Token",
|
||||
"enable_real_debrid": "Povolit Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid je neomezený správce stahování, který umožňuje stahovat soubory v nejvyšší rychlosti vašeho internetu.",
|
||||
"real_debrid_invalid_token": "Neplatný API token",
|
||||
"real_debrid_api_token_hint": "API token můžeš sehnat <0>zde</0>",
|
||||
"debrid_invalid_token": "Neplatný API token",
|
||||
"debrid_api_token_hint": "API token můžeš sehnat <0>zde</0>",
|
||||
"real_debrid_free_account_error": "Účet \"{{username}}\" má základní úroveň. Prosím předplaťte si Real-Debrid",
|
||||
"real_debrid_linked_message": "Účet \"{{username}}\" je propojen",
|
||||
"debrid_linked_message": "Účet \"{{username}}\" je propojen",
|
||||
"save_changes": "Uložit změny",
|
||||
"changes_saved": "Změny úspěšně uloženy",
|
||||
"download_sources_description": "Hydra bude odsud sbírat soubory. Zdrojový odkaz musí být .json soubor obsahující odkazy na soubory.",
|
||||
|
@ -177,13 +177,13 @@
|
||||
"behavior": "Opførsel",
|
||||
"download_sources": "Download kilder",
|
||||
"language": "Sprog",
|
||||
"real_debrid_api_token": "API nøgle",
|
||||
"api_token": "API nøgle",
|
||||
"enable_real_debrid": "Slå Real-Debrid til",
|
||||
"real_debrid_description": "Real-Debrid er en ubegrænset downloader der gør det muligt for dig at downloade filer med det samme og med den bedste udnyttelse af din internet hastighed.",
|
||||
"real_debrid_invalid_token": "Ugyldig API nøgle",
|
||||
"real_debrid_api_token_hint": "Du kan få din API nøgle <0>her</0>",
|
||||
"debrid_invalid_token": "Ugyldig API nøgle",
|
||||
"debrid_api_token_hint": "Du kan få din API nøgle <0>her</0>",
|
||||
"real_debrid_free_account_error": "Brugeren \"{{username}}\" er en gratis bruger. Venligst abbonér på Real-Debrid",
|
||||
"real_debrid_linked_message": "Brugeren \"{{username}}\" er forbundet",
|
||||
"debrid_linked_message": "Brugeren \"{{username}}\" er forbundet",
|
||||
"save_changes": "Gem ændringer",
|
||||
"changes_saved": "Ændringer gemt successfuldt",
|
||||
"download_sources_description": "Hydra vil hente download links fra disse kilder. Kilde URLen skal være et direkte link til en .json fil der indeholder download linkene.",
|
||||
|
@ -161,13 +161,13 @@
|
||||
"behavior": "Verhalten",
|
||||
"download_sources": "Download-Quellen",
|
||||
"language": "Sprache",
|
||||
"real_debrid_api_token": "API Token",
|
||||
"api_token": "API Token",
|
||||
"enable_real_debrid": "Real-Debrid aktivieren",
|
||||
"real_debrid_description": "Real-Debrid ist ein unrestriktiver Downloader, der es dir ermöglicht Dateien sofort und mit deiner maximalen Internetgeschwindigkeit herunterzuladen.",
|
||||
"real_debrid_invalid_token": "API token nicht gültig",
|
||||
"real_debrid_api_token_hint": "<0>Hier</0> kannst du dir deinen API Token holen",
|
||||
"debrid_invalid_token": "API token nicht gültig",
|
||||
"debrid_api_token_hint": "<0>Hier</0> kannst du dir deinen API Token holen",
|
||||
"real_debrid_free_account_error": "Das Konto \"{{username}}\" ist ein gratis account. Bitte abonniere Real-Debrid",
|
||||
"real_debrid_linked_message": "Konto \"{{username}}\" verknüpft",
|
||||
"debrid_linked_message": "Konto \"{{username}}\" verknüpft",
|
||||
"save_changes": "Änderungen speichern",
|
||||
"changes_saved": "Änderungen erfolgreich gespeichert",
|
||||
"download_sources_description": "Hydra wird die Download-Links von diesen Quellen abrufen. Die Quell-URL muss ein direkter Link zu einer .json Datei, welche die Download-Links enthält, sein.",
|
||||
|
@ -184,7 +184,11 @@
|
||||
"reset_achievements_description": "This will reset all achievements for {{game}}",
|
||||
"reset_achievements_title": "Are you sure?",
|
||||
"reset_achievements_success": "Achievements successfully reset",
|
||||
"reset_achievements_error": "Failed to reset achievements"
|
||||
"reset_achievements_error": "Failed to reset achievements",
|
||||
"download_error_gofile_quota_exceeded": "You have exceeded your Gofile monthly quota. Please await the quota to reset.",
|
||||
"download_error_real_debrid_account_not_authorized": "Your Real-Debrid account is not authorized to make new downloads. Please check your account settings and try again.",
|
||||
"download_error_not_cached_in_real_debrid": "This download is not available on Real-Debrid and polling download status from Real-Debrid is not yet available.",
|
||||
"download_error_not_cached_in_torbox": "This download is not available on Torbox and polling download status from Torbox is not yet available."
|
||||
},
|
||||
"activation": {
|
||||
"title": "Activate Hydra",
|
||||
@ -236,13 +240,13 @@
|
||||
"behavior": "Behavior",
|
||||
"download_sources": "Download sources",
|
||||
"language": "Language",
|
||||
"real_debrid_api_token": "API Token",
|
||||
"api_token": "API Token",
|
||||
"enable_real_debrid": "Enable Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid is an unrestricted downloader that allows you to quickly download files, only limited by your internet speed.",
|
||||
"real_debrid_invalid_token": "Invalid API token",
|
||||
"real_debrid_api_token_hint": "You can get your API token <0>here</0>",
|
||||
"debrid_invalid_token": "Invalid API token",
|
||||
"debrid_api_token_hint": "You can get your API token <0>here</0>",
|
||||
"real_debrid_free_account_error": "The account \"{{username}}\" is a free account. Please subscribe to Real-Debrid",
|
||||
"real_debrid_linked_message": "Account \"{{username}}\" linked",
|
||||
"debrid_linked_message": "Account \"{{username}}\" linked",
|
||||
"save_changes": "Save changes",
|
||||
"changes_saved": "Changes successfully saved",
|
||||
"download_sources_description": "Hydra will fetch the download links from these sources. The source URL must be a direct link to a .json file containing the download links.",
|
||||
@ -296,7 +300,11 @@
|
||||
"become_subscriber": "Be Hydra Cloud",
|
||||
"subscription_renew_cancelled": "Automatic renewal is disabled",
|
||||
"subscription_renews_on": "Your subscription renews on {{date}}",
|
||||
"bill_sent_until": "Your next bill will be sent until this day"
|
||||
"bill_sent_until": "Your next bill will be sent until this day",
|
||||
"enable_torbox": "Enable Torbox",
|
||||
"torbox_description": "TorBox is your premium seedbox service rivaling even the best servers on the market.",
|
||||
"torbox_account_linked": "TorBox account linked",
|
||||
"real_debrid_account_linked": "Real-Debrid account linked"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download complete",
|
||||
|
@ -175,7 +175,16 @@
|
||||
"backup_from": "Copia de seguridad de {{date}}",
|
||||
"custom_backup_location_set": "Se configuró la carpeta de copia de seguridad",
|
||||
"clear": "Limpiar",
|
||||
"no_directory_selected": "No se seleccionó un directorio"
|
||||
"no_directory_selected": "No se seleccionó un directorio",
|
||||
"launch_options": "Opciones de Inicio",
|
||||
"launch_options_description": "Los usuarios avanzados pueden introducir sus propias modificaciones de opciones de inicio (característica experimental)",
|
||||
"launch_options_placeholder": "Sin parámetro específicado",
|
||||
"no_write_permission": "No se puede descargar en este directorio. Presiona aquí para aprender más.",
|
||||
"reset_achievements": "Reiniciar logros",
|
||||
"reset_achievements_description": "Esto reiniciará todos los logros de {{game}}",
|
||||
"reset_achievements_title": "¿Estás seguro?",
|
||||
"reset_achievements_success": "Logros reiniciados exitosamente",
|
||||
"reset_achievements_error": "Se produjo un error al reiniciar los logros"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Activar Hydra",
|
||||
@ -227,13 +236,13 @@
|
||||
"behavior": "Otros",
|
||||
"download_sources": "Fuentes de descarga",
|
||||
"language": "Idioma",
|
||||
"real_debrid_api_token": "Token API",
|
||||
"api_token": "Token API",
|
||||
"enable_real_debrid": "Activar Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid es una forma de descargar sin restricciones archivos instantáneamente con la máxima velocidad de tu internet.",
|
||||
"real_debrid_invalid_token": "Token de API inválido",
|
||||
"real_debrid_api_token_hint": "Puedes obtener tu clave de API <0>aquí</0>",
|
||||
"debrid_invalid_token": "Token de API inválido",
|
||||
"debrid_api_token_hint": "Puedes obtener tu clave de API <0>aquí</0>",
|
||||
"real_debrid_free_account_error": "La cuenta \"{{username}}\" es una cuenta gratuita. Por favor, suscríbete a Real-Debrid",
|
||||
"real_debrid_linked_message": "Cuenta \"{{username}}\" vinculada",
|
||||
"debrid_linked_message": "Cuenta \"{{username}}\" vinculada",
|
||||
"save_changes": "Guardar cambios",
|
||||
"changes_saved": "Ajustes guardados exitosamente",
|
||||
"download_sources_description": "Hydra buscará los enlaces de descarga de estas fuentes. La URL de origen debe ser un enlace directo a un archivo .json que contenga los enlaces de descarga",
|
||||
@ -271,7 +280,23 @@
|
||||
"launch_minimized": "Iniciar Hydra minimizado",
|
||||
"disable_nsfw_alert": "Desactivar alerta NSFW",
|
||||
"seed_after_download_complete": "Realizar seeding después de que se completa la descarga",
|
||||
"show_hidden_achievement_description": "Ocultar descripción de logros ocultos antes de desbloquearlos"
|
||||
"show_hidden_achievement_description": "Ocultar descripción de logros ocultos antes de desbloquearlos",
|
||||
"account": "Cuenta",
|
||||
"account_data_updated_successfully": "Datos de la cuenta actualizados",
|
||||
"bill_sent_until": "Tú próxima factura se enviará el {{date}}",
|
||||
"current_email": "Correo actual:",
|
||||
"manage_subscription": "Gestionar suscripción",
|
||||
"no_email_account": "No has configurado un correo aún",
|
||||
"no_subscription": "Disfruta Hydra de la mejor manera",
|
||||
"no_users_blocked": "No tienes usuarios bloqueados",
|
||||
"notifications": "Notificaciones",
|
||||
"renew_subscription": "Renovar Hydra Cloud",
|
||||
"subscription_active_until": "Tu Hydra Cloud está activa hasta {{date}}",
|
||||
"subscription_expired_at": "Tú suscripción expiró el {{date}}",
|
||||
"subscription_renew_cancelled": "Está desactivada la renovación automática",
|
||||
"subscription_renews_on": "Tú suscripción se renueva el {{date}}",
|
||||
"update_email": "Actualizar correo",
|
||||
"update_password": "Actualizar contraseña"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Descarga completada",
|
||||
|
@ -213,13 +213,13 @@
|
||||
"behavior": "Käitumine",
|
||||
"download_sources": "Allalaadimise allikad",
|
||||
"language": "Keel",
|
||||
"real_debrid_api_token": "API Võti",
|
||||
"api_token": "API Võti",
|
||||
"enable_real_debrid": "Luba Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid on piiranguteta allalaadija, mis võimaldab sul faile alla laadida koheselt ja sinu internetiühenduse parima kiirusega.",
|
||||
"real_debrid_invalid_token": "Vigane API võti",
|
||||
"real_debrid_api_token_hint": "Sa saad oma API võtme <0>siit</0>",
|
||||
"debrid_invalid_token": "Vigane API võti",
|
||||
"debrid_api_token_hint": "Sa saad oma API võtme <0>siit</0>",
|
||||
"real_debrid_free_account_error": "Konto \"{{username}}\" on tasuta konto. Palun telli Real-Debrid",
|
||||
"real_debrid_linked_message": "Konto \"{{username}}\" ühendatud",
|
||||
"debrid_linked_message": "Konto \"{{username}}\" ühendatud",
|
||||
"save_changes": "Salvesta muudatused",
|
||||
"changes_saved": "Muudatused edukalt salvestatud",
|
||||
"download_sources_description": "Hydra laeb allalaadimise lingid nendest allikatest. Allika URL peab olema otsene link .json failile, mis sisaldab allalaadimise linke.",
|
||||
|
@ -110,7 +110,7 @@
|
||||
"general": "کلی",
|
||||
"behavior": "رفتار",
|
||||
"enable_real_debrid": "فعالسازی Real-Debrid",
|
||||
"real_debrid_api_token_hint": "کلید API خود را از <ب0>اینجا</0> بگیرید.",
|
||||
"debrid_api_token_hint": "کلید API خود را از <ب0>اینجا</0> بگیرید.",
|
||||
"save_changes": "ذخیره تغییرات"
|
||||
},
|
||||
"notifications": {
|
||||
|
@ -161,13 +161,13 @@
|
||||
"behavior": "Perilaku",
|
||||
"download_sources": "Sumber unduhan",
|
||||
"language": "Bahasa",
|
||||
"real_debrid_api_token": "Token API",
|
||||
"api_token": "Token API",
|
||||
"enable_real_debrid": "Aktifkan Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid adalah downloader tanpa batas yang memungkinkan kamu untuk mengunduh file dengan cepat dan pada kecepatan terbaik dari Internet kamu.",
|
||||
"real_debrid_invalid_token": "Token API tidak valid",
|
||||
"real_debrid_api_token_hint": "Kamu bisa dapatkan token API di <0>sini</0>",
|
||||
"debrid_invalid_token": "Token API tidak valid",
|
||||
"debrid_api_token_hint": "Kamu bisa dapatkan token API di <0>sini</0>",
|
||||
"real_debrid_free_account_error": "Akun \"{{username}}\" adalah akun gratis. Silakan berlangganan Real-Debrid",
|
||||
"real_debrid_linked_message": "Akun \"{{username}}\" terhubung",
|
||||
"debrid_linked_message": "Akun \"{{username}}\" terhubung",
|
||||
"save_changes": "Simpan perubahan",
|
||||
"changes_saved": "Perubahan disimpan berhasil",
|
||||
"download_sources_description": "Hydra akan mencari link unduhan dari sini. URL harus menuju file .json dengan link unduhan.",
|
||||
|
@ -118,7 +118,7 @@
|
||||
"general": "Generale",
|
||||
"behavior": "Comportamento",
|
||||
"enable_real_debrid": "Abilita Real Debrid",
|
||||
"real_debrid_api_token_hint": "Puoi trovare la tua chiave API <0>here</0>",
|
||||
"debrid_api_token_hint": "Puoi trovare la tua chiave API <0>here</0>",
|
||||
"save_changes": "Salva modifiche"
|
||||
},
|
||||
"notifications": {
|
||||
|
@ -159,13 +159,13 @@
|
||||
"behavior": "Мінез-құлық",
|
||||
"download_sources": "Жүктеу көздері",
|
||||
"language": "Тіл",
|
||||
"real_debrid_api_token": "API Кілті",
|
||||
"api_token": "API Кілті",
|
||||
"enable_real_debrid": "Real-Debrid-ті қосу",
|
||||
"real_debrid_description": "Real-Debrid - бұл шектеусіз жүктеуші, ол интернетте орналастырылған файлдарды тез жүктеуге немесе жеке желі арқылы кез келген блоктарды айналып өтіп, оларды бірден плеерге беруге мүмкіндік береді.",
|
||||
"real_debrid_invalid_token": "Қате API кілті",
|
||||
"real_debrid_api_token_hint": "API кілтін <0>осы жерден</0> алуға болады",
|
||||
"debrid_invalid_token": "Қате API кілті",
|
||||
"debrid_api_token_hint": "API кілтін <0>осы жерден</0> алуға болады",
|
||||
"real_debrid_free_account_error": "\"{{username}}\" аккаунты жазылымға ие емес. Real-Debrid жазылымын алыңыз",
|
||||
"real_debrid_linked_message": "\"{{username}}\" аккаунты байланған",
|
||||
"debrid_linked_message": "\"{{username}}\" аккаунты байланған",
|
||||
"save_changes": "Өзгерістерді сақтау",
|
||||
"changes_saved": "Өзгерістер сәтті сақталды",
|
||||
"download_sources_description": "Hydra осы көздерден жүктеу сілтемелерін алады. URL-да жүктеу сілтемелері бар .json файлына тікелей сілтеме болуы керек.",
|
||||
|
@ -110,7 +110,7 @@
|
||||
"general": "일반",
|
||||
"behavior": "행동",
|
||||
"enable_real_debrid": "Real-Debrid 활성화",
|
||||
"real_debrid_api_token_hint": "API 키를 <0>이곳</0>에서 얻으세요.",
|
||||
"debrid_api_token_hint": "API 키를 <0>이곳</0>에서 얻으세요.",
|
||||
"save_changes": "변경 사항 저장"
|
||||
},
|
||||
"notifications": {
|
||||
|
@ -177,13 +177,13 @@
|
||||
"behavior": "Oppførsel",
|
||||
"download_sources": "Nedlastingskilder",
|
||||
"language": "Språk",
|
||||
"real_debrid_api_token": "API nøkkel",
|
||||
"api_token": "API nøkkel",
|
||||
"enable_real_debrid": "Slå på Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid er en ubegrenset nedlaster som gør det mulig for deg å laste ned filer med en gang og med den beste utnyttelsen av internethastigheten din.",
|
||||
"real_debrid_invalid_token": "Ugyldig API nøkkel",
|
||||
"real_debrid_api_token_hint": "Du kan få API nøkkelen din <0>her</0>",
|
||||
"debrid_invalid_token": "Ugyldig API nøkkel",
|
||||
"debrid_api_token_hint": "Du kan få API nøkkelen din <0>her</0>",
|
||||
"real_debrid_free_account_error": "Brukeren \"{{username}}\" er en gratis bruker. Vennligst abboner på Real-Debrid",
|
||||
"real_debrid_linked_message": "Brukeren \"{{username}}\" er forbunnet",
|
||||
"debrid_linked_message": "Brukeren \"{{username}}\" er forbunnet",
|
||||
"save_changes": "Lagre endringer",
|
||||
"changes_saved": "Lagring av endringer vellykket",
|
||||
"download_sources_description": "Hydra vil hente nedlastingslenker fra disse kildene. Kilde URLen skal være en direkte lenke til en .json fil som inneholder nedlastingslenkene.",
|
||||
|
@ -111,7 +111,7 @@
|
||||
"general": "Algemeen",
|
||||
"behavior": "Gedrag",
|
||||
"enable_real_debrid": "Enable Real-Debrid",
|
||||
"real_debrid_api_token_hint": "U kunt uw API-sleutel <0>hier</0> verkrijgen.",
|
||||
"debrid_api_token_hint": "U kunt uw API-sleutel <0>hier</0> verkrijgen.",
|
||||
"save_changes": "Wijzigingen opslaan"
|
||||
},
|
||||
"notifications": {
|
||||
|
@ -119,7 +119,7 @@
|
||||
"behavior": "Zachowania",
|
||||
"language": "Język",
|
||||
"enable_real_debrid": "Włącz Real-Debrid",
|
||||
"real_debrid_api_token_hint": "Możesz uzyskać swój klucz API <0>tutaj</0>",
|
||||
"debrid_api_token_hint": "Możesz uzyskać swój klucz API <0>tutaj</0>",
|
||||
"save_changes": "Zapisz zmiany"
|
||||
},
|
||||
"notifications": {
|
||||
|
@ -172,7 +172,12 @@
|
||||
"reset_achievements_description": "Isso irá resetar todas as conquistas de {{game}}",
|
||||
"reset_achievements_title": "Tem certeza?",
|
||||
"reset_achievements_success": "Conquistas resetadas com sucesso",
|
||||
"reset_achievements_error": "Falha ao resetar conquistas"
|
||||
"reset_achievements_error": "Falha ao resetar conquistas",
|
||||
"no_write_permission": "Não é possível baixar nesse diretório. Clique aqui para saber mais.",
|
||||
"download_error_gofile_quota_exceeded": "Você excedeu sua cota mensal do Gofile. Por favor, aguarde a cota resetar.",
|
||||
"download_error_real_debrid_account_not_authorized": "Sua conta do Real-Debrid não está autorizada a fazer novos downloads. Por favor, verifique sua assinatura e tente novamente.",
|
||||
"download_error_not_cached_in_real_debrid": "Este download não está disponível no Real-Debrid e a verificação do status do download não está disponível.",
|
||||
"download_error_not_cached_in_torbox": "Este download não está disponível no Torbox e a verificação do status do download não está disponível."
|
||||
},
|
||||
"activation": {
|
||||
"title": "Ativação",
|
||||
@ -224,13 +229,13 @@
|
||||
"behavior": "Comportamento",
|
||||
"download_sources": "Fontes de download",
|
||||
"language": "Idioma",
|
||||
"real_debrid_api_token": "Token de API",
|
||||
"api_token": "Token de API",
|
||||
"enable_real_debrid": "Habilitar Real-Debrid",
|
||||
"real_debrid_api_token_hint": "Você pode obter seu token de API <0>aqui</0>",
|
||||
"debrid_api_token_hint": "Você pode obter seu token de API <0>aqui</0>",
|
||||
"real_debrid_description": "O Real-Debrid é um downloader sem restrições que permite baixar arquivos instantaneamente e com a melhor velocidade da sua Internet.",
|
||||
"real_debrid_invalid_token": "Token de API inválido",
|
||||
"debrid_invalid_token": "Token de API inválido",
|
||||
"real_debrid_free_account_error": "A conta \"{{username}}\" é uma conta gratuita. Por favor, assine a Real-Debrid",
|
||||
"real_debrid_linked_message": "Conta \"{{username}}\" vinculada",
|
||||
"debrid_linked_message": "Conta \"{{username}}\" vinculada",
|
||||
"save_changes": "Salvar mudanças",
|
||||
"changes_saved": "Ajustes salvos com sucesso",
|
||||
"download_sources_description": "Hydra vai buscar links de download em todas as fontes habilitadas. A URL da fonte deve ser um link direto para um arquivo .json contendo uma lista de links.",
|
||||
@ -284,7 +289,11 @@
|
||||
"become_subscriber": "Seja Hydra Cloud",
|
||||
"subscription_renew_cancelled": "A renovação automática está desativada",
|
||||
"subscription_renews_on": "Sua assinatura renova dia {{date}}",
|
||||
"bill_sent_until": "Sua próxima cobrança será enviada até esse dia"
|
||||
"bill_sent_until": "Sua próxima cobrança será enviada até esse dia",
|
||||
"enable_torbox": "Habilitar Torbox",
|
||||
"torbox_description": "TorBox é o seu serviço de seedbox premium que rivaliza até com os melhores servidores do mercado.",
|
||||
"torbox_account_linked": "Conta do TorBox vinculada",
|
||||
"real_debrid_account_linked": "Conta Real-Debrid associada"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download concluído",
|
||||
|
@ -205,13 +205,13 @@
|
||||
"behavior": "Comportamento",
|
||||
"download_sources": "Fontes de transferência",
|
||||
"language": "Idioma",
|
||||
"real_debrid_api_token": "Token de API",
|
||||
"api_token": "Token de API",
|
||||
"enable_real_debrid": "Ativar Real-Debrid",
|
||||
"real_debrid_api_token_hint": "Podes obter o teu token de API <0>aqui</0>",
|
||||
"debrid_api_token_hint": "Podes obter o teu token de API <0>aqui</0>",
|
||||
"real_debrid_description": "O Real-Debrid é um downloader sem restrições que permite descarregar ficheiros instantaneamente e com a melhor velocidade da tua Internet.",
|
||||
"real_debrid_invalid_token": "Token de API inválido",
|
||||
"debrid_invalid_token": "Token de API inválido",
|
||||
"real_debrid_free_account_error": "A conta \"{{username}}\" é uma conta gratuita. Por favor, subscreve o Real-Debrid",
|
||||
"real_debrid_linked_message": "Conta \"{{username}}\" associada",
|
||||
"debrid_linked_message": "Conta \"{{username}}\" associada",
|
||||
"save_changes": "Guardar alterações",
|
||||
"changes_saved": "Alterações guardadas com sucesso",
|
||||
"download_sources_description": "O Hydra vai procurar links de download em todas as fontes ativadas. O URL da fonte deve ser um link direto para um ficheiro .json que contenha uma lista de links.",
|
||||
|
@ -124,13 +124,13 @@
|
||||
"general": "General",
|
||||
"behavior": "Comportament",
|
||||
"language": "Limbă",
|
||||
"real_debrid_api_token": "Token API",
|
||||
"api_token": "Token API",
|
||||
"enable_real_debrid": "Activează Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid este un descărcător fără restricții care îți permite să descarci fișiere instantaneu și la cea mai bună viteză a internetului tău.",
|
||||
"real_debrid_invalid_token": "Token API invalid",
|
||||
"real_debrid_api_token_hint": "Poți obține token-ul tău API <0>aici</0>",
|
||||
"debrid_invalid_token": "Token API invalid",
|
||||
"debrid_api_token_hint": "Poți obține token-ul tău API <0>aici</0>",
|
||||
"real_debrid_free_account_error": "Contul \"{{username}}\" este un cont gratuit. Te rugăm să te abonezi la Real-Debrid",
|
||||
"real_debrid_linked_message": "Contul \"{{username}}\" a fost legat",
|
||||
"debrid_linked_message": "Contul \"{{username}}\" a fost legat",
|
||||
"save_changes": "Salvează modificările",
|
||||
"changes_saved": "Modificările au fost salvate cu succes"
|
||||
},
|
||||
|
@ -237,13 +237,13 @@
|
||||
"behavior": "Поведение",
|
||||
"download_sources": "Источники загрузки",
|
||||
"language": "Язык",
|
||||
"real_debrid_api_token": "API Ключ",
|
||||
"api_token": "API Ключ",
|
||||
"enable_real_debrid": "Включить Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid - это неограниченный загрузчик, который позволяет быстро скачивать файлы, размещенные в Интернете, или мгновенно передавать их в плеер через частную сеть, позволяющую обходить любые блокировки.",
|
||||
"real_debrid_invalid_token": "Неверный API ключ",
|
||||
"real_debrid_api_token_hint": "API ключ можно получить <0>здесь</0>",
|
||||
"debrid_invalid_token": "Неверный API ключ",
|
||||
"debrid_api_token_hint": "API ключ можно получить <0>здесь</0>",
|
||||
"real_debrid_free_account_error": "Аккаунт \"{{username}}\" - не имеет подписки. Пожалуйста, оформите подписку на Real-Debrid",
|
||||
"real_debrid_linked_message": "Привязан аккаунт \"{{username}}\"",
|
||||
"debrid_linked_message": "Привязан аккаунт \"{{username}}\"",
|
||||
"save_changes": "Сохранить изменения",
|
||||
"changes_saved": "Изменения успешно сохранены",
|
||||
"download_sources_description": "Hydra будет получать ссылки на загрузки из этих источников. URL должна содержать прямую ссылку на .json-файл с ссылками для загрузок.",
|
||||
|
@ -236,13 +236,13 @@
|
||||
"behavior": "Davranış",
|
||||
"download_sources": "İndirme kaynakları",
|
||||
"language": "Dil",
|
||||
"real_debrid_api_token": "API Anahtarı",
|
||||
"api_token": "API Anahtarı",
|
||||
"enable_real_debrid": "Real-Debrid'i Etkinleştir",
|
||||
"real_debrid_description": "Real-Debrid, yalnızca internet hızınızla sınırlı olarak hızlı dosya indirmenizi sağlayan sınırsız bir indirici.",
|
||||
"real_debrid_invalid_token": "Geçersiz API anahtarı",
|
||||
"real_debrid_api_token_hint": "API anahtarınızı <0>buradan</0> alabilirsiniz",
|
||||
"debrid_invalid_token": "Geçersiz API anahtarı",
|
||||
"debrid_api_token_hint": "API anahtarınızı <0>buradan</0> alabilirsiniz",
|
||||
"real_debrid_free_account_error": "\"{{username}}\" hesabı ücretsiz bir hesaptır. Lütfen Real-Debrid abonesi olun",
|
||||
"real_debrid_linked_message": "\"{{username}}\" hesabı bağlandı",
|
||||
"debrid_linked_message": "\"{{username}}\" hesabı bağlandı",
|
||||
"save_changes": "Değişiklikleri Kaydet",
|
||||
"changes_saved": "Değişiklikler başarıyla kaydedildi",
|
||||
"download_sources_description": "Hydra, indirme bağlantılarını bu kaynaklardan alacak. Kaynak URL, indirme bağlantılarını içeren bir .json dosyasına doğrudan bir bağlantı olmalıdır.",
|
||||
|
@ -174,13 +174,13 @@
|
||||
"import": "Імпортувати",
|
||||
"insert_valid_json_url": "Вставте дійсний URL JSON-файлу",
|
||||
"language": "Мова",
|
||||
"real_debrid_api_token": "API-токен",
|
||||
"real_debrid_api_token_hint": "API токен можливо отримати <0>тут</0>",
|
||||
"api_token": "API-токен",
|
||||
"debrid_api_token_hint": "API токен можливо отримати <0>тут</0>",
|
||||
"real_debrid_api_token_label": "Real-Debrid API-токен",
|
||||
"real_debrid_description": "Real-Debrid — це необмежений завантажувач, який дозволяє швидко завантажувати файли, розміщені в Інтернеті, або миттєво передавати їх у плеєр через приватну мережу, що дозволяє обходити будь-які блокування.",
|
||||
"real_debrid_free_account_error": "Акаунт \"{{username}}\" - не має наявної підписки. Будь ласка, оформіть підписку на Real-Debrid",
|
||||
"real_debrid_invalid_token": "Невірний API-токен",
|
||||
"real_debrid_linked_message": "Акаунт \"{{username}}\" привязаний",
|
||||
"debrid_invalid_token": "Невірний API-токен",
|
||||
"debrid_linked_message": "Акаунт \"{{username}}\" привязаний",
|
||||
"remove_download_source": "Видалити",
|
||||
"removed_download_source": "Джерело завантажень було видалено",
|
||||
"save_changes": "Зберегти зміни",
|
||||
|
@ -213,13 +213,13 @@
|
||||
"behavior": "行为",
|
||||
"download_sources": "下载源",
|
||||
"language": "语言",
|
||||
"real_debrid_api_token": "API 令牌",
|
||||
"api_token": "API 令牌",
|
||||
"enable_real_debrid": "启用 Real-Debrid",
|
||||
"real_debrid_description": "Real-Debrid 是一个无限制的下载器,允许您以最快的互联网速度即时下载文件。",
|
||||
"real_debrid_invalid_token": "无效的 API 令牌",
|
||||
"real_debrid_api_token_hint": "您可以从<0>这里</0>获取API密钥.",
|
||||
"debrid_invalid_token": "无效的 API 令牌",
|
||||
"debrid_api_token_hint": "您可以从<0>这里</0>获取API密钥.",
|
||||
"real_debrid_free_account_error": "账户 \"{{username}}\" 是免费账户。请订阅 Real-Debrid",
|
||||
"real_debrid_linked_message": "账户 \"{{username}}\" 已链接",
|
||||
"debrid_linked_message": "账户 \"{{username}}\" 已链接",
|
||||
"save_changes": "保存更改",
|
||||
"changes_saved": "更改已成功保存",
|
||||
"download_sources_description": "Hydra 将从这些源获取下载链接。源 URL 必须是直接链接到包含下载链接的 .json 文件。",
|
||||
|
@ -7,13 +7,18 @@ export const defaultDownloadsPath = app.getPath("downloads");
|
||||
|
||||
export const isStaging = import.meta.env.MAIN_VITE_API_URL.includes("staging");
|
||||
|
||||
export const levelDatabasePath = path.join(
|
||||
app.getPath("userData"),
|
||||
`hydra-db${isStaging ? "-staging" : ""}`
|
||||
);
|
||||
|
||||
export const databaseDirectory = path.join(app.getPath("appData"), "hydra");
|
||||
export const databasePath = path.join(
|
||||
databaseDirectory,
|
||||
isStaging ? "hydra_test.db" : "hydra.db"
|
||||
);
|
||||
|
||||
export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
|
||||
export const logsPath = path.join(app.getPath("userData"), "logs");
|
||||
|
||||
export const seedsPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, "seeds")
|
||||
|
@ -1,27 +0,0 @@
|
||||
import { DataSource } from "typeorm";
|
||||
import {
|
||||
DownloadQueue,
|
||||
Game,
|
||||
GameShopCache,
|
||||
UserPreferences,
|
||||
UserAuth,
|
||||
GameAchievement,
|
||||
UserSubscription,
|
||||
} from "@main/entity";
|
||||
|
||||
import { databasePath } from "./constants";
|
||||
|
||||
export const dataSource = new DataSource({
|
||||
type: "better-sqlite3",
|
||||
entities: [
|
||||
Game,
|
||||
UserAuth,
|
||||
UserPreferences,
|
||||
UserSubscription,
|
||||
GameShopCache,
|
||||
DownloadQueue,
|
||||
GameAchievement,
|
||||
],
|
||||
synchronize: false,
|
||||
database: databasePath,
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
OneToOne,
|
||||
JoinColumn,
|
||||
} from "typeorm";
|
||||
import type { Game } from "./game.entity";
|
||||
|
||||
@Entity("download_queue")
|
||||
export class DownloadQueue {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@OneToOne("Game", "downloadQueue")
|
||||
@JoinColumn()
|
||||
game: Game;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity("game_achievement")
|
||||
export class GameAchievement {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column("text")
|
||||
objectId: string;
|
||||
|
||||
@Column("text")
|
||||
shop: string;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
unlockedAchievements: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
achievements: string | null;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
@Entity("game_shop_cache")
|
||||
export class GameShopCache {
|
||||
@PrimaryColumn("text", { unique: true })
|
||||
objectID: string;
|
||||
|
||||
@Column("text")
|
||||
shop: GameShop;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
serializedData: string;
|
||||
|
||||
/**
|
||||
* @deprecated Use IndexedDB's `howLongToBeatEntries` instead
|
||||
*/
|
||||
@Column("text", { nullable: true })
|
||||
howLongToBeatSerializedData: string;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
language: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
OneToOne,
|
||||
} from "typeorm";
|
||||
|
||||
import type { GameShop, GameStatus } from "@types";
|
||||
import { Downloader } from "@shared";
|
||||
import type { DownloadQueue } from "./download-queue.entity";
|
||||
|
||||
@Entity("game")
|
||||
export class Game {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column("text", { unique: true })
|
||||
objectID: string;
|
||||
|
||||
@Column("text", { unique: true, nullable: true })
|
||||
remoteId: string | null;
|
||||
|
||||
@Column("text")
|
||||
title: string;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
iconUrl: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
folderName: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
downloadPath: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
executablePath: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
launchOptions: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
winePrefixPath: string | null;
|
||||
|
||||
@Column("int", { default: 0 })
|
||||
playTimeInMilliseconds: number;
|
||||
|
||||
@Column("text")
|
||||
shop: GameShop;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
status: GameStatus | null;
|
||||
|
||||
@Column("int", { default: Downloader.Torrent })
|
||||
downloader: Downloader;
|
||||
|
||||
/**
|
||||
* Progress is a float between 0 and 1
|
||||
*/
|
||||
@Column("float", { default: 0 })
|
||||
progress: number;
|
||||
|
||||
@Column("int", { default: 0 })
|
||||
bytesDownloaded: number;
|
||||
|
||||
@Column("datetime", { nullable: true })
|
||||
lastTimePlayed: Date | null;
|
||||
|
||||
@Column("float", { default: 0 })
|
||||
fileSize: number;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
uri: string | null;
|
||||
|
||||
@OneToOne("DownloadQueue", "game")
|
||||
downloadQueue: DownloadQueue;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
isDeleted: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
shouldSeed: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
export * from "./game.entity";
|
||||
export * from "./user-auth.entity";
|
||||
export * from "./user-preferences.entity";
|
||||
export * from "./user-subscription.entity";
|
||||
export * from "./game-shop-cache.entity";
|
||||
export * from "./game.entity";
|
||||
export * from "./game-achievements.entity";
|
||||
export * from "./download-queue.entity";
|
@ -1,45 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
OneToOne,
|
||||
} from "typeorm";
|
||||
import { UserSubscription } from "./user-subscription.entity";
|
||||
|
||||
@Entity("user_auth")
|
||||
export class UserAuth {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
userId: string;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
displayName: string;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
profileImageUrl: string | null;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
backgroundImageUrl: string | null;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
accessToken: string;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
refreshToken: string;
|
||||
|
||||
@Column("int", { default: 0 })
|
||||
tokenExpirationTimestamp: number;
|
||||
|
||||
@OneToOne("UserSubscription", "user")
|
||||
subscription: UserSubscription | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
|
||||
@Entity("user_preferences")
|
||||
export class UserPreferences {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
downloadsPath: string | null;
|
||||
|
||||
@Column("text", { default: "en" })
|
||||
language: string;
|
||||
|
||||
@Column("text", { nullable: true })
|
||||
realDebridApiToken: string | null;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
downloadNotificationsEnabled: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
repackUpdatesNotificationsEnabled: boolean;
|
||||
|
||||
@Column("boolean", { default: true })
|
||||
achievementNotificationsEnabled: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
preferQuitInsteadOfHiding: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
runAtStartup: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
startMinimized: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
disableNsfwAlert: boolean;
|
||||
|
||||
@Column("boolean", { default: true })
|
||||
seedAfterDownloadComplete: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
showHiddenAchievementsDescription: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
import type { SubscriptionStatus } from "@types";
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
OneToOne,
|
||||
JoinColumn,
|
||||
} from "typeorm";
|
||||
import { UserAuth } from "./user-auth.entity";
|
||||
|
||||
@Entity("user_subscription")
|
||||
export class UserSubscription {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
subscriptionId: string;
|
||||
|
||||
@OneToOne("UserAuth", "subscription")
|
||||
@JoinColumn()
|
||||
user: UserAuth;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
status: SubscriptionStatus;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
planId: string;
|
||||
|
||||
@Column("text", { default: "" })
|
||||
planName: string;
|
||||
|
||||
@Column("datetime", { nullable: true })
|
||||
expiresAt: Date | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
@ -1,13 +1,19 @@
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import type { Auth } from "@types";
|
||||
import { Crypto } from "@main/services";
|
||||
|
||||
const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const auth = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
const auth = await db.get<string, Auth>(levelKeys.auth, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
if (!auth) return null;
|
||||
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;
|
||||
const payload = jwt.decode(
|
||||
Crypto.decrypt(auth.accessToken)
|
||||
) as jwt.JwtPayload;
|
||||
|
||||
if (!payload) return null;
|
||||
|
||||
|
@ -1,35 +1,29 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { DownloadManager, HydraApi, gamesPlaytime } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game, UserAuth, UserSubscription } from "@main/entity";
|
||||
import { PythonRPC } from "@main/services/python-rpc";
|
||||
import { db, downloadsSublevel, gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const databaseOperations = dataSource
|
||||
.transaction(async (transactionalEntityManager) => {
|
||||
await transactionalEntityManager.getRepository(DownloadQueue).delete({});
|
||||
|
||||
await transactionalEntityManager.getRepository(Game).delete({});
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(UserAuth)
|
||||
.delete({ id: 1 });
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(UserSubscription)
|
||||
.delete({ id: 1 });
|
||||
})
|
||||
const databaseOperations = db
|
||||
.batch([
|
||||
{
|
||||
type: "del",
|
||||
key: levelKeys.auth,
|
||||
},
|
||||
{
|
||||
type: "del",
|
||||
key: levelKeys.user,
|
||||
},
|
||||
])
|
||||
.then(() => {
|
||||
/* Removes all games being played */
|
||||
gamesPlaytime.clear();
|
||||
|
||||
return Promise.all([gamesSublevel.clear(), downloadsSublevel.clear()]);
|
||||
});
|
||||
|
||||
/* Cancels any ongoing downloads */
|
||||
DownloadManager.cancelDownload();
|
||||
|
||||
/* Disconnects libtorrent */
|
||||
PythonRPC.kill();
|
||||
|
||||
HydraApi.handleSignOut();
|
||||
|
||||
await Promise.all([
|
||||
|
@ -1,47 +1,8 @@
|
||||
import type { AppUpdaterEvent } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import updater, { UpdateInfo } from "electron-updater";
|
||||
import { WindowManager } from "@main/services";
|
||||
import { app } from "electron";
|
||||
import { publishNotificationUpdateReadyToInstall } from "@main/services/notifications";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
const sendEvent = (event: AppUpdaterEvent) => {
|
||||
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
||||
};
|
||||
|
||||
const sendEventsForDebug = false;
|
||||
|
||||
const isAutoInstallAvailable =
|
||||
process.platform !== "darwin" && process.env.PORTABLE_EXECUTABLE_FILE == null;
|
||||
|
||||
const mockValuesForDebug = () => {
|
||||
sendEvent({ type: "update-available", info: { version: "1.3.0" } });
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
};
|
||||
|
||||
const newVersionInfo = { version: "" };
|
||||
import { UpdateManager } from "@main/services/update-manager";
|
||||
|
||||
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
autoUpdater
|
||||
.once("update-available", (info: UpdateInfo) => {
|
||||
sendEvent({ type: "update-available", info });
|
||||
newVersionInfo.version = info.version;
|
||||
})
|
||||
.once("update-downloaded", () => {
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
publishNotificationUpdateReadyToInstall(newVersionInfo.version);
|
||||
});
|
||||
|
||||
if (app.isPackaged) {
|
||||
autoUpdater.autoDownload = isAutoInstallAvailable;
|
||||
autoUpdater.checkForUpdates();
|
||||
} else if (sendEventsForDebug) {
|
||||
mockValuesForDebug();
|
||||
}
|
||||
|
||||
return isAutoInstallAvailable;
|
||||
return UpdateManager.checkForUpdates();
|
||||
};
|
||||
|
||||
registerEvent("checkForUpdates", checkForUpdates);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { gameShopCacheRepository } from "@main/repository";
|
||||
import { getSteamAppDetails } from "@main/services";
|
||||
import { getSteamAppDetails, logger } from "@main/services";
|
||||
|
||||
import type { ShopDetails, GameShop, SteamAppDetails } from "@types";
|
||||
import type { ShopDetails, GameShop } from "@types";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { steamGamesWorker } from "@main/workers";
|
||||
import { gamesShopCacheSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const getLocalizedSteamAppDetails = async (
|
||||
objectId: string,
|
||||
@ -39,35 +39,27 @@ const getGameShopDetails = async (
|
||||
language: string
|
||||
): Promise<ShopDetails | null> => {
|
||||
if (shop === "steam") {
|
||||
const cachedData = await gameShopCacheRepository.findOne({
|
||||
where: { objectID: objectId, language },
|
||||
});
|
||||
const cachedData = await gamesShopCacheSublevel.get(
|
||||
levelKeys.gameShopCacheItem(shop, objectId, language)
|
||||
);
|
||||
|
||||
const appDetails = getLocalizedSteamAppDetails(objectId, language).then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
gameShopCacheRepository.upsert(
|
||||
{
|
||||
objectID: objectId,
|
||||
shop: "steam",
|
||||
language,
|
||||
serializedData: JSON.stringify(result),
|
||||
},
|
||||
["objectID"]
|
||||
);
|
||||
gamesShopCacheSublevel
|
||||
.put(levelKeys.gameShopCacheItem(shop, objectId, language), result)
|
||||
.catch((err) => {
|
||||
logger.error("Could not cache game details", err);
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
);
|
||||
|
||||
const cachedGame = cachedData?.serializedData
|
||||
? (JSON.parse(cachedData?.serializedData) as SteamAppDetails)
|
||||
: null;
|
||||
|
||||
if (cachedGame) {
|
||||
if (cachedData) {
|
||||
return {
|
||||
...cachedGame,
|
||||
...cachedData,
|
||||
objectId,
|
||||
} as ShopDetails;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import type { TrendingGame } from "@types";
|
||||
|
||||
const getTrendingGames = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
|
||||
const language = userPreferences?.language || "en";
|
||||
const language = await db
|
||||
.get<string, string>(levelKeys.language, {
|
||||
valueEncoding: "utf-8",
|
||||
})
|
||||
.then((language) => language || "en");
|
||||
|
||||
const trendingGames = await HydraApi.get<TrendingGame[]>(
|
||||
"/games/trending",
|
||||
|
@ -1,19 +1,14 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import type { GameShop } from "@types";
|
||||
import { Ludusavi } from "@main/services";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const getGameBackupPreview = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
objectId: string,
|
||||
shop: GameShop
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
objectID: objectId,
|
||||
shop,
|
||||
},
|
||||
});
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
return Ludusavi.getBackupPreview(shop, objectId, game?.winePrefixPath);
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ import os from "node:os";
|
||||
import { backupsPath } from "@main/constants";
|
||||
import { app } from "electron";
|
||||
import { normalizePath } from "@main/helpers";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const bundleBackup = async (
|
||||
shop: GameShop,
|
||||
@ -46,12 +46,7 @@ const uploadSaveGame = async (
|
||||
shop: GameShop,
|
||||
downloadOptionTitle: string | null
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
objectID: objectId,
|
||||
shop,
|
||||
},
|
||||
});
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
const bundleLocation = await bundleBackup(
|
||||
shop,
|
||||
|
@ -1,15 +1,21 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const checkFolderWritePermission = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
path: string
|
||||
) =>
|
||||
new Promise((resolve) => {
|
||||
fs.access(path, fs.constants.W_OK, (err) => {
|
||||
resolve(!err);
|
||||
});
|
||||
});
|
||||
testPath: string
|
||||
) => {
|
||||
const testFilePath = path.join(testPath, ".hydra-write-test");
|
||||
|
||||
try {
|
||||
fs.writeFileSync(testFilePath, "");
|
||||
fs.rmSync(testFilePath);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("checkFolderWritePermission", checkFolderWritePermission);
|
||||
|
@ -1,44 +0,0 @@
|
||||
import { Document as YMLDocument } from "yaml";
|
||||
import { Game } from "@main/entity";
|
||||
import path from "node:path";
|
||||
|
||||
export const generateYML = (game: Game) => {
|
||||
const slugifiedGameTitle = game.title.replace(/\s/g, "-").toLocaleLowerCase();
|
||||
|
||||
const doc = new YMLDocument({
|
||||
name: game.title,
|
||||
game_slug: slugifiedGameTitle,
|
||||
slug: `${slugifiedGameTitle}-installer`,
|
||||
version: "Installer",
|
||||
runner: "wine",
|
||||
script: {
|
||||
game: {
|
||||
prefix: "$GAMEDIR",
|
||||
arch: "win64",
|
||||
working_dir: "$GAMEDIR",
|
||||
},
|
||||
installer: [
|
||||
{
|
||||
task: {
|
||||
name: "create_prefix",
|
||||
arch: "win64",
|
||||
prefix: "$GAMEDIR",
|
||||
},
|
||||
},
|
||||
{
|
||||
task: {
|
||||
executable: path.join(
|
||||
game.downloadPath!,
|
||||
game.folderName!,
|
||||
"setup.exe"
|
||||
),
|
||||
name: "wineexec",
|
||||
prefix: "$GAMEDIR",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
return doc.toString();
|
||||
};
|
@ -1,15 +1,16 @@
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import { defaultDownloadsPath } from "@main/constants";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import type { UserPreferences } from "@types";
|
||||
|
||||
export const getDownloadsPath = async () => {
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
if (userPreferences && userPreferences.downloadsPath)
|
||||
return userPreferences.downloadsPath;
|
||||
if (userPreferences?.downloadsPath) return userPreferences.downloadsPath;
|
||||
|
||||
return defaultDownloadsPath;
|
||||
};
|
||||
|
7
src/main/events/helpers/parse-launch-options.ts
Normal file
7
src/main/events/helpers/parse-launch-options.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const parseLaunchOptions = (params?: string | null): string[] => {
|
||||
if (!params) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return params.split(" ");
|
||||
};
|
@ -46,6 +46,7 @@ import "./user-preferences/auto-launch";
|
||||
import "./autoupdater/check-for-updates";
|
||||
import "./autoupdater/restart-and-install-update";
|
||||
import "./user-preferences/authenticate-real-debrid";
|
||||
import "./user-preferences/authenticate-torbox";
|
||||
import "./download-sources/put-download-source";
|
||||
import "./auth/sign-out";
|
||||
import "./auth/open-auth-window";
|
||||
|
@ -1,57 +1,55 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
import type { GameShop } from "@types";
|
||||
import type { Game, GameShop } from "@types";
|
||||
|
||||
import { steamGamesWorker } from "@main/workers";
|
||||
import { createGame } from "@main/services/library-sync";
|
||||
import { steamUrlBuilder } from "@shared";
|
||||
import { updateLocalUnlockedAchivements } from "@main/services/achievements/update-local-unlocked-achivements";
|
||||
import { downloadsSublevel, gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const addGameToLibrary = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
title: string,
|
||||
shop: GameShop
|
||||
title: string
|
||||
) => {
|
||||
return gameRepository
|
||||
.update(
|
||||
{
|
||||
objectID: objectId,
|
||||
},
|
||||
{
|
||||
shop,
|
||||
status: null,
|
||||
isDeleted: false,
|
||||
}
|
||||
)
|
||||
.then(async ({ affected }) => {
|
||||
if (!affected) {
|
||||
const steamGame = await steamGamesWorker.run(Number(objectId), {
|
||||
name: "getById",
|
||||
});
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
if (game) {
|
||||
await downloadsSublevel.del(gameKey);
|
||||
|
||||
await gameRepository.insert({
|
||||
title,
|
||||
iconUrl,
|
||||
objectID: objectId,
|
||||
shop,
|
||||
});
|
||||
}
|
||||
|
||||
const game = await gameRepository.findOne({
|
||||
where: { objectID: objectId },
|
||||
});
|
||||
|
||||
updateLocalUnlockedAchivements(game!);
|
||||
|
||||
createGame(game!).catch(() => {});
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
isDeleted: false,
|
||||
});
|
||||
} else {
|
||||
const steamGame = await steamGamesWorker.run(Number(objectId), {
|
||||
name: "getById",
|
||||
});
|
||||
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
|
||||
const game: Game = {
|
||||
title,
|
||||
iconUrl,
|
||||
objectId,
|
||||
shop,
|
||||
remoteId: null,
|
||||
isDeleted: false,
|
||||
playTimeInMilliseconds: 0,
|
||||
lastTimePlayed: null,
|
||||
};
|
||||
|
||||
await gamesSublevel.put(levelKeys.game(shop, objectId), game);
|
||||
|
||||
updateLocalUnlockedAchivements(game!);
|
||||
|
||||
createGame(game!).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("addGameToLibrary", addGameToLibrary);
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { logger } from "@main/services";
|
||||
import sudo from "sudo-prompt";
|
||||
import { app } from "electron";
|
||||
import { PythonRPC } from "@main/services/python-rpc";
|
||||
import { ProcessPayload } from "@main/services/download/types";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const getKillCommand = (pid: number) => {
|
||||
if (process.platform == "win32") {
|
||||
@ -16,15 +17,14 @@ const getKillCommand = (pid: number) => {
|
||||
|
||||
const closeGame = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const processes =
|
||||
(await PythonRPC.rpc.get<ProcessPayload[] | null>("/process-list")).data ||
|
||||
[];
|
||||
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: gameId, isDeleted: false },
|
||||
});
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
if (!game) return;
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import createDesktopShortcut from "create-desktop-shortcuts";
|
||||
import path from "node:path";
|
||||
import { app } from "electron";
|
||||
import { removeSymbolsFromName } from "@shared";
|
||||
import { GameShop } from "@types";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const createGameShortcut = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
id: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
): Promise<boolean> => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id, executablePath: Not(IsNull()) },
|
||||
});
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (game) {
|
||||
const filePath = game.executablePath;
|
||||
|
@ -1,37 +1,27 @@
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||
import { logger } from "@main/services";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { GameShop } from "@types";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const deleteGameFolder = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
): Promise<void> => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: [
|
||||
{
|
||||
id: gameId,
|
||||
isDeleted: false,
|
||||
status: "removed",
|
||||
},
|
||||
{
|
||||
id: gameId,
|
||||
progress: 1,
|
||||
isDeleted: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
|
||||
if (!game) return;
|
||||
const download = await downloadsSublevel.get(downloadKey);
|
||||
|
||||
if (game.folderName) {
|
||||
if (!download) return;
|
||||
|
||||
if (download.folderName) {
|
||||
const folderPath = path.join(
|
||||
game.downloadPath ?? (await getDownloadsPath()),
|
||||
game.folderName
|
||||
download.downloadPath ?? (await getDownloadsPath()),
|
||||
download.folderName
|
||||
);
|
||||
|
||||
if (fs.existsSync(folderPath)) {
|
||||
@ -52,10 +42,7 @@ const deleteGameFolder = async (
|
||||
}
|
||||
}
|
||||
|
||||
await gameRepository.update(
|
||||
{ id: gameId },
|
||||
{ downloadPath: null, folderName: null, status: null, progress: 0 }
|
||||
);
|
||||
await downloadsSublevel.del(downloadKey);
|
||||
};
|
||||
|
||||
registerEvent("deleteGameFolder", deleteGameFolder);
|
||||
|
@ -1,16 +1,21 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gamesSublevel, downloadsSublevel, levelKeys } from "@main/level";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const getGameByObjectId = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) =>
|
||||
gameRepository.findOne({
|
||||
where: {
|
||||
objectID: objectId,
|
||||
isDeleted: false,
|
||||
},
|
||||
});
|
||||
) => {
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
const [game, download] = await Promise.all([
|
||||
gamesSublevel.get(gameKey),
|
||||
downloadsSublevel.get(gameKey),
|
||||
]);
|
||||
|
||||
if (!game || game.isDeleted) return null;
|
||||
|
||||
return { id: gameKey, ...game, download };
|
||||
};
|
||||
|
||||
registerEvent("getGameByObjectId", getGameByObjectId);
|
||||
|
@ -1,17 +1,26 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
import type { LibraryGame } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { downloadsSublevel, gamesSublevel } from "@main/level";
|
||||
|
||||
const getLibrary = async () =>
|
||||
gameRepository.find({
|
||||
where: {
|
||||
isDeleted: false,
|
||||
},
|
||||
relations: {
|
||||
downloadQueue: true,
|
||||
},
|
||||
order: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
});
|
||||
const getLibrary = async (): Promise<LibraryGame[]> => {
|
||||
return gamesSublevel
|
||||
.iterator()
|
||||
.all()
|
||||
.then((results) => {
|
||||
return Promise.all(
|
||||
results
|
||||
.filter(([_key, game]) => game.isDeleted === false)
|
||||
.map(async ([key, game]) => {
|
||||
const download = await downloadsSublevel.get(key);
|
||||
|
||||
return {
|
||||
id: key,
|
||||
...game,
|
||||
download: download ?? null,
|
||||
};
|
||||
})
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("getLibrary", getLibrary);
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { shell } from "electron";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const openGameExecutablePath = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: gameId, isDeleted: false },
|
||||
});
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
if (!game || !game.executablePath) return;
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
import { shell } from "electron";
|
||||
import path from "node:path";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { GameShop } from "@types";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const openGameInstallerPath = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: gameId, isDeleted: false },
|
||||
});
|
||||
const download = await downloadsSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
if (!game || !game.folderName || !game.downloadPath) return true;
|
||||
if (!download || !download.folderName || !download.downloadPath) return true;
|
||||
|
||||
const gamePath = path.join(
|
||||
game.downloadPath ?? (await getDownloadsPath()),
|
||||
game.folderName!
|
||||
download.downloadPath ?? (await getDownloadsPath()),
|
||||
download.folderName!
|
||||
);
|
||||
|
||||
shell.showItemInFolder(gamePath);
|
||||
|
@ -1,14 +1,12 @@
|
||||
import { shell } from "electron";
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { spawnSync, exec } from "node:child_process";
|
||||
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { generateYML } from "../helpers/generate-lutris-yaml";
|
||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const executeGameInstaller = (filePath: string) => {
|
||||
if (process.platform === "win32") {
|
||||
@ -26,21 +24,21 @@ const executeGameInstaller = (filePath: string) => {
|
||||
|
||||
const openGameInstaller = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: gameId, isDeleted: false },
|
||||
});
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
const download = await downloadsSublevel.get(downloadKey);
|
||||
|
||||
if (!game || !game.folderName) return true;
|
||||
if (!download?.folderName) return true;
|
||||
|
||||
const gamePath = path.join(
|
||||
game.downloadPath ?? (await getDownloadsPath()),
|
||||
game.folderName!
|
||||
download.downloadPath ?? (await getDownloadsPath()),
|
||||
download.folderName
|
||||
);
|
||||
|
||||
if (!fs.existsSync(gamePath)) {
|
||||
await gameRepository.update({ id: gameId }, { status: null });
|
||||
await downloadsSublevel.del(downloadKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,13 +68,6 @@ const openGameInstaller = async (
|
||||
);
|
||||
}
|
||||
|
||||
if (spawnSync("which", ["lutris"]).status === 0) {
|
||||
const ymlPath = path.join(gamePath, "setup.yml");
|
||||
await writeFile(ymlPath, generateYML(game));
|
||||
exec(`lutris --install "${ymlPath}"`);
|
||||
return true;
|
||||
}
|
||||
|
||||
shell.openPath(gamePath);
|
||||
return true;
|
||||
};
|
||||
|
@ -1,24 +1,39 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { shell } from "electron";
|
||||
import { spawn } from "child_process";
|
||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
import { parseLaunchOptions } from "../helpers/parse-launch-options";
|
||||
|
||||
const openGame = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number,
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
executablePath: string,
|
||||
launchOptions: string | null
|
||||
launchOptions?: string | null
|
||||
) => {
|
||||
// TODO: revisit this for launchOptions
|
||||
const parsedPath = parseExecutablePath(executablePath);
|
||||
const parsedParams = parseLaunchOptions(launchOptions);
|
||||
|
||||
await gameRepository.update(
|
||||
{ id: gameId },
|
||||
{ executablePath: parsedPath, launchOptions }
|
||||
);
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
shell.openPath(parsedPath);
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (!game) return;
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
executablePath: parsedPath,
|
||||
launchOptions,
|
||||
});
|
||||
|
||||
if (parsedParams.length === 0) {
|
||||
shell.openPath(parsedPath);
|
||||
return;
|
||||
}
|
||||
|
||||
spawn(parsedPath, parsedParams, { shell: false, detached: true });
|
||||
};
|
||||
|
||||
registerEvent("openGame", openGame);
|
||||
|
@ -1,26 +1,26 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
import { HydraApi, logger } from "@main/services";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const removeGameFromLibrary = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
gameRepository.update(
|
||||
{ id: gameId },
|
||||
{ isDeleted: true, executablePath: null }
|
||||
);
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
removeRemoveGameFromLibrary(gameId).catch((err) => {
|
||||
logger.error("removeRemoveGameFromLibrary", err);
|
||||
});
|
||||
};
|
||||
if (game) {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
isDeleted: true,
|
||||
executablePath: null,
|
||||
});
|
||||
|
||||
const removeRemoveGameFromLibrary = async (gameId: number) => {
|
||||
const game = await gameRepository.findOne({ where: { id: gameId } });
|
||||
|
||||
if (game?.remoteId) {
|
||||
HydraApi.delete(`/profile/games/${game.remoteId}`).catch(() => {});
|
||||
if (game?.remoteId) {
|
||||
HydraApi.delete(`/profile/games/${game.remoteId}`).catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,21 +1,14 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
import { levelKeys, downloadsSublevel } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const removeGame = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
await gameRepository.update(
|
||||
{
|
||||
id: gameId,
|
||||
},
|
||||
{
|
||||
status: "removed",
|
||||
downloadPath: null,
|
||||
bytesDownloaded: 0,
|
||||
progress: 0,
|
||||
}
|
||||
);
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
await downloadsSublevel.del(downloadKey);
|
||||
};
|
||||
|
||||
registerEvent("removeGame", removeGame);
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { gameAchievementRepository, gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { findAchievementFiles } from "@main/services/achievements/find-achivement-files";
|
||||
import fs from "fs";
|
||||
import { achievementsLogger, HydraApi, WindowManager } from "@main/services";
|
||||
import { getUnlockedAchievements } from "../user/get-unlocked-achievements";
|
||||
import {
|
||||
gameAchievementsSublevel,
|
||||
gamesSublevel,
|
||||
levelKeys,
|
||||
} from "@main/level";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const resetGameAchievements = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
try {
|
||||
const game = await gameRepository.findOne({ where: { id: gameId } });
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
if (!game) return;
|
||||
|
||||
@ -23,28 +29,34 @@ const resetGameAchievements = async (
|
||||
}
|
||||
}
|
||||
|
||||
await gameAchievementRepository.update(
|
||||
{ objectId: game.objectID },
|
||||
{
|
||||
unlockedAchievements: null,
|
||||
}
|
||||
);
|
||||
const levelKey = levelKeys.game(game.shop, game.objectId);
|
||||
|
||||
await gameAchievementsSublevel
|
||||
.get(levelKey)
|
||||
.then(async (gameAchievements) => {
|
||||
if (gameAchievements) {
|
||||
await gameAchievementsSublevel.put(levelKey, {
|
||||
...gameAchievements,
|
||||
unlockedAchievements: [],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await HydraApi.delete(`/profile/games/achievements/${game.remoteId}`).then(
|
||||
() =>
|
||||
achievementsLogger.log(
|
||||
`Deleted achievements from ${game.remoteId} - ${game.objectID} - ${game.title}`
|
||||
`Deleted achievements from ${game.remoteId} - ${game.objectId} - ${game.title}`
|
||||
)
|
||||
);
|
||||
|
||||
const gameAchievements = await getUnlockedAchievements(
|
||||
game.objectID,
|
||||
game.objectId,
|
||||
game.shop,
|
||||
true
|
||||
);
|
||||
|
||||
WindowManager.mainWindow?.webContents.send(
|
||||
`on-update-achievements-${game.objectID}-${game.shop}`,
|
||||
`on-update-achievements-${game.objectId}-${game.shop}`,
|
||||
gameAchievements
|
||||
);
|
||||
} catch (error) {
|
||||
|
@ -1,13 +1,23 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { levelKeys, gamesSublevel } from "@main/level";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const selectGameWinePrefix = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
id: number,
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
winePrefixPath: string | null
|
||||
) => {
|
||||
return gameRepository.update({ id }, { winePrefixPath: winePrefixPath });
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (!game) return;
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
winePrefixPath: winePrefixPath,
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("selectGameWinePrefix", selectGameWinePrefix);
|
||||
|
@ -1,25 +1,27 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const updateExecutablePath = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
id: number,
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
executablePath: string | null
|
||||
) => {
|
||||
const parsedPath = executablePath
|
||||
? parseExecutablePath(executablePath)
|
||||
: null;
|
||||
|
||||
return gameRepository.update(
|
||||
{
|
||||
id,
|
||||
},
|
||||
{
|
||||
executablePath: parsedPath,
|
||||
}
|
||||
);
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
if (!game) return;
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
executablePath: parsedPath,
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("updateExecutablePath", updateExecutablePath);
|
||||
|
@ -1,19 +1,23 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const updateLaunchOptions = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
id: number,
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
launchOptions: string | null
|
||||
) => {
|
||||
return gameRepository.update(
|
||||
{
|
||||
id,
|
||||
},
|
||||
{
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (game) {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
launchOptions: launchOptions?.trim() != "" ? launchOptions : null,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("updateLaunchOptions", updateLaunchOptions);
|
||||
|
@ -1,13 +1,17 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gamesSublevel } from "@main/level";
|
||||
|
||||
const verifyExecutablePathInUse = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
executablePath: string
|
||||
) => {
|
||||
return gameRepository.findOne({
|
||||
where: { executablePath },
|
||||
});
|
||||
for await (const game of gamesSublevel.values()) {
|
||||
if (game.executablePath === executablePath) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
registerEvent("verifyExecutablePathInUse", verifyExecutablePathInUse);
|
||||
|
@ -1,17 +1,20 @@
|
||||
import { shell } from "electron";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { Crypto, HydraApi } from "@main/services";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import type { Auth } from "@types";
|
||||
|
||||
const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
const auth = await db.get<string, Auth>(levelKeys.auth, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
if (!userAuth) {
|
||||
if (!auth) {
|
||||
return;
|
||||
}
|
||||
|
||||
const paymentToken = await HydraApi.post("/auth/payment", {
|
||||
refreshToken: userAuth.refreshToken,
|
||||
refreshToken: Crypto.decrypt(auth.refreshToken),
|
||||
}).then((response) => response.accessToken);
|
||||
|
||||
const params = new URLSearchParams({
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Notification } from "electron";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import { t } from "i18next";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import type { UserPreferences } from "@types";
|
||||
|
||||
const publishNewRepacksNotification = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@ -9,9 +10,12 @@ const publishNewRepacksNotification = async (
|
||||
) => {
|
||||
if (newRepacksCount < 1) return;
|
||||
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
if (userPreferences?.repackUpdatesNotificationsEnabled) {
|
||||
new Notification({
|
||||
|
@ -7,7 +7,7 @@ import { omit } from "lodash-es";
|
||||
import axios from "axios";
|
||||
import { fileTypeFromFile } from "file-type";
|
||||
|
||||
const patchUserProfile = async (updateProfile: UpdateProfileRequest) => {
|
||||
export const patchUserProfile = async (updateProfile: UpdateProfileRequest) => {
|
||||
return HydraApi.patch<UserProfile>("/profile", updateProfile);
|
||||
};
|
||||
|
||||
|
@ -1,31 +1,19 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game } from "@main/entity";
|
||||
import { GameShop } from "@types";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const cancelGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await DownloadManager.cancelDownload(gameId);
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
|
||||
await transactionalEntityManager.getRepository(DownloadQueue).delete({
|
||||
game: { id: gameId },
|
||||
});
|
||||
await DownloadManager.cancelDownload(downloadKey);
|
||||
|
||||
await transactionalEntityManager.getRepository(Game).update(
|
||||
{
|
||||
id: gameId,
|
||||
},
|
||||
{
|
||||
status: "removed",
|
||||
bytesDownloaded: 0,
|
||||
progress: 0,
|
||||
}
|
||||
);
|
||||
});
|
||||
await downloadsSublevel.del(downloadKey);
|
||||
};
|
||||
|
||||
registerEvent("cancelGameDownload", cancelGameDownload);
|
||||
|
@ -1,24 +1,27 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game } from "@main/entity";
|
||||
import { GameShop } from "@types";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const pauseGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await DownloadManager.pauseDownload();
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
await transactionalEntityManager.getRepository(DownloadQueue).delete({
|
||||
game: { id: gameId },
|
||||
const download = await downloadsSublevel.get(gameKey);
|
||||
|
||||
if (download) {
|
||||
await DownloadManager.pauseDownload(gameKey);
|
||||
|
||||
await downloadsSublevel.put(gameKey, {
|
||||
...download,
|
||||
status: "paused",
|
||||
queued: false,
|
||||
});
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "paused" });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("pauseGameDownload", pauseGameDownload);
|
||||
|
@ -1,17 +1,24 @@
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { gameRepository } from "@main/repository";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const pauseGameSeed = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
await gameRepository.update(gameId, {
|
||||
status: "complete",
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
const download = await downloadsSublevel.get(downloadKey);
|
||||
|
||||
if (!download) return;
|
||||
|
||||
await downloadsSublevel.put(downloadKey, {
|
||||
...download,
|
||||
shouldSeed: false,
|
||||
});
|
||||
|
||||
await DownloadManager.pauseSeeding(gameId);
|
||||
await DownloadManager.pauseSeeding(downloadKey);
|
||||
};
|
||||
|
||||
registerEvent("pauseGameSeed", pauseGameSeed);
|
||||
|
@ -1,46 +1,37 @@
|
||||
import { Not } from "typeorm";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game } from "@main/entity";
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
import { GameShop } from "@types";
|
||||
|
||||
const resumeGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
id: gameId,
|
||||
isDeleted: false,
|
||||
},
|
||||
});
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
if (!game) return;
|
||||
const download = await downloadsSublevel.get(gameKey);
|
||||
|
||||
if (game.status === "paused") {
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await DownloadManager.pauseDownload();
|
||||
if (download?.status === "paused") {
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ status: "active", progress: Not(1) }, { status: "paused" });
|
||||
for await (const [key, value] of downloadsSublevel.iterator()) {
|
||||
if (value.status === "active" && value.progress !== 1) {
|
||||
await downloadsSublevel.put(key, {
|
||||
...value,
|
||||
status: "paused",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await DownloadManager.resumeDownload(game);
|
||||
await DownloadManager.resumeDownload(download);
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(DownloadQueue)
|
||||
.delete({ game: { id: gameId } });
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(DownloadQueue)
|
||||
.insert({ game: { id: gameId } });
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "active" });
|
||||
await downloadsSublevel.put(gameKey, {
|
||||
...download,
|
||||
status: "active",
|
||||
timestamp: Date.now(),
|
||||
queued: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,29 +1,23 @@
|
||||
import { downloadsSublevel, levelKeys } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { Downloader } from "@shared";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
const resumeGameSeed = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
id: gameId,
|
||||
isDeleted: false,
|
||||
downloader: Downloader.Torrent,
|
||||
progress: 1,
|
||||
},
|
||||
});
|
||||
const download = await downloadsSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
if (!game) return;
|
||||
if (!download) return;
|
||||
|
||||
await gameRepository.update(gameId, {
|
||||
status: "seeding",
|
||||
await downloadsSublevel.put(levelKeys.game(shop, objectId), {
|
||||
...download,
|
||||
shouldSeed: true,
|
||||
});
|
||||
|
||||
await DownloadManager.resumeSeeding(game);
|
||||
await DownloadManager.resumeSeeding(download);
|
||||
};
|
||||
|
||||
registerEvent("resumeGameSeed", resumeGameSeed);
|
||||
|
@ -1,13 +1,12 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import type { StartGameDownloadPayload } from "@types";
|
||||
import { DownloadManager, HydraApi } from "@main/services";
|
||||
import type { Download, StartGameDownloadPayload } from "@types";
|
||||
import { DownloadManager, HydraApi, logger } from "@main/services";
|
||||
|
||||
import { Not } from "typeorm";
|
||||
import { steamGamesWorker } from "@main/workers";
|
||||
import { createGame } from "@main/services/library-sync";
|
||||
import { steamUrlBuilder } from "@shared";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game } from "@main/entity";
|
||||
import { Downloader, DownloadError, steamUrlBuilder } from "@shared";
|
||||
import { downloadsSublevel, gamesSublevel, levelKeys } from "@main/level";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
const startGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@ -15,85 +14,117 @@ const startGameDownload = async (
|
||||
) => {
|
||||
const { objectId, title, shop, downloadPath, downloader, uri } = payload;
|
||||
|
||||
return dataSource.transaction(async (transactionalEntityManager) => {
|
||||
const gameRepository = transactionalEntityManager.getRepository(Game);
|
||||
const downloadQueueRepository =
|
||||
transactionalEntityManager.getRepository(DownloadQueue);
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
objectID: objectId,
|
||||
shop,
|
||||
},
|
||||
});
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await gameRepository.update(
|
||||
{ status: "active", progress: Not(1) },
|
||||
{ status: "paused" }
|
||||
);
|
||||
|
||||
if (game) {
|
||||
await gameRepository.update(
|
||||
{
|
||||
id: game.id,
|
||||
},
|
||||
{
|
||||
status: "active",
|
||||
progress: 0,
|
||||
bytesDownloaded: 0,
|
||||
downloadPath,
|
||||
downloader,
|
||||
uri,
|
||||
isDeleted: false,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
const steamGame = await steamGamesWorker.run(Number(objectId), {
|
||||
name: "getById",
|
||||
});
|
||||
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
|
||||
await gameRepository.insert({
|
||||
title,
|
||||
iconUrl,
|
||||
objectID: objectId,
|
||||
downloader,
|
||||
shop,
|
||||
status: "active",
|
||||
downloadPath,
|
||||
uri,
|
||||
for await (const [key, value] of downloadsSublevel.iterator()) {
|
||||
if (value.status === "active" && value.progress !== 1) {
|
||||
await downloadsSublevel.put(key, {
|
||||
...value,
|
||||
status: "paused",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const updatedGame = await gameRepository.findOne({
|
||||
where: {
|
||||
objectID: objectId,
|
||||
},
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
/* Delete any previous download */
|
||||
await downloadsSublevel.del(gameKey);
|
||||
|
||||
if (game?.isDeleted) {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
isDeleted: false,
|
||||
});
|
||||
} else {
|
||||
const steamGame = await steamGamesWorker.run(Number(objectId), {
|
||||
name: "getById",
|
||||
});
|
||||
|
||||
await DownloadManager.cancelDownload(updatedGame!.id);
|
||||
await DownloadManager.startDownload(updatedGame!);
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
|
||||
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
|
||||
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
|
||||
await gamesSublevel.put(gameKey, {
|
||||
title,
|
||||
iconUrl,
|
||||
objectId,
|
||||
shop,
|
||||
remoteId: null,
|
||||
playTimeInMilliseconds: 0,
|
||||
lastTimePlayed: null,
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
|
||||
await DownloadManager.cancelDownload(gameKey);
|
||||
|
||||
const download: Download = {
|
||||
shop,
|
||||
objectId,
|
||||
status: "active",
|
||||
progress: 0,
|
||||
bytesDownloaded: 0,
|
||||
downloadPath,
|
||||
downloader,
|
||||
uri,
|
||||
folderName: null,
|
||||
fileSize: null,
|
||||
shouldSeed: false,
|
||||
timestamp: Date.now(),
|
||||
queued: true,
|
||||
};
|
||||
|
||||
try {
|
||||
await DownloadManager.startDownload(download).then(() => {
|
||||
return downloadsSublevel.put(gameKey, download);
|
||||
});
|
||||
|
||||
const updatedGame = await gamesSublevel.get(gameKey);
|
||||
|
||||
await Promise.all([
|
||||
createGame(updatedGame!).catch(() => {}),
|
||||
HydraApi.post(
|
||||
"/games/download",
|
||||
{
|
||||
objectId: updatedGame!.objectID,
|
||||
shop: updatedGame!.shop,
|
||||
objectId,
|
||||
shop,
|
||||
},
|
||||
{ needsAuth: false }
|
||||
).catch(() => {}),
|
||||
]);
|
||||
});
|
||||
|
||||
return { ok: true };
|
||||
} catch (err: unknown) {
|
||||
logger.error("Failed to start download", err);
|
||||
|
||||
if (err instanceof AxiosError) {
|
||||
if (err.response?.status === 429 && downloader === Downloader.Gofile) {
|
||||
return { ok: false, error: DownloadError.GofileQuotaExceeded };
|
||||
}
|
||||
|
||||
if (
|
||||
err.response?.status === 403 &&
|
||||
downloader === Downloader.RealDebrid
|
||||
) {
|
||||
return {
|
||||
ok: false,
|
||||
error: DownloadError.RealDebridAccountNotAuthorized,
|
||||
};
|
||||
}
|
||||
|
||||
if (downloader === Downloader.TorBox) {
|
||||
return { ok: false, error: err.response?.data?.detail };
|
||||
}
|
||||
}
|
||||
|
||||
if (err instanceof Error) {
|
||||
return { ok: false, error: err.message };
|
||||
}
|
||||
|
||||
return { ok: false };
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("startGameDownload", startGameDownload);
|
||||
|
14
src/main/events/user-preferences/authenticate-torbox.ts
Normal file
14
src/main/events/user-preferences/authenticate-torbox.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { TorBoxClient } from "@main/services/download/torbox";
|
||||
|
||||
const authenticateTorBox = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
apiToken: string
|
||||
) => {
|
||||
TorBoxClient.authorize(apiToken);
|
||||
|
||||
const user = await TorBoxClient.getUser();
|
||||
return user;
|
||||
};
|
||||
|
||||
registerEvent("authenticateTorBox", authenticateTorBox);
|
@ -1,9 +1,27 @@
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import { Crypto } from "@main/services";
|
||||
import type { UserPreferences } from "@types";
|
||||
|
||||
const getUserPreferences = async () =>
|
||||
userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
db
|
||||
.get<string, UserPreferences | null>(levelKeys.userPreferences, {
|
||||
valueEncoding: "json",
|
||||
})
|
||||
.then((userPreferences) => {
|
||||
if (userPreferences?.realDebridApiToken) {
|
||||
userPreferences.realDebridApiToken = Crypto.decrypt(
|
||||
userPreferences.realDebridApiToken
|
||||
);
|
||||
}
|
||||
|
||||
if (userPreferences?.torBoxApiToken) {
|
||||
userPreferences.torBoxApiToken = Crypto.decrypt(
|
||||
userPreferences.torBoxApiToken
|
||||
);
|
||||
}
|
||||
|
||||
return userPreferences;
|
||||
});
|
||||
|
||||
registerEvent("getUserPreferences", getUserPreferences);
|
||||
|
@ -1,23 +1,52 @@
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
import type { UserPreferences } from "@types";
|
||||
import i18next from "i18next";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import { Crypto } from "@main/services";
|
||||
import { patchUserProfile } from "../profile/update-profile";
|
||||
|
||||
const updateUserPreferences = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
preferences: Partial<UserPreferences>
|
||||
) => {
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{ valueEncoding: "json" }
|
||||
);
|
||||
|
||||
if (preferences.language) {
|
||||
await db.put<string, string>(levelKeys.language, preferences.language, {
|
||||
valueEncoding: "utf-8",
|
||||
});
|
||||
|
||||
i18next.changeLanguage(preferences.language);
|
||||
patchUserProfile({ language: preferences.language }).catch(() => {});
|
||||
}
|
||||
|
||||
return userPreferencesRepository.upsert(
|
||||
if (preferences.realDebridApiToken) {
|
||||
preferences.realDebridApiToken = Crypto.encrypt(
|
||||
preferences.realDebridApiToken
|
||||
);
|
||||
}
|
||||
|
||||
if (preferences.torBoxApiToken) {
|
||||
preferences.torBoxApiToken = Crypto.encrypt(preferences.torBoxApiToken);
|
||||
}
|
||||
|
||||
if (!preferences.downloadsPath) {
|
||||
preferences.downloadsPath = null;
|
||||
}
|
||||
|
||||
await db.put<string, UserPreferences>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
id: 1,
|
||||
...userPreferences,
|
||||
...preferences,
|
||||
},
|
||||
["id"]
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import type { ComparedAchievements, GameShop } from "@types";
|
||||
import type { ComparedAchievements, GameShop, UserPreferences } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
|
||||
import { HydraApi } from "@main/services";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
|
||||
const getComparedUnlockedAchievements = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@ -9,9 +10,12 @@ const getComparedUnlockedAchievements = async (
|
||||
shop: GameShop,
|
||||
userId: string
|
||||
) => {
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
const showHiddenAchievementsDescription =
|
||||
userPreferences?.showHiddenAchievementsDescription || false;
|
||||
@ -21,7 +25,7 @@ const getComparedUnlockedAchievements = async (
|
||||
{
|
||||
shop,
|
||||
objectId,
|
||||
language: userPreferences?.language || "en",
|
||||
language: userPreferences?.language ?? "en",
|
||||
}
|
||||
).then((achievements) => {
|
||||
const sortedAchievements = achievements.achievements
|
||||
|
@ -1,23 +1,23 @@
|
||||
import type { GameShop, UnlockedAchievement, UserAchievement } from "@types";
|
||||
import type { GameShop, UserAchievement, UserPreferences } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import {
|
||||
gameAchievementRepository,
|
||||
userPreferencesRepository,
|
||||
} from "@main/repository";
|
||||
import { getGameAchievementData } from "@main/services/achievements/get-game-achievement-data";
|
||||
import { db, gameAchievementsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
export const getUnlockedAchievements = async (
|
||||
objectId: string,
|
||||
shop: GameShop,
|
||||
useCachedData: boolean
|
||||
): Promise<UserAchievement[]> => {
|
||||
const cachedAchievements = await gameAchievementRepository.findOne({
|
||||
where: { objectId, shop },
|
||||
});
|
||||
const cachedAchievements = await gameAchievementsSublevel.get(
|
||||
levelKeys.game(shop, objectId)
|
||||
);
|
||||
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
const showHiddenAchievementsDescription =
|
||||
userPreferences?.showHiddenAchievementsDescription || false;
|
||||
@ -25,12 +25,10 @@ export const getUnlockedAchievements = async (
|
||||
const achievementsData = await getGameAchievementData(
|
||||
objectId,
|
||||
shop,
|
||||
useCachedData ? cachedAchievements : null
|
||||
useCachedData
|
||||
);
|
||||
|
||||
const unlockedAchievements = JSON.parse(
|
||||
cachedAchievements?.unlockedAchievements || "[]"
|
||||
) as UnlockedAchievement[];
|
||||
const unlockedAchievements = cachedAchievements?.unlockedAchievements ?? [];
|
||||
|
||||
return achievementsData
|
||||
.map((achievementData) => {
|
||||
|
@ -1,16 +1,19 @@
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { db } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services";
|
||||
import type { UserFriends } from "@types";
|
||||
import type { User, UserFriends } from "@types";
|
||||
import { levelKeys } from "@main/level/sublevels";
|
||||
|
||||
export const getUserFriends = async (
|
||||
userId: string,
|
||||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
const user = await db.get<string, User>(levelKeys.user, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
if (loggedUser?.userId === userId) {
|
||||
if (user?.id === userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip });
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,13 @@ import updater from "electron-updater";
|
||||
import i18n from "i18next";
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
import fs from "node:fs";
|
||||
import { electronApp, optimizer } from "@electron-toolkit/utils";
|
||||
import { logger, WindowManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import resources from "@locales";
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
import { knexClient, migrationConfig } from "./knex-client";
|
||||
import { databaseDirectory } from "./constants";
|
||||
import { PythonRPC } from "./services/python-rpc";
|
||||
import { Aria2 } from "./services/aria2";
|
||||
import { db, levelKeys } from "./level";
|
||||
import { loadState } from "./main";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
@ -50,21 +47,6 @@ if (process.defaultApp) {
|
||||
app.setAsDefaultProtocolClient(PROTOCOL);
|
||||
}
|
||||
|
||||
const runMigrations = async () => {
|
||||
if (!fs.existsSync(databaseDirectory)) {
|
||||
fs.mkdirSync(databaseDirectory, { recursive: true });
|
||||
}
|
||||
|
||||
await knexClient.migrate.list(migrationConfig).then((result) => {
|
||||
logger.log(
|
||||
"Migrations to run:",
|
||||
result[1].map((migration) => migration.name)
|
||||
);
|
||||
});
|
||||
|
||||
await knexClient.migrate.latest(migrationConfig);
|
||||
};
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
@ -76,31 +58,19 @@ app.whenReady().then(async () => {
|
||||
return net.fetch(url.pathToFileURL(decodeURI(filePath)).toString());
|
||||
});
|
||||
|
||||
await runMigrations()
|
||||
.then(() => {
|
||||
logger.log("Migrations executed successfully");
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.log("Migrations failed to run:", err);
|
||||
});
|
||||
await loadState();
|
||||
|
||||
await dataSource.initialize();
|
||||
|
||||
await import("./main");
|
||||
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
const language = await db.get<string, string>(levelKeys.language, {
|
||||
valueEncoding: "utf-8",
|
||||
});
|
||||
|
||||
if (userPreferences?.language) {
|
||||
i18n.changeLanguage(userPreferences.language);
|
||||
}
|
||||
if (language) i18n.changeLanguage(language);
|
||||
|
||||
if (!process.argv.includes("--hidden")) {
|
||||
WindowManager.createMainWindow();
|
||||
}
|
||||
|
||||
WindowManager.createSystemTray(userPreferences?.language || "en");
|
||||
WindowManager.createSystemTray(language || "en");
|
||||
});
|
||||
|
||||
app.on("browser-window-created", (_, window) => {
|
||||
|
@ -1,53 +1,6 @@
|
||||
import knex, { Knex } from "knex";
|
||||
import knex from "knex";
|
||||
import { databasePath } from "./constants";
|
||||
import { Hydra2_0_3 } from "./migrations/20240830143811_Hydra_2_0_3";
|
||||
import { RepackUris } from "./migrations/20240830143906_RepackUris";
|
||||
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
|
||||
import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris";
|
||||
import { app } from "electron";
|
||||
import { FixMissingColumns } from "./migrations/20240918001920_FixMissingColumns";
|
||||
import { CreateGameAchievement } from "./migrations/20240919030940_create_game_achievement";
|
||||
import { AddAchievementNotificationPreference } from "./migrations/20241013012900_add_achievement_notification_preference";
|
||||
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
|
||||
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
|
||||
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
|
||||
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
|
||||
import { AddDisableNsfwAlertColumn } from "./migrations/20241106053733_add_disable_nsfw_alert_column";
|
||||
import { AddShouldSeedColumn } from "./migrations/20241108200154_add_should_seed_colum";
|
||||
import { AddSeedAfterDownloadColumn } from "./migrations/20241108201806_add_seed_after_download";
|
||||
import { AddHiddenAchievementDescriptionColumn } from "./migrations/20241216140633_add_hidden_achievement_description_column ";
|
||||
import { AddLaunchOptionsColumnToGame } from "./migrations/20241226044022_add_launch_options_column_to_game";
|
||||
|
||||
export type HydraMigration = Knex.Migration & { name: string };
|
||||
|
||||
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
||||
getMigrations(): Promise<HydraMigration[]> {
|
||||
return Promise.resolve([
|
||||
Hydra2_0_3,
|
||||
RepackUris,
|
||||
UpdateUserLanguage,
|
||||
EnsureRepackUris,
|
||||
FixMissingColumns,
|
||||
CreateGameAchievement,
|
||||
AddAchievementNotificationPreference,
|
||||
CreateUserSubscription,
|
||||
AddBackgroundImageUrl,
|
||||
AddWinePrefixToGame,
|
||||
AddStartMinimizedColumn,
|
||||
AddDisableNsfwAlertColumn,
|
||||
AddShouldSeedColumn,
|
||||
AddSeedAfterDownloadColumn,
|
||||
AddHiddenAchievementDescriptionColumn,
|
||||
AddLaunchOptionsColumnToGame,
|
||||
]);
|
||||
}
|
||||
getMigrationName(migration: HydraMigration): string {
|
||||
return migration.name;
|
||||
}
|
||||
getMigration(migration: HydraMigration): Promise<Knex.Migration> {
|
||||
return Promise.resolve(migration);
|
||||
}
|
||||
}
|
||||
|
||||
export const knexClient = knex({
|
||||
debug: !app.isPackaged,
|
||||
@ -56,7 +9,3 @@ export const knexClient = knex({
|
||||
filename: databasePath,
|
||||
},
|
||||
});
|
||||
|
||||
export const migrationConfig: Knex.MigratorConfig = {
|
||||
migrationSource: new MigrationSource(),
|
||||
};
|
||||
|
3
src/main/level/index.ts
Normal file
3
src/main/level/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export { db } from "./level";
|
||||
|
||||
export * from "./sublevels";
|
6
src/main/level/level.ts
Normal file
6
src/main/level/level.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { levelDatabasePath } from "@main/constants";
|
||||
import { ClassicLevel } from "classic-level";
|
||||
|
||||
export const db = new ClassicLevel(levelDatabasePath, {
|
||||
valueEncoding: "json",
|
||||
});
|
11
src/main/level/sublevels/downloads.ts
Normal file
11
src/main/level/sublevels/downloads.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { Download } from "@types";
|
||||
|
||||
import { db } from "../level";
|
||||
import { levelKeys } from "./keys";
|
||||
|
||||
export const downloadsSublevel = db.sublevel<string, Download>(
|
||||
levelKeys.downloads,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
11
src/main/level/sublevels/game-achievements.ts
Normal file
11
src/main/level/sublevels/game-achievements.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { GameAchievement } from "@types";
|
||||
|
||||
import { db } from "../level";
|
||||
import { levelKeys } from "./keys";
|
||||
|
||||
export const gameAchievementsSublevel = db.sublevel<string, GameAchievement>(
|
||||
levelKeys.gameAchievements,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
11
src/main/level/sublevels/game-shop-cache.ts
Normal file
11
src/main/level/sublevels/game-shop-cache.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { ShopDetails } from "@types";
|
||||
|
||||
import { db } from "../level";
|
||||
import { levelKeys } from "./keys";
|
||||
|
||||
export const gamesShopCacheSublevel = db.sublevel<string, ShopDetails>(
|
||||
levelKeys.gameShopCache,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
8
src/main/level/sublevels/games.ts
Normal file
8
src/main/level/sublevels/games.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import type { Game } from "@types";
|
||||
|
||||
import { db } from "../level";
|
||||
import { levelKeys } from "./keys";
|
||||
|
||||
export const gamesSublevel = db.sublevel<string, Game>(levelKeys.games, {
|
||||
valueEncoding: "json",
|
||||
});
|
6
src/main/level/sublevels/index.ts
Normal file
6
src/main/level/sublevels/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export * from "./downloads";
|
||||
export * from "./games";
|
||||
export * from "./game-shop-cache";
|
||||
export * from "./game-achievements";
|
||||
|
||||
export * from "./keys";
|
16
src/main/level/sublevels/keys.ts
Normal file
16
src/main/level/sublevels/keys.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
export const levelKeys = {
|
||||
games: "games",
|
||||
game: (shop: GameShop, objectId: string) => `${shop}:${objectId}`,
|
||||
user: "user",
|
||||
auth: "auth",
|
||||
gameShopCache: "gameShopCache",
|
||||
gameShopCacheItem: (shop: GameShop, objectId: string, language: string) =>
|
||||
`${shop}:${objectId}:${language}`,
|
||||
gameAchievements: "gameAchievements",
|
||||
downloads: "downloads",
|
||||
userPreferences: "userPreferences",
|
||||
language: "language",
|
||||
sqliteMigrationDone: "sqliteMigrationDone",
|
||||
};
|
223
src/main/main.ts
223
src/main/main.ts
@ -1,24 +1,50 @@
|
||||
import { DownloadManager, Ludusavi, startMainLoop } from "./services";
|
||||
import {
|
||||
downloadQueueRepository,
|
||||
gameRepository,
|
||||
userPreferencesRepository,
|
||||
} from "./repository";
|
||||
import { UserPreferences } from "./entity";
|
||||
Crypto,
|
||||
DownloadManager,
|
||||
logger,
|
||||
Ludusavi,
|
||||
startMainLoop,
|
||||
} from "./services";
|
||||
import { RealDebridClient } from "./services/download/real-debrid";
|
||||
import { HydraApi } from "./services/hydra-api";
|
||||
import { uploadGamesBatch } from "./services/library-sync";
|
||||
import { Aria2 } from "./services/aria2";
|
||||
import { downloadsSublevel } from "./level/sublevels/downloads";
|
||||
import { sortBy } from "lodash-es";
|
||||
import { Downloader } from "@shared";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import {
|
||||
gameAchievementsSublevel,
|
||||
gamesSublevel,
|
||||
levelKeys,
|
||||
db,
|
||||
} from "./level";
|
||||
import { Auth, User, type UserPreferences } from "@types";
|
||||
import { knexClient } from "./knex-client";
|
||||
import { TorBoxClient } from "./services/download/torbox";
|
||||
|
||||
const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
import("./events");
|
||||
export const loadState = async () => {
|
||||
const userPreferences = await migrateFromSqlite().then(async () => {
|
||||
await db.put<string, boolean>(levelKeys.sqliteMigrationDone, true, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
return db.get<string, UserPreferences | null>(levelKeys.userPreferences, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
});
|
||||
|
||||
await import("./events");
|
||||
|
||||
Aria2.spawn();
|
||||
|
||||
if (userPreferences?.realDebridApiToken) {
|
||||
RealDebridClient.authorize(userPreferences?.realDebridApiToken);
|
||||
RealDebridClient.authorize(
|
||||
Crypto.decrypt(userPreferences.realDebridApiToken)
|
||||
);
|
||||
}
|
||||
|
||||
if (userPreferences?.torBoxApiToken) {
|
||||
TorBoxClient.authorize(Crypto.decrypt(userPreferences.torBoxApiToken));
|
||||
}
|
||||
|
||||
Ludusavi.addManifestToLudusaviConfig();
|
||||
@ -27,33 +53,162 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
uploadGamesBatch();
|
||||
});
|
||||
|
||||
const [nextQueueItem] = await downloadQueueRepository.find({
|
||||
order: {
|
||||
id: "DESC",
|
||||
},
|
||||
relations: {
|
||||
game: true,
|
||||
},
|
||||
});
|
||||
const downloads = await downloadsSublevel
|
||||
.values()
|
||||
.all()
|
||||
.then((games) => {
|
||||
return sortBy(
|
||||
games.filter((game) => game.queued),
|
||||
"timestamp",
|
||||
"DESC"
|
||||
);
|
||||
});
|
||||
|
||||
const seedList = await gameRepository.find({
|
||||
where: {
|
||||
shouldSeed: true,
|
||||
downloader: Downloader.Torrent,
|
||||
progress: 1,
|
||||
uri: Not(IsNull()),
|
||||
},
|
||||
});
|
||||
const [nextItemOnQueue] = downloads;
|
||||
|
||||
await DownloadManager.startRPC(nextQueueItem?.game, seedList);
|
||||
const downloadsToSeed = downloads.filter(
|
||||
(download) =>
|
||||
download.shouldSeed &&
|
||||
download.downloader === Downloader.Torrent &&
|
||||
download.progress === 1 &&
|
||||
download.uri !== null
|
||||
);
|
||||
|
||||
await DownloadManager.startRPC(nextItemOnQueue, downloadsToSeed);
|
||||
|
||||
startMainLoop();
|
||||
};
|
||||
|
||||
userPreferencesRepository
|
||||
.findOne({
|
||||
where: { id: 1 },
|
||||
})
|
||||
.then((userPreferences) => {
|
||||
loadState(userPreferences);
|
||||
});
|
||||
const migrateFromSqlite = async () => {
|
||||
const sqliteMigrationDone = await db.get(levelKeys.sqliteMigrationDone);
|
||||
|
||||
if (sqliteMigrationDone) {
|
||||
return;
|
||||
}
|
||||
|
||||
const migrateGames = knexClient("game")
|
||||
.select("*")
|
||||
.then((games) => {
|
||||
return gamesSublevel.batch(
|
||||
games.map((game) => ({
|
||||
type: "put",
|
||||
key: levelKeys.game(game.shop, game.objectID),
|
||||
value: {
|
||||
objectId: game.objectID,
|
||||
shop: game.shop,
|
||||
title: game.title,
|
||||
iconUrl: game.iconUrl,
|
||||
playTimeInMilliseconds: game.playTimeInMilliseconds,
|
||||
lastTimePlayed: game.lastTimePlayed,
|
||||
remoteId: game.remoteId,
|
||||
winePrefixPath: game.winePrefixPath,
|
||||
launchOptions: game.launchOptions,
|
||||
executablePath: game.executablePath,
|
||||
isDeleted: game.isDeleted === 1,
|
||||
},
|
||||
}))
|
||||
);
|
||||
})
|
||||
.then(() => {
|
||||
logger.info("Games migrated successfully");
|
||||
});
|
||||
|
||||
const migrateUserPreferences = knexClient("user_preferences")
|
||||
.select("*")
|
||||
.then(async (userPreferences) => {
|
||||
if (userPreferences.length > 0) {
|
||||
const { realDebridApiToken, ...rest } = userPreferences[0];
|
||||
|
||||
await db.put<string, UserPreferences>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
...rest,
|
||||
realDebridApiToken: realDebridApiToken
|
||||
? Crypto.encrypt(realDebridApiToken)
|
||||
: null,
|
||||
preferQuitInsteadOfHiding: rest.preferQuitInsteadOfHiding === 1,
|
||||
runAtStartup: rest.runAtStartup === 1,
|
||||
startMinimized: rest.startMinimized === 1,
|
||||
disableNsfwAlert: rest.disableNsfwAlert === 1,
|
||||
seedAfterDownloadComplete: rest.seedAfterDownloadComplete === 1,
|
||||
showHiddenAchievementsDescription:
|
||||
rest.showHiddenAchievementsDescription === 1,
|
||||
downloadNotificationsEnabled:
|
||||
rest.downloadNotificationsEnabled === 1,
|
||||
repackUpdatesNotificationsEnabled:
|
||||
rest.repackUpdatesNotificationsEnabled === 1,
|
||||
achievementNotificationsEnabled:
|
||||
rest.achievementNotificationsEnabled === 1,
|
||||
},
|
||||
{ valueEncoding: "json" }
|
||||
);
|
||||
|
||||
if (rest.language) {
|
||||
await db.put(levelKeys.language, rest.language);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
logger.info("User preferences migrated successfully");
|
||||
});
|
||||
|
||||
const migrateAchievements = knexClient("game_achievement")
|
||||
.select("*")
|
||||
.then((achievements) => {
|
||||
return gameAchievementsSublevel.batch(
|
||||
achievements.map((achievement) => ({
|
||||
type: "put",
|
||||
key: levelKeys.game(achievement.shop, achievement.objectId),
|
||||
value: {
|
||||
achievements: JSON.parse(achievement.achievements),
|
||||
unlockedAchievements: JSON.parse(achievement.unlockedAchievements),
|
||||
},
|
||||
}))
|
||||
);
|
||||
})
|
||||
.then(() => {
|
||||
logger.info("Achievements migrated successfully");
|
||||
});
|
||||
|
||||
const migrateUser = knexClient("user_auth")
|
||||
.select("*")
|
||||
.then(async (users) => {
|
||||
if (users.length > 0) {
|
||||
await db.put<string, User>(
|
||||
levelKeys.user,
|
||||
{
|
||||
id: users[0].userId,
|
||||
displayName: users[0].displayName,
|
||||
profileImageUrl: users[0].profileImageUrl,
|
||||
backgroundImageUrl: users[0].backgroundImageUrl,
|
||||
subscription: users[0].subscription,
|
||||
},
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
await db.put<string, Auth>(
|
||||
levelKeys.auth,
|
||||
{
|
||||
accessToken: Crypto.encrypt(users[0].accessToken),
|
||||
refreshToken: Crypto.encrypt(users[0].refreshToken),
|
||||
tokenExpirationTimestamp: users[0].tokenExpirationTimestamp,
|
||||
},
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
logger.info("User data migrated successfully");
|
||||
});
|
||||
|
||||
return Promise.allSettled([
|
||||
migrateGames,
|
||||
migrateUserPreferences,
|
||||
migrateAchievements,
|
||||
migrateUser,
|
||||
]);
|
||||
};
|
||||
|
@ -1,171 +0,0 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const Hydra2_0_3: HydraMigration = {
|
||||
name: "Hydra_2_0_3",
|
||||
up: async (knex: Knex) => {
|
||||
const timestamp = new Date().getTime();
|
||||
|
||||
await knex.schema.hasTable("migrations").then(async (exists) => {
|
||||
if (exists) {
|
||||
await knex.schema.dropTable("migrations");
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("download_source").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("download_source", (table) => {
|
||||
table.increments("id").primary();
|
||||
table
|
||||
.text("url")
|
||||
.unique({ indexName: "download_source_url_unique_" + timestamp });
|
||||
table.text("name").notNullable();
|
||||
table.text("etag");
|
||||
table.integer("downloadCount").notNullable().defaultTo(0);
|
||||
table.text("status").notNullable().defaultTo(0);
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("repack").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("repack", (table) => {
|
||||
table.increments("id").primary();
|
||||
table
|
||||
.text("title")
|
||||
.notNullable()
|
||||
.unique({ indexName: "repack_title_unique_" + timestamp });
|
||||
table
|
||||
.text("magnet")
|
||||
.notNullable()
|
||||
.unique({ indexName: "repack_magnet_unique_" + timestamp });
|
||||
table.integer("page");
|
||||
table.text("repacker").notNullable();
|
||||
table.text("fileSize").notNullable();
|
||||
table.datetime("uploadDate").notNullable();
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
table
|
||||
.integer("downloadSourceId")
|
||||
.references("download_source.id")
|
||||
.onDelete("CASCADE");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("game").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("game", (table) => {
|
||||
table.increments("id").primary();
|
||||
table
|
||||
.text("objectID")
|
||||
.notNullable()
|
||||
.unique({ indexName: "game_objectID_unique_" + timestamp });
|
||||
table
|
||||
.text("remoteId")
|
||||
.unique({ indexName: "game_remoteId_unique_" + timestamp });
|
||||
table.text("title").notNullable();
|
||||
table.text("iconUrl");
|
||||
table.text("folderName");
|
||||
table.text("downloadPath");
|
||||
table.text("executablePath");
|
||||
table.integer("playTimeInMilliseconds").notNullable().defaultTo(0);
|
||||
table.text("shop").notNullable();
|
||||
table.text("status");
|
||||
table.integer("downloader").notNullable().defaultTo(1);
|
||||
table.float("progress").notNullable().defaultTo(0);
|
||||
table.integer("bytesDownloaded").notNullable().defaultTo(0);
|
||||
table.datetime("lastTimePlayed");
|
||||
table.float("fileSize").notNullable().defaultTo(0);
|
||||
table.text("uri");
|
||||
table.boolean("isDeleted").notNullable().defaultTo(0);
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
table
|
||||
.integer("repackId")
|
||||
.references("repack.id")
|
||||
.unique("repack_repackId_unique_" + timestamp);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("user_preferences").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("user_preferences", (table) => {
|
||||
table.increments("id").primary();
|
||||
table.text("downloadsPath");
|
||||
table.text("language").notNullable().defaultTo("en");
|
||||
table.text("realDebridApiToken");
|
||||
table
|
||||
.boolean("downloadNotificationsEnabled")
|
||||
.notNullable()
|
||||
.defaultTo(0);
|
||||
table
|
||||
.boolean("repackUpdatesNotificationsEnabled")
|
||||
.notNullable()
|
||||
.defaultTo(0);
|
||||
table.boolean("preferQuitInsteadOfHiding").notNullable().defaultTo(0);
|
||||
table.boolean("runAtStartup").notNullable().defaultTo(0);
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("game_shop_cache").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("game_shop_cache", (table) => {
|
||||
table.text("objectID").primary().notNullable();
|
||||
table.text("shop").notNullable();
|
||||
table.text("serializedData");
|
||||
table.text("howLongToBeatSerializedData");
|
||||
table.text("language");
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("download_queue").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("download_queue", (table) => {
|
||||
table.increments("id").primary();
|
||||
table
|
||||
.integer("gameId")
|
||||
.references("game.id")
|
||||
.unique("download_queue_gameId_unique_" + timestamp);
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasTable("user_auth").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.createTable("user_auth", (table) => {
|
||||
table.increments("id").primary();
|
||||
table.text("userId").notNullable().defaultTo("");
|
||||
table.text("displayName").notNullable().defaultTo("");
|
||||
table.text("profileImageUrl");
|
||||
table.text("accessToken").notNullable().defaultTo("");
|
||||
table.text("refreshToken").notNullable().defaultTo("");
|
||||
table.integer("tokenExpirationTimestamp").notNullable().defaultTo(0);
|
||||
table.datetime("createdAt").notNullable().defaultTo(knex.fn.now());
|
||||
table.datetime("updatedAt").notNullable().defaultTo(knex.fn.now());
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
down: async (knex: Knex) => {
|
||||
await knex.schema.dropTableIfExists("game");
|
||||
await knex.schema.dropTableIfExists("repack");
|
||||
await knex.schema.dropTableIfExists("download_queue");
|
||||
await knex.schema.dropTableIfExists("user_auth");
|
||||
await knex.schema.dropTableIfExists("game_shop_cache");
|
||||
await knex.schema.dropTableIfExists("user_preferences");
|
||||
await knex.schema.dropTableIfExists("download_source");
|
||||
},
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const RepackUris: HydraMigration = {
|
||||
name: "RepackUris",
|
||||
up: async (knex: Knex) => {
|
||||
await knex.schema.alterTable("repack", (table) => {
|
||||
table.text("uris").notNullable().defaultTo("[]");
|
||||
});
|
||||
},
|
||||
|
||||
down: async (knex: Knex) => {
|
||||
await knex.schema.alterTable("repack", (table) => {
|
||||
table.integer("page");
|
||||
table.dropColumn("uris");
|
||||
});
|
||||
},
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const UpdateUserLanguage: HydraMigration = {
|
||||
name: "UpdateUserLanguage",
|
||||
up: async (knex: Knex) => {
|
||||
await knex("user_preferences")
|
||||
.update("language", "pt-BR")
|
||||
.where("language", "pt");
|
||||
},
|
||||
|
||||
down: async (_knex: Knex) => {},
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const EnsureRepackUris: HydraMigration = {
|
||||
name: "EnsureRepackUris",
|
||||
up: async (knex: Knex) => {
|
||||
await knex.schema.hasColumn("repack", "uris").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.table("repack", (table) => {
|
||||
table.text("uris").notNullable().defaultTo("[]");
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
down: async (_knex: Knex) => {},
|
||||
};
|
@ -1,41 +0,0 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const FixMissingColumns: HydraMigration = {
|
||||
name: "FixMissingColumns",
|
||||
up: async (knex: Knex) => {
|
||||
const timestamp = new Date().getTime();
|
||||
await knex.schema
|
||||
.hasColumn("repack", "downloadSourceId")
|
||||
.then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.table("repack", (table) => {
|
||||
table
|
||||
.integer("downloadSourceId")
|
||||
.references("download_source.id")
|
||||
.onDelete("CASCADE");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasColumn("game", "remoteId").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.table("game", (table) => {
|
||||
table
|
||||
.text("remoteId")
|
||||
.unique({ indexName: "game_remoteId_unique_" + timestamp });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await knex.schema.hasColumn("game", "uri").then(async (exists) => {
|
||||
if (!exists) {
|
||||
await knex.schema.table("game", (table) => {
|
||||
table.text("uri");
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
down: async (_knex: Knex) => {},
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user