[Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Come up with a useful post-processing script? Share it here!
Post Reply
User avatar
Ski-lleR
Newbie
Newbie
Posts: 2
Joined: May 14th, 2012, 1:29 pm

[Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by Ski-lleR »

Hi

Based on this :
http://forums.sabnzbd.org/viewtopic.php?f=9&t=1735

Created a script with :
- Abgx check of 360 ISO
- extract-xiso of 360 ISO to user defined folder
- Moving of DLC/XBLA to user defined folder
- Handling of multi-disc game
- A lot of settings for customize ABGX & extract-xiso

English version (not perfect since i'm french):

Code: Select all

#!/bin/bash
# $1 (source folder) provided by sabnzbd+

# ---------- Users settings

# Check iso with ABGX
# Possible choice:
#   > 0: No
#   > 1: Yes
ABGX=1

# Extract ISO with extract-xiso
# Possible choice:
#   > 0: No
#   > 1: Yes
XISO=1

# Where to extract iso
isoFolder="/home/user/Download/Xbox 360/ISO"

# Where to move DLC (additionnal content for game)
dlcFolder="/home/user/Download/Xbox 360/DLC"

# Where to move XBLA
xblaFolder="/home/user/Download/Xbox 360/XBLA"

# ABGX options

# Verbosity level
# Possible choice:
#   > 0: Low
#   > 1: Standard
#   > 2: High
VERBOSITY_ABGX=2

# Always check for AnyDVD corrupt
# Possible choice:
#   > 0: No
#   > 1: Yes
AnyDVD=1

# Verify/Fix non padded video partition (useless)
# Possible choice:
#   > 0: No
#   > 1: Yes
VideoPadding=0

# Verify/Create .dvd file (useless when game are transfered to hdd)
# Possible choice:
#   > 0: No
#   > 1: Yes
DvdCheck=0

# Verify game partition CRC (Recommanded)
# Possible choice:
#   > 0: If necessary
#   > 1: Always
#   > 2: Never
CrcCheck=0

# Autofix method (Suggested: 3)
# Possible choice:
#  > 0: Disabled
#  > 1: If stealth failed
#  > 2: If stealth is uncertain and fails verification
#  > 3: If stealth pass but fails verification (recommanded for downloaded iso)
AutoFix=3

# Language used when displaying strings from the title id resource
# Possible choice:
#  > 1: English
#  > 2: Japanese
#  > 3: German
#  > 4: French
#  > 5: Spanish
#  > 6: Italian
#  > 7: Korean
#  > 8: Traditional chinese
#  > 9: Portuguese
#  > 10: Simplified chinese
#  > 11: Polish
#  > 12: Russian
Language=1


# extract-xiso options

# Verbosity level
# Possible choice:
#   > 0: Full silent
#   > 1: Only error
#   > 2: Standard
VERBOSITY_XISO=1

# Don't extract $SystemUpdate folder
# Possible choice:
#   > 0: No
#   > 1: Yes
SkipSystemUpdate=1

# ---------- End of users settings

# Don't touch after this (except if you know what you do ^^)

case $VERBOSITY_ABGX in
	0) VERBOSITY_ABGX="--noverbose" ;;
	1) VERBOSITY_ABGX="" ;;
	2) VERBOSITY_ABGX="--verbose" ;;
	*) VERBOSITY_ABGX="" ;;
esac

case $AnyDVD in
	0) AnyDVD="" ;;
	1) AnyDVD="--corrupt" ;;
	*) AnyDVD="" ;;
esac

case $VideoPadding in
	0) VideoPadding="" ;;
	1) VideoPadding="--padding" ;;
	*) VideoPadding="" ;;
esac

case $DvdCheck in
	0) DvdCheck="--nodvdcheck" ;;
	1) DvdCheck="" ;;
	*) DvdCheck="" ;;
esac

case $CrcCheck in
	0) CrcCheck="" ;;
	1) CrcCheck="--gamecrc" ;;
	2) CrcCheck="--nogamecrc" ;;
	*) CrcCheck="" ;;
esac

case $AutoFix in
	0) AutoFix="--noautofix" ;;
	1) AutoFix="--autofixfailed" ;;
	2) AutoFix="" ;;
	3) AutoFix="--autofixalways" ;;
	*) AutoFix="--autofixalways" ;;
esac

# Raw settings used for ABGX, set by user, with some other :
# --stripcolors > Because log is used by Sabnzbd, we disable color
# --csv > Update csv, used for display additional game information
# --splitvid > Check if the ISO is splitvid
ABGX_OPTIONS="$VERBOSITY_ABGX $AnyDVD $VideoPadding $DvdCheck $CrcCheck $AutoFix $Language --stripcolors --csv --splitvid"

