1
1
$MSG = " $emudeckFolder /logs/msg.log"
2
2
3
- function generate_pythonEnv () {
4
- $pythonRegistryPath = " HKLM:\SOFTWARE\Python\PythonCore"
5
- if (Test-Path $pythonRegistryPath ) {
6
- Write-Output " Python already installed."
7
- } else {
8
- Write-Host " Installing Python, please wait..."
9
- $PYinstaller = " python-3.11.0-amd64.exe"
10
- $url = " https://www.python.org/ftp/python/3.11.0/$PYinstaller "
11
- download $url $PYinstaller
12
- Start-Process " $temp \$PYinstaller " - Wait - Args " /passive InstallAllUsers=1 PrependPath=1 Include_test=0"
13
- }
14
-
15
- check_for_pip ' requests'
16
- check_for_pip ' vdf'
17
- }
18
3
19
4
function generateGameLists {
20
- # Invoca la función generate_pythonEnv y redirige la salida a null
21
- generate_pythonEnv | Out-Null
5
+ Move-Item - Path " $storagePath /retrolibrary/assets/alekfull/carousel-icons " - Destination " $storagePath /retrolibrary/assets/default/carousel-icons " - Force
6
+ generate_pythonEnv * > $null
22
7
23
- # Obtiene la carpeta de usuario de Steam más reciente
24
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
25
- $destFolder = " $steamInstallPath /userdata$accountFolder /config/grid/retrolibrary/artwork"
26
- Write-Output " Starting to build database" | Set-Content - Path $MSG
8
+ $accountfolder = Get-ChildItem " $HOME /.steam/steam/userdata" | Sort-Object LastWriteTime - Descending | Select-Object - First 1
9
+ $dest_folder = " $accountfolder /config/grid/retrolibrary/artwork/"
27
10
28
- # Crea los directorios necesarios
29
- New-Item - ItemType Directory - Force - Path " $storagePath /retrolibrary/artwork"
30
- New-Item - ItemType Directory - Force - Path " $storagePath /retrolibrary/cache"
31
- New-Item - ItemType Directory - Force - Path " $accountFolder /config/grid/retrolibrary"
11
+ " Starting to build database " | Out-File - FilePath " $MSG "
12
+ New-Item - ItemType Directory - Path " $storagePath /retrolibrary/artwork" - Force
13
+ New-Item - ItemType Directory - Path " $storagePath /retrolibrary/cache" - Force
14
+ New-Item - ItemType Directory - Path " $accountfolder /config/grid/retrolibrary/ " - Force
32
15
33
- # Elimina archivos vacíos en el directorio de artwork
34
16
Get-ChildItem " $storagePath /retrolibrary/artwork" - File | Where-Object { $_.Length -eq 0 } | Remove-Item - Force
35
17
36
- # Crea junctions
37
- mkdir " $accountFolder /config/grid/retrolibrary" - ErrorAction SilentlyContinue
38
- $simLinkPath = " $steamInstallPath /userdata/$accountFolder /config/grid/retrolibrary/artwork"
39
- $emuSavePath = " $storagePath /retrolibrary/artwork"
40
- createSaveLink $simLinkPath $emuSavePath
41
-
42
- $simLinkPath = " $steamInstallPath /userdata/$accountFolder /config/grid/retrolibrary/cache"
43
- $emuSavePath = " $storagePath \retrolibrary\cache"
44
- createSaveLink $simLinkPath $emuSavePath
18
+ New-Item - ItemType SymbolicLink - Path " $accountfolder /config/grid/retrolibrary/artwork" - Target " $storagePath /retrolibrary/artwork" - Force
19
+ New-Item - ItemType SymbolicLink - Path " $accountfolder /config/grid/retrolibrary/cache" - Target " $storagePath /retrolibrary/cache" - Force
45
20
46
- # Llama a las funciones de descarga
47
21
generateGameLists_downloadAchievements
48
22
generateGameLists_downloadData
49
23
generateGameLists_downloadAssets
50
24
51
- # Sincroniza archivos usando RoboCopy
52
- robocopy " $emudeckBackend /roms/" " $storagePath /retrolibrary/artwork" / MIR / XD roms txt / SL
53
-
54
- # Configura las rutas de Pegasus
25
+ robocopy " $emudeckBackend /roms/" " $storagePath /retrolibrary/artwork" / E / XD roms txt
55
26
pegasus_setPaths
56
-
57
- Write-Output " Database built" | Set-Content - Path $MSG
58
-
59
- # Ejecuta el script de Python
60
27
python " $emudeckBackend /tools/retro-library/generate_game_lists.py" " $romsPath "
61
-
62
- # Llama a la función para manejar artwork en segundo plano
63
- # Start-Job { generateGameLists_artwork } | Out-Null
28
+ generateGameLists_artwork * > $null &
64
29
}
65
30
66
31
function generateGameListsJson {
67
- # Invoca la función generate_pythonEnv y redirige la salida a null
68
- generate_pythonEnv | Out-Null
69
-
70
- # Escribe mensajes en el archivo de mensaje
71
- Write-Output " Adding Games" | Set-Content - Path $MSG
72
- Write-Output " Games Added" | Set-Content - Path $MSG
73
-
74
- # Muestra el contenido del archivo JSON
32
+ generate_pythonEnv * > $null
33
+ " Adding Games" | Out-File - FilePath " $MSG "
34
+ " Games Added" | Out-File - FilePath " $MSG "
75
35
Get-Content " $storagePath /retrolibrary/cache/roms_games.json"
76
36
}
77
37
78
38
function generateGameLists_artwork {
79
- # Invoca la función generate_pythonEnv y redirige la salida a null
80
- generate_pythonEnv | Out-Null
81
-
82
- # Escribe mensaje inicial en el archivo de mensaje
83
- Write-Output " Searching for missing artwork" | Set-Content - Path $MSG
84
-
85
- # Ejecuta los scripts de Python para buscar y descargar artwork
39
+ generate_pythonEnv * > $null
40
+ " Searching for missing artwork" | Out-File - FilePath " $MSG "
86
41
python " $emudeckBackend /tools/retro-library/missing_artwork_platforms.py" " $romsPath " " $storagePath /retrolibrary/artwork"
87
42
python " $emudeckBackend /tools/retro-library/download_art_platforms.py" " $storagePath /retrolibrary/artwork"
88
-
89
- # Ejecuta los scripts de Python adicionales en segundo plano
90
- Start-Job {
91
- python " $emudeckBackend /tools/retro-library/missing_artwork_nohash.py" " $romsPath " " $storagePath /retrolibrary/artwork"
92
- python " $emudeckBackend /tools/retro-library/download_art_nohash.py" " $storagePath /retrolibrary/artwork"
93
- }
94
-
95
- # Escribe mensaje final en el archivo de mensaje
96
- Write-Output " Artwork finished. Restart if you see this message" | Set-Content - Path $MSG
43
+ python " $emudeckBackend /tools/retro-library/missing_artwork_nohash.py" " $romsPath " " $storagePath /retrolibrary/artwork"
44
+ python " $emudeckBackend /tools/retro-library/download_art_nohash.py" " $storagePath /retrolibrary/artwork" &
45
+ " Artwork finished. Restart if you see this message" | Out-File - FilePath " $MSG "
97
46
}
98
47
99
- function saveImage ($url , $name , $system ){
100
-
101
- # Obtiene la carpeta de usuario de Steam más reciente
102
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
103
- $accountFolder = $accountFolder.FullName
104
-
105
- # Define las rutas de destino
106
- $destFolder = " $storagePath /retrolibrary/artwork/$system /media/box2dfront/"
107
- $destPath = " $destFolder /$name .jpg"
108
-
109
- # Crea el directorio si no existe
110
- if (-not (Test-Path - Path $destFolder )) {
111
- New-Item - ItemType Directory - Force - Path $destFolder | Out-Null
112
- }
48
+ function saveImage {
49
+ param (
50
+ [string ]$url , [string ]$name , [string ]$system
51
+ )
113
52
114
- # Descarga la imagen desde la URL
115
- Invoke-WebRequest - Uri $url - OutFile $destPath - UseBasicParsing - Quiet
53
+ $accountfolder = Get-ChildItem " $HOME /.steam/steam/userdata" | Sort-Object LastWriteTime - Descending | Select-Object - First 1
54
+ $dest_folder = " $storagePath /retrolibrary/artwork/$system /media/box2dfront/"
55
+ $dest_path = " $dest_folder /$name .jpg"
56
+ Invoke-WebRequest - Uri $url - OutFile $dest_path
116
57
}
117
58
118
- function addGameListsArtwork ($file , $appID , $platform ){
59
+ function addGameListsArtwork {
60
+ param (
61
+ [string ]$file , [string ]$appID , [string ]$platform
62
+ )
119
63
120
- # Obtiene la carpeta de usuario de Steam más reciente
121
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
122
- $accountFolder = $accountFolder.FullName
123
- # Define las rutas de origen y destino
64
+ $accountfolder = Get-ChildItem " $HOME /.steam/steam/userdata" | Sort-Object LastWriteTime - Descending | Select-Object - First 1
124
65
$vertical = " $storagePath /retrolibrary/artwork/$platform /media/box2dfront/$file .jpg"
125
- $grid = $vertical
126
- $destinationVertical = " $accountFolder /config/grid/${appID} p.png"
127
- $destinationHero = " $accountFolder /config/grid/${appID} _hero.png"
128
- $destinationGrid = " $accountFolder /config/grid/${appID} .png"
66
+ $destination_vertical = " $accountfolder /config/grid/${appID} p.png"
67
+ $destination_hero = " $accountfolder /config/grid/${appID} _hero.png"
68
+ $destination_grid = " $accountfolder /config/grid/${appID} .png"
129
69
130
- # Elimina los archivos existentes en los destinos
131
- Remove-Item - Path $destinationVertical - Force - ErrorAction SilentlyContinue
132
- Remove-Item - Path $destinationHero - Force - ErrorAction SilentlyContinue
133
- Remove-Item - Path $destinationGrid - Force - ErrorAction SilentlyContinue
134
-
135
- # Crea enlaces simbólicos (junctions)
136
- createSaveLink $destinationVertical $vertical
137
- createSaveLink $destinationHero $grid
138
- createSaveLink $destinationGrid $grid
139
-
140
- }
141
-
142
- function generateGameLists_getPercentage {
143
- # Invoca la función generate_pythonEnv y redirige la salida a null
144
- generate_pythonEnv | Out-Null
145
-
146
- # Obtiene la carpeta de usuario de Steam más reciente
147
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
148
- $accountFolder = $accountFolder.FullName
149
- # Define las rutas necesarias
150
- $destFolder = " $storagePath /retrolibrary/artwork/"
151
- $jsonFile = " $storagePath /retrolibrary/cache/roms_games.json"
152
- $jsonFileArtwork = " $storagePath /retrolibrary/cache/missing_artwork_no_hash.json"
153
-
154
- # Ejecuta el script de Python para generar datos de artworks faltantes
155
- python " $emudeckBackend /tools/retro-library/missing_artwork_nohash.py" " $romsPath " " $destFolder " | Out-Null
156
-
157
- # Cargar y procesar los datos de JSON
158
- if (-Not (Test-Path $jsonFile ) -or -Not (Test-Path $jsonFileArtwork )) {
159
- Write-Output " Required JSON files are missing."
160
- return
161
- }
162
-
163
- # Leer el contenido de los archivos JSON
164
- $games = (Get-Content $jsonFile | ConvertFrom-Json | ForEach-Object { $_.games } | Measure-Object ).Count
165
- $artworkMissing = (Get-Content $jsonFileArtwork | ConvertFrom-Json | ForEach-Object { $_.games } | Measure-Object ).Count
166
-
167
- if ($games -eq 0 -or -Not $games ) {
168
- Write-Output " No games found in the JSON file."
169
- return
170
- }
171
-
172
- # Calcular juegos procesados y el porcentaje
173
- $parsedGames = $games - $artworkMissing
174
- $percentage = [math ]::Floor((100 * $parsedGames ) / $games )
175
-
176
- # Mostrar el resultado
177
- Write-Output " $parsedGames / $games ($percentage %)"
178
- }
179
-
180
-
181
-
182
-
183
- function generateGameLists_retroAchievements ($hash , $system ) {
184
-
185
- # Define la ruta local para los datos
186
- $localDataPath = " $storagePath /retrolibrary/achievements/$system .json"
187
-
188
- # Ejecuta el script de Python para gestionar retroachievements
189
- python " $emudeckBackend /tools/retro-library/retro_achievements.py" " $cheevos_username " " $hash " " $localDataPath "
190
- }
191
-
192
- function generateGameLists_downloadAchievements {
193
- # Define la carpeta de logros
194
- $folder = " $storagePath /retrolibrary/achievements"
195
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
196
- $accountFolder = $accountFolder.FullName
197
- $destFolder = " $accountFolder /config/grid/retrolibrary/achievements"
198
-
199
- # Comprueba si la carpeta existe, si no, la crea y descarga los datos
200
- if (-not (Test-Path - Path $folder )) {
201
- Write-Output " Downloading Retroachievements Data" | Set-Content - Path $MSG
202
- New-Item - ItemType Directory - Force - Path $folder | Out-Null
203
- createSaveLink $destFolder $folder
204
- download " https://bot.emudeck.com/achievements/achievements.zip" " achievements.zip"
205
- moveFromTo " $temp /achievements" " $storagePath \retrolibrary\achievements"
206
- Write-Output " Retroachievements Data Downloaded" | Set-Content - Path $MSG
207
- }
208
- }
70
+ Remove-Item - Path $destination_vertical - Force - ErrorAction SilentlyContinue
71
+ Remove-Item - Path $destination_hero - Force - ErrorAction SilentlyContinue
72
+ Remove-Item - Path $destination_grid - Force - ErrorAction SilentlyContinue
209
73
210
- function generateGameLists_downloadData {
211
- # Define la carpeta de datos
212
- $folder = " $storagePath /retrolibrary/data"
213
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
214
- $accountFolder = $accountFolder.FullName
215
- $destFolder = " $accountFolder /config/grid/retrolibrary/data"
216
-
217
- # Crea la carpeta y descarga los datos si no existe
218
- if (-not (Test-Path - Path $folder )) {
219
- Write-Output " Downloading Metadata" | Set-Content - Path $MSG
220
- New-Item - ItemType Directory - Force - Path $folder | Out-Null
221
- createSaveLink $destFolder $folder
222
- download " https://bot.emudeck.com/data/data.zip" " data.zip"
223
- moveFromTo " $temp /data" " $storagePath \retrolibrary\data"
224
- Write-Output " Metadata Downloaded" | Set-Content - Path $MSG
225
- }
74
+ New-Item - ItemType SymbolicLink - Path $destination_vertical - Target $vertical - Force
75
+ New-Item - ItemType SymbolicLink - Path $destination_hero - Target $vertical - Force
76
+ New-Item - ItemType SymbolicLink - Path $destination_grid - Target $vertical - Force
226
77
}
227
78
228
- function generateGameLists_downloadAssets {
229
- # Define la carpeta de assets
230
- $folder = " $storagePath /retrolibrary/assets"
231
- $accountFolder = Get-ChildItem " $steamInstallPath /userdata" - Directory | Sort-Object LastWriteTime - Descending | Select-Object - First 1
232
- $accountFolder = $accountFolder.FullName
233
- $destFolder = " $accountFolder /config/grid/retrolibrary/assets"
234
-
235
- # Crea la carpeta y descarga los assets si no existe
236
- if (-not (Test-Path - Path $folder )) {
237
- Write-Output " Downloading Assets" | Set-Content - Path $MSG
238
- New-Item - ItemType Directory - Force - Path $folder | Out-Null
239
- createSaveLink $destFolder $folder
240
- download " https://bot.emudeck.com/assets/alekfull/alekfull.zip" " alekfull.zip"
241
- moveFromTo " $temp /alekfull" " $storagePath \retrolibrary\assets"
242
- Write-Output " Assets Downloaded" | Set-Content - Path $MSG
243
- }
244
- }
79
+ Set-Alias generateGameLists generateGameLists
80
+ Set-Alias generateGameListsJson generateGameListsJson
81
+ Set-Alias generateGameLists_artwork generateGameLists_artwork
82
+ Set-Alias saveImage saveImage
83
+ Set-Alias addGameListsArtwork addGameListsArtwork
0 commit comments