OPL Manager para Linux em SHELL
Publicado por José Lucas (última atualização em 09/09/2020)
[ Hits: 8.165 ]
Homepage: https://github.com/NIDObr
Olá, fiz este script para ser usado em conjunto com o OPL, maiores informações sobre o OPL:
https://www.ps2-home.com/forum/app.php/portal
Ele altera/formata o nome dos jogos para ser usado com o OPL e gerencia as arts dos jogos, funciona com ISOs de PS2 e VCDs de PS1, ainda falta muita coisa.
Poderiam avaliar como o script está? Valeu VOL!
GitHub: https://github.com/NIDObr/Nido_oplmanager
#!/bin/bash
#------------------------------------------------------------------
# Author: nido
# More: < https://github.com/NIDObr >
# Version: 0.1.6-beta 06/09/2020
# Tested on:
# GNU bash, versão 4.4.20(1)-release (x86_64-pc-linux-gnu)
# Info: OPL MANAGER for linux
# License: GPLv3+
#------------------------------------------------------------------
#----------------------------Vars----------------------------------
[ -e "$1" ] && {
opl_path="$1" # OPL Path
} || {
opl_path='/media/hd2_160/samba/opl' # OPL Path
#opl_path='/media/sd64/ps2opl' # OPL Path
}
arts_path='/media/hd2_160/samba/opl/ART/PS2/' # ARTS Path
tmp_list="/tmp/${RANDOM}" # TMP file
#----------------------------Functions-----------------------------
game_manager(){
if $(echo "$1" | egrep -q "([A-Z]{4}\_[0-9]{3}\.[0-9]{2}\.([A-Z|a-z|0-9| |\-]|[\(\)\.\!\'\,]){1,}\.[a-z|A-Z]{3})");then # Check if the name is already formatted
return 2
else
local id=$(cat "$1" | egrep -a -o -m 1 "([A-Z]{4}\_[0-9]{3}\.[0-9]{2})") # Extract the game ID
[ -z "$id" ] && return 3 # Check if you have a valid ID.
fi
local id_data=$(printf '%s\n' "${id}" | awk -F "_" '{print $2}' | awk -F "." '{print $1$2}') # convert the format used in the database (from: 213.12 to: 21312)
local url_db='https://psxdatacenter.com/' # main "database" url
local pal_2='psx2/plist2.html'
local ntsc_e2='psx2/jlist2.html'
local ntsc_u2='psx2/ulist2.html'
local pal_1='plist.html'
local ntsc_u1='ulist.html'
local ntsc_j1='jlist.html'
local disc="$3"
local cont='1'
local pre='0'
case "${disc}" in
"/DVD/"|"/CD/")
for db_region in "${ntsc_u2}" "${ntsc_e2}" "${pal_2}";do
local info=$(curl "${url_db}${db_region}" 2>&1 | grep -a -m 1 "${id_data}") # check if the game is in the database
if $(printf '%s\n' "$info" | grep -q "INFO");then
local info_url=$(printf '%s\n' "${info}" | awk -F "\"" '{print $10}')
local name=$(curl "${url_db}/psx2/${info_url}" 2>&1 | grep -A 2 "OFFICIAL TITLE" | grep "nbsp;" | awk -F ";" '{print $2}' | awk -F "<" '{print $1}')
echo "$name"
break
fi
local name=$(curl "${url_db}${db_region}" 2>&1 | grep -a -A 1 "${id_data}" | grep "nbsp" | awk -F ";" '{print $2}' | awk -F "<" '{print $1}') # get the name of the database
break
done
;;
"/POPS/")
for db_region in "${ntsc_u1}" "${ntsc_j1}" "${pal_1}";do
local info=$(curl "${url_db}${db_region}" 2>&1 | grep -a -m 1 "${id_data}") # check if the game is in the database
if $(printf '%s\n' "${info}" | grep -q "INFO");then
local info_url=$(printf '%s\n' "${info}" | awk -F "\"" '{print $10}')
local info_page=$(curl -s "${url_db}${info_url}" 2>&1)
local name=$(printf '%s\n' "${info_page}" | grep -A 2 "Official Title" | grep "nbsp;" | awk -F ";" '{print $2}' | awk -F '<' '{print $1}')
break
fi
local name=$(curl "${url_db}${db_region}" 2>&1 | grep -a -A 1 "${id_data}" | grep "nbsp" | awk -F ";" '{print $2}' | awk -F "<" '{print $1}') # get the name of the database
break
done
;;
esac
if [ -z "${name}" ];then # If the game is not in the database, just add the ID.
printf '%s\n' "Jogo não encontrado no banco de dados: "
new_name="${id}.$(echo "${1}" | awk -F "${disc}" '{print $2}' | awk -F "." '{print $1}')"
else
new_name="${id}.${name}"
fi
if [ "${disc}" = "/POPS/" ];then # Change the extension.
local format="VCD"
mkdir "${2}${disc}${new_name}/"
else
local format="iso"
fi
printf '%s\n' "After: ` printf "${1}" | awk -F "\/" '{print $7}'`"
printf '%s\n' "Before: ${new_name}.${format}"
printf '%s\n\n' "ID: ${id}"
mv "${1}" "${2}${disc}${new_name}.${format}" # Rename the game.
art_manager "${4}" "${2}" "${id}"
}
art_manager(){
cp "${1}${3}/"* "${2}/ART/"
for prefix in "BG" "SCR" "COV" "ICO" "LAB" "LGO";do
for artname in $(ls "${2}/ART/" | egrep "${prefix}(\_[0-9]{2})");do
pre=$(printf '%s\n' "$artname" | egrep -o "(\_[0-9]{2}\.)")
case "${pre}" in
"_00.")
new_art=$(printf '%s\n' $artname | sed -r s/_00././g)
mv ${2}/ART/$artname ${2}/ART/$new_art
;;
"_01.")
if [ "$prefix" = "BG" ];then
rm "${2}/ART/${artname}"
else
new_art=$(printf '%s\n' $artname | sed -r s/_01./1./g)
mv ${2}/ART/$artname ${2}/ART/$new_art
fi
;;
*)rm "${2}/ART/${artname}";;
esac
done
done
}
#----------------------------Header--------------------------------
> "${tmp_list}"
for disc_type in "/DVD/" "/CD/" "/POPS/";do # Check the directories for games
if [ "${disc_type}" = "/POPS/" ];then # If it is PS1 run:
for pops in $(ls "${opl_path}${disc_type}"*.VCD | sed -r 's/ /+_/g');do
old_name=$(printf '%s\n' "${pops}" | sed -r 's/\+\_/ /g') # Old name
game_manager "$old_name" "${opl_path}" "${disc_type}" "${arts_path}" # Call main function
done
else
for dvd in $(ls "${opl_path}${disc_type}"*.iso | sed -r 's/ /+_/g');do # If it is PS2 run:
old_name=$(printf '%s\n' "${dvd}" | sed -r 's/\+\_/ /g') # Old name
game_manager "$old_name" "${opl_path}" "${disc_type}" "${arts_path}" # Call main function
done
fi
done
rm "${tmp_list}"
Script para trocar textos em arquivos
Pegando IP sem saber qual interface está sendo usada
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Novos apps de produtividade, avanços em IA e distros em ebulição agitam o universo Linux
Como instalar o repositório do DBeaver no Ubuntu
Como instalar o Plex Media Server no Ubuntu
Digitando underscore com "shift" + "barra de espaços"
Como ativar a lixeira e recuperar aquivos deletados em um servidor Linux
Como mudar o nome de dispositivos Bluetooth via linha de comando
Problemas com Driver NVIDIA (0)
Programa fora de escala na tela do pc (19)
Fedora KDE plasma 42 X Módulo de segurança BB (Warsaw-2) (1)