case $VERBOSITY_XISO in
	0) VERBOSITY_XISO="-Q" ;;
	1) VERBOSITY_XISO="-q" ;;
	2) VERBOSITY_XISO="" ;;
	*) VERBOSITY_XISO="" ;;
esac

case $SkipSystemUpdate in
	0) SkipSystemUpdate="" ;;
	1) SkipSystemUpdate="-s" ;;
	*) SkipSystemUpdate="" ;;
esac

# Raw settings used by EXTRACT-XISO, set by user
XISO_OPTIONS="$SkipSystemUpdate $VERBOSITY_XISO"

# If folder provided by SABNZBD contain _FAILED_, delete it and exit script
FAILED_TEST=`find "$1" -type d \( -iname "*_FAILED_*" \) -print`
if [ "$FAILED_TEST" ] ; then
echo "failed download detected, deleting downloaded folder and exit script"
rm -Rf "$1"
exit
fi

# If folder provided by SABNZBD contain "DLC" or "XBLA", move it to folder specified in user settings
case "$1" in 
  *XBLA*)
   echo "XBLA detected, moving to $xblaFolder"
   mv "$1" "$xblaFolder"
   exit
    ;;
  *DLC*)
   echo "DLC detected, moving to $dlcFolder"
   mv "$1" "$dlcFolder"
   exit
    ;;
esac

# Rename file terminaded with .000 to .iso
if [ `find . -size +5000000k -regex '.*/.*\.000' ` ] ; then
   OLD_000="$FOLDER_PATH`find . -regex '.*/.*\.000' | sort | sed -n '1p' | sed 's/^\.//'`"
   RENAME_ISO="$FOLDER_PATH`find . -regex '.*/.*\.000' | sed 's/000/iso/' | sed -n '1p' | sed 's/^\.//'`"
   mv "$OLD_000" "$RENAME_ISO"
   rm "$FOLDER_PATH"/*.dvd
fi

# If we find .iso > 5 GB
if [ `find "$1" -size +5000000k -regex '.*/.*\.iso' | wc -l` -eq 1 ] ; then

   # Launch ABGX if activated by user
   if [ $ABGX -eq 1 ] ; then

      # For each .iso file
      find "$1" -regex '.*/.*\.iso' | while read FILENAME;
      do

      echo "Launching ABGX for $1/${FILENAME##*/}"

      # Launch abgx360 with user settings
      /usr/local/bin/abgx360 $ABGX_OPTIONS "$1"/${FILENAME##*/} | tee -a "$1"/${FILENAME##*/}_abgx360.txt

      # If abgx say verification is valid
      if grep "was successful!" "$1"/${FILENAME##*/}_abgx360.txt > /dev/null; then
           
           echo "Valid iso!"

           # Browse abgx log to obtain number of disc for this game and current disc number
           while read line  
	   do
                if [[ "$line" == *"Disc Number"* ]] ; then
                tmp=${line//[^[:digit:]]/}
                currentDisc=${tmp:0:1}
                discQuantity=${tmp:1:1}
                break
		fi
	   done < "$1"/${FILENAME##*/}_abgx360.txt

           if [ $XISO -eq 1 ] ; then
                # Folder where game will be extracted is folder specified for "isoFolder", followed by name in ABGX
                # For example, "/home/user/Download/Xbox 360/ISO/My_GAME_RF_XBOX360-KFC"
                currentFolderName=${1##*/}
                extractFolder="$isoFolder"/"$currentFolderName"

                # If it's a multi-disc game, directory where game is extracted look like :
                # GameName/disc 1
                # GameName/disc 2
                # ...
                #
                # so FreeStyle Dash can use disc swap automatically
                # For example, "/home/user/Download/Xbox 360/ISO/My_GAME_RF_XBOX360-KFC/disc 1"
                if [ $discQuantity -gt 1 ] ; then
                     extractFolder="$extractFolder/disc $currentDisc"
                     echo "It's a multi-disc game, directory will be conform to FreeStyle dash swap function!"
                fi

                # Create extract folder
                mkdir -p "$extractFolder"

                echo "Extract iso [$1/${FILENAME##*/}] to [$dossierExtraction]"

	        # Extract the game with extract-xiso if activated by user
                /bin/extract-xiso -d "$dossierExtraction" -x $XISO_OPTIONS "$1"/${FILENAME##*/}
           fi
      fi
      done
   fi
else
   echo "Non-Xbox 360 detected (size < 5 GB), cancelling abgx360/extract-xiso"
fi
French Version :

Code: Select all

#!/bin/bash
# $1 (dossier source) est fournis par sabnzbd+

# ---------- Paramètres utilisateurs

# Vérifier les ISO avec ABGX
# Choix possible:
#   > 0: Non
#   > 1: Oui
ABGX=1

# Décompresser les ISO avec extract-xiso
# Choix possible:
#   > 0: Non
#   > 1: Oui
XISO=1

# Dossier ou seront décompressé les isos
dossierISO="/home/utilisateur/Telechargement/Xbox 360/ISO"

# Dossier ou seront déplacé les DLC (contenu supplémentaire pour les jeux)
dossierDLC="/home/utilisateur/Telechargement/Xbox 360/DLC"

# Dossier ou seront déplacé les Xbox Live Arcade
dossierXBLA="/home/utilisateur/Telechargement/Xbox 360/XBLA"

# Options pour ABGX

# Quantité d'information renvoyé
# Choix possible:
#   > 0: Basse
#   > 1: Moyenne
#   > 2: Elevé
VERBOSITE_ABGX=2

# Toujours vérifier si le jeu souffre de la corruption AnyDVD
# Choix possible:
#   > 0: Non
#   > 1: Oui
AnyDVD=1

# Vérifier/Corriger les partitions vidéos non séparées par des zéros (inutiles)
# Choix possible
#   > 0: Non
#   > 1: Oui
VideoPadding=0

# Vérifier/Créer le fichier .dvd (inutiles quand les jeux sont transférer sur le disque dur)
# Choix possible:
#   > 0: Non
#   > 1: Oui
DvdCheck=0

# Vérifier le CRC de la partition de jeu (Vivement conseillé)
# Choix possible:
#   > 0: Si nécessaire
#   > 1: Toujours
#   > 2: Jamais
CrcCheck=0

# Type de correction automatique (Conseil: 3)
# Choix possible:
#  > 0: Désactivée
#  > 1: Si "stealth failed"
#  > 2: Si "stealth" incertains et que la vérification échoue
#  > 3: Si "stealth" ok mais que la vérification échoue (recommandé pour les iso téléchargés)
AutoFix=3

# Langue utilisée pour afficher les informations depuis les ressources
# Choix possible:
#  > 1: Anglais
#  > 2: Japonnais
#  > 3: Allemand
#  > 4: Français
#  > 5: Espagnol
#  > 6: Italien
#  > 7: Coréen
#  > 8: Chinois traditionnel
#  > 9: Portugais
#  > 10: Chinois simplifié
#  > 11: Polonais
#  > 12: Russe
Langue=4


# Options pour extract-xiso

# Quantité d'information renvoyé
# Choix possible:
#   > 0: Totalement silencieux
#   > 1: Seulement en cas d'erreur
#   > 2: Standard
VERBOSITE_XISO=1

# Ne pas extraire le dossier $SystemUpdate
# Choix possible
#   > 0: Non
#   > 1: Oui
SkipSystemUpdate=1

# ---------- Fin des paramètres utilisateurs

# Ne pas touché à partir d'ici (sauf si vous maitrisez les bash scripts évidemments ^^)

case $VERBOSITE_ABGX in
	0) VERBOSITE_ABGX="--noverbose" ;;
	1) VERBOSITE_ABGX="" ;;
	2) VERBOSITE_ABGX="--verbose" ;;
	*) VERBOSITE_ABGX="" ;;
esac

case $AnyDVD in
	0) AnyDVD="" ;;
	1) AnyDVD="--corrupt" ;;
	*) AnyDVD="" ;;
esac

case $VideoPadding in
	0) VideoPadding="" ;;
	1) VideoPadding="--padding" ;;
	*) VideoPadding="" ;;
esac

case $DvdCheck in
	0) DvdCheck="--nodvdcheck" ;;
	1) DvdCheck="" ;;
	*) DvdCheck="" ;;
esac

case $CrcCheck in
	0) CrcCheck="" ;;
	1) CrcCheck="--gamecrc" ;;
	2) CrcCheck="--nogamecrc" ;;
	*) CrcCheck="" ;;
esac

case $AutoFix in
	0) AutoFix="--noautofix" ;;
	1) AutoFix="--autofixfailed" ;;
	2) AutoFix="" ;;
	3) AutoFix="--autofixalways" ;;
	*) AutoFix="--autofixalways" ;;
esac

# Les paramètres fournis à ABGX, défini par l'utilisateur un peu plus haut, avec en plus :
# --stripcolors > Le log sera affiché dans sabnzbd, qui ne prendra pas en compte la couleur
# --csv > Permet de mettre à jour le csv, qui est utilisé pour afficher les informations détaillés sur le jeu
# --splitvid > Vérifie que le jeu est bien splitvid
ABGX_OPTIONS="$VERBOSITE_ABGX $AnyDVD $VideoPadding $DvdCheck $CrcCheck $AutoFix $Langue --stripcolors --csv --splitvid"

case $VERBOSITE_XISO in
	0) VERBOSITE_XISO="-Q" ;;
	1) VERBOSITE_XISO="-q" ;;
	2) VERBOSITE_XISO="" ;;
	*) VERBOSITE_XISO="" ;;
esac

case $SkipSystemUpdate in
	0) SkipSystemUpdate="" ;;
	1) SkipSystemUpdate="-s" ;;
	*) SkipSystemUpdate="" ;;
esac

# Les paramètres fournis à EXTRACT-XISO, défini par l'utilisateur un peu plus haut
XISO_OPTIONS="$SkipSystemUpdate $VERBOSITE_XISO"

# Si le dossier fournis par SABNZBD contient la mention _FAILED_, le supprimé et quitté le script
FAILED_TEST=`find "$1" -type d \( -iname "*_FAILED_*" \) -print`
if [ "$FAILED_TEST" ] ; then
echo "telechargement echoue detecte, lancement du script de traitement de traitement de contenu Xbox 360 annule, suppression de l'image"
rm -Rf "$1"
exit
fi

# Si le dossier créé par sabnzbd contient "DLC" ou "XBLA", le déplacé dans le dossier spécifié plus haut par l'utilisateur
case "$1" in 
  *XBLA*)
   echo "XBLA detecte, deplacement dans le dossier $dossierXBLA"
   mv "$1" "$dossierXBLA"
   exit
    ;;
  *DLC*)
   echo "DLC detecte, déplacement dans le dossier $dossierDLC"
   mv "$1" "$dossierDLC"
   exit
    ;;
esac

# Remplace l'extension des ISO se terminant par .000 en .iso
if [ `find . -size +5000000k -regex '.*/.*\.000' ` ] ; then
   OLD_000="$FOLDER_PATH`find . -regex '.*/.*\.000' | sort | sed -n '1p' | sed 's/^\.//'`"
   RENAME_ISO="$FOLDER_PATH`find . -regex '.*/.*\.000' | sed 's/000/iso/' | sed -n '1p' | sed 's/^\.//'`"
   mv "$OLD_000" "$RENAME_ISO"
   rm "$FOLDER_PATH"/*.dvd
fi

# S'il y a des fichiers .iso de plus de 5 go
if [ `find "$1" -size +5000000k -regex '.*/.*\.iso' | wc -l` -eq 1 ] ; then

   # Lance ABGX si activé dans les options utilisateurs
   if [ $ABGX -eq 1 ] ; then

      # Pour chaque fichier .iso
      find "$1" -regex '.*/.*\.iso' | while read FILENAME;
      do

      echo "Lancement de ABGX pour $1/${FILENAME##*/}"

      # Lancer abgx360 avec les options utilisateurs
       /usr/local/bin/abgx360 $ABGX_OPTIONS "$1"/${FILENAME##*/} | tee -a "$1"/${FILENAME##*/}_abgx360.txt

      # Si abgx indique une réussite de la vérification
      if grep "was successful!" "$1"/${FILENAME##*/}_abgx360.txt > /dev/null; then
           
           echo "L'iso est valide!"

           # Parcourir le log d'abgx afin de récupérer le nombre de disque ainsi que le disque actuel
           while read ligne  
	   do
                if [[ "$ligne" == *"Disc Number"* ]] ; then
                tmp=${ligne//[^[:digit:]]/}
                discActuel=${tmp:0:1}
                nombreDisque=${tmp:1:1}
                break
		fi
	   done < "$1"/${FILENAME##*/}_abgx360.txt

           if [ $XISO -eq 1 ] ; then
                # Le répertoire ou sera décompresser le jeu sera le chemin spécifié pour "dossierISO", suivi du nom dans ABGX
                # Par exemple, "/home/utilisateur/Telechargement/Xbox 360/ISO/MonJeu_RF_XBOX360-KFC"
                nomDuDossierActuel=${1##*/}
                dossierExtraction="$dossierISO"/"$nomDuDossierActuel"

                # S'il y a plus d'un disque, l'arborescence ou sera décompresser le jeu ressemblera à :
                # NomDuJeu/disc 1
                # NomDuJeu/disc 2
                # ...
                #
                # afin de permettre à FreeStyle Dash de faire fonctionner les jeux multi-disques
                # Par exemple, "/home/utilisateur/Telechargement/Xbox 360/ISO/MonJeu_RF_XBOX360-KFC/disc 1"
                if [ $nombreDisque -gt 1 ] ; then
                     dossierExtraction="$dossierExtraction/disc $discActuel"
                     echo "C'est un jeu multi-disque, l'arborescence sera adapte pour fonctionner avec FreeStyle Dash!"
                fi

                # On créer le dossier ou sera décompresser le jeu
                mkdir -p "$dossierExtraction"

                echo "Decompression de l'iso [$1/${FILENAME##*/}] dans le dossier [$dossierExtraction]"

	        # On décompresse le jeu avec extract-xiso si activé dans les options utilisateurs
                /bin/extract-xiso -d "$dossierExtraction" -x $XISO_OPTIONS "$1"/${FILENAME##*/}
           fi
      fi
      done
   fi
else
   echo "Iso Non-Xbox360 détecté (taille inférieur à 5 go), lancement de abgx360/extract-xiso annulé"
fi
Feel free to optimize it (i know it's ugly) & repost (i'm not a bash scripter, but c++ dev)

Edit :
15/05/12
- Fixed bug with abgx/extract-xiso launch (using full path instead of just app name)
- Fixed bug with mkdir (not quoted)
- Replaced pwd with ${1##*/} to get download folder name from path
Image
La sincérité est la perle qui se forme dans le coquillage du coeur
gilou
Newbie
Newbie
Posts: 1
Joined: June 20th, 2012, 9:52 am

Re: [Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by gilou »

English version (not perfect since i'm french):

Good job man, thank you very much.
And your code is not so ugly at all !!!

French Version :
Aucun reply sur ce script !! Comment on est passé à coté ? C'est pas possible !! Ton script fait "la totale" il ne manque plus qu'il joue au jeu à notre place. Franchement, une super idée, un grand merci à toi. Je me suis inscrit juste pour te poster ça.
Comme quoi le nb de réponse n'est franchement pas représentatif de l'intérêt d'un script !!!
Bravo encore et à bientôt pour la V2 (abgx360 + extract-xiso + play)
User avatar
Ski-lleR
Newbie
Newbie
Posts: 2
Joined: May 14th, 2012, 1:29 pm

Re: [Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by Ski-lleR »

Thanks gilou ^^

Just some thing need to be corrected.

Bug
-------------------------
- .000 are not renamed to .iso (bug in script), so script is never executed on this file.

Improvement
-------------------------
- Search in all subfolder of root item path, because currently it's only in root item path
- Folder for script output log, instead of iso folder. So deleting folder when extracted correctly don't destroy abgx/extract-xiso log

Addin
-------------------------
- Delete iso AND/OR root item path if all iso (in case of multidisc) are OK & extracted correctly.
- (joke) AutoPlay script (yeah, computer love play to xbox 360 ;D)

Remember to create .nzb containing all the dvd iso of multi-disc game, so my script can extract them in Freestyle Dash style (disc 1, disc 2 folder etc...). Will post an improved version soon
Image
La sincérité est la perle qui se forme dans le coquillage du coeur
rossta
Newbie
Newbie
Posts: 1
Joined: August 12th, 2012, 3:48 am

Re: [Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by rossta »

hey,
you need to change the $dossierExtraction instances in the English version to $extractFolder instead - taken me ages to figure out why it hasn't been extracting my xiso's !!

great script btw - as per your post, would love to see a finished Multi-disc option in there (looks like it only goes as far as extracting the first disc at the moment) and would also love to be able to have an option to force XISO in case ABGX360 doesnt find a verified rip in its database (but the game is actually ok).

other than that, looking forward to more updates on this - very useful thanks :)
Hairybiker
Jr. Member
Jr. Member
Posts: 50
Joined: October 24th, 2011, 4:18 am

Re: [Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by Hairybiker »

I had this very problem, it is because there is more than one iso in the folder.
Change line 198 to read
if [ `find "$1" -size +5000000k -regex '.*/.*\.iso' | wc -l` -ge 1 ] ; then

i.e. change the -eq 1 to -ge 1

It is looking for a single iso (eq 1) now it will look for all the iso's.
Kuchhogya
Newbie
Newbie
Posts: 1
Joined: February 13th, 2016, 4:59 am

Re: [Linux] Check & Extract 360 ISO (abgx360 + extract-xiso)

Post by Kuchhogya »

so my script can extract them in Freestyle Dash style (disc 1, disc 2 folder etc...). Will post an improved version soon????



== www.chessrivals.net ==
Post Reply