Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- releaseDate=14.09.2017
- echo "fastscraper ver. $releaseDate"
- # Set ScreenScraper credentials
- username=""
- password=""
- # Interface language selection (auto, es, de, fr, en)
- lang=auto
- # Flags - Static parameters
- # If true, add roms that are not found as an empty gamelist entry.
- addNotFound=-add_not_found=false
- # Comma separated order to prefer images, s=snapshot, b=boxart, f=fanart, a=banner, l=logo, 3b=3D boxart, cart=cartridge, clabel=cartridge label, mix3=Standard 3 mix, mix4=Standard 4 mix. (default "b")
- consoleImg=-console_img="mix3,b,s"
- # Comma seperated order to prefer console sources, ss=screenscraper, ovgdb=OpenVGDB, gdb=theGamesDB (default "gdb")
- consoleSrc=-console_src="ss"
- # If true, convert videos for the Raspberry Pi (e.g. 320x240@30fps) NOTE: This needs HandBrakeCLI installed
- convertVideo=-convert_videos="true"
- # If false, don't download any images, instead see if the expected file is stored locally already. (default true)
- downloadImg=-download_images=true
- # If true, download marquees.
- downloadMarquee=-download_marquees="false"
- # If true, download videos.
- downloadVideo=-download_videos="false"
- # Comma separated list of extensions to also include in the scraper.
- extraExt=-extra_ext=".scummvm,.ipf,.mx1,.mx2,.exe,.ws,.wsc,.wad,.dsk,.tap,.trd,.tzx,.z80,.p,.a0,.crt,.nib,.do,.po"
- # jpg or png, the format to write the images. (default "jpg")
- imgFormat=-img_format="png"
- # The path to use for images in gamelist.xml. (default "images")
- imagePath=-image_path="./downloaded_images"
- # The suffix added after rom name when creating image files. (default "-image")
- imageSuffix=-image_suffix="-image"
- # The order to choose for language if there is more than one for a value. (en, fr, es, de, pt) (default "en")
- langSS=-lang="en,es,pt,de,fr"
- # Comma separated order to prefer images, s=snap, t=title, m=marquee, c=cabniet, b=boxart, 3b=3D-boxart, fly=flyer. (default "t,m,s,c")
- mameImg=-mame_img="b,s,fly,m,t"
- # Comma seperated order to prefer mame sources, ss=screenscraper, adb=arcadeitalia, mamedb=mamedb-mirror, gdb=theGamesDB-neogeo (default "adb,gdb")
- mameSrc=-mame_src="ss"
- # jpg or png, the format to write the marquees. (default "png")
- marqueeFormat=-marquee_format="png"
- # The path to use for marquees in gamelist.xml. (default "images")
- marqueePath=-marquee_path="./downloaded_images"
- # The suffix added after rom name when creating marquee files. (default "-marquee")
- marqueeSuffix=-marquee_suffix="-marquee"
- # The max height of images. Larger images will be resized.
- maxHeight=-max_height=0
- # The max width of images. Larger images will be resized. (default 400)
- maxWidth=-max_width=400
- # Don't add thumbnails to the gamelist.
- noThumb=-no_thumb=true
- # Download the thumbnail for both the image and thumb (faster). (default "false")
- thumbOnly=-thumb_only=false
- # Information will be attempted to be downloaded again but won't remove roms that are not scraped.
- refreshXML=-refresh=false
- # The order to choose for region if there is more than one for a value. xx is a special region that will choose any region. (default "us,wor,eu,jp,fr,xx")
- regionSS=-region="us,wor,eu,jp,fr,xx"
- # The `username` for registered ScreenScraper users.
- username=-ss_user=$username
- # The `password` for registered ScreenScraper users.
- password=-ss_password=$password
- # If true, use the filename minus the extension as the game title in xml.
- useFilename=-use_filename=false
- # Use the name in the No-Intro DB instead of the one in the GDB. (default true)
- useNoIntroName=-use_nointro_name=true
- # The path to use for videos in gamelist.xml. (default "images")
- videoPath=-video_path="./downloaded_images"
- # The suffix added after rom name when creating video files. (default "-video")
- videoSuffix=-video_suffix="-video"
- # Use N worker threads to process roms. (default 1)
- workersN=-workers=4
- # Create dictionary
- # Get OS's language
- if [ -f "/recalbox/share/system/recalbox.conf" ]; then
- language=$(grep '^system.language' /recalbox/share/system/recalbox.conf | cut -d '=' -f 2 | cut -d '_' -f 1)
- else
- language=$(locale | grep 'LANG=' | cut -d '=' -f2 | cut -d '"' -f2 | cut -d '_' -f1)
- fi
- # Select dictionary
- if [[ "$lang" =~ ^(es|de|fr|en)$ ]]; then language=$lang
- case $language in
- es)
- dict=('ERROR: Sin conexión a internet. Saliendo...' 'no es una plataforma soportada.' 'ERROR: Imposible descargar el scraper. Saliendo...' 'ERROR: Imposible descomprimir el scraper. Saliendo...' 'ERROR: Imposible comprobar actualizaciones en GitHub.' 'Actualizando sselph scraper de' 'a' ', espere por favor...' 'Descargando sselph scraper' 'Abriendo Explorador de Carpetas...' 'Explorador de Carpetas para' ' aun no implementado, lo siento!' 'Carpeta de roms seleccionada:' 'No olvides detener EmulationStation antes de scrapear!' '¿Qué sistema(s) desea scrapear? Escriba "all" para todos los sistemas o "cd" para abrir el navegador de carpetas.' 'Entrada incorrecta!' '¿Deseas anexar los gamelists existentes? [Y/N]:' 'Scrapeando' 'en progreso. Espere por favor...' 'Inicio' 'Fin' 'Duración' 'Por favor, seleccione la carpeta de roms.' 'Scrapeado finalizado!') ;;
- de)
- dict=('FEHLER: Keine Internetverbindung verfügbar. Beenden...' 'ist kein unterstütztes Betriebssystem.' 'FEHLER: Scraper konnte nicht heruntergeladet werden. Beenden...' 'FEHLER: Scraper konnte nicht entpackt werden. Beenden...' 'FEHLER: Suche nach Updates auf GitHub fehlgeschlagen.' 'Update sselph scraper von' 'auf' ' wird durchgeführt, bitte warten...' 'Download sselph scraper' 'Öffne Ordner Browser...' 'Ordner Browser für' 'noch nicht implementiert, entschuldige!' 'Ausgewählter roms Ordner:' 'Vergiss nicht EmulationStation vor dem Scrapen zu beenden!' 'Welche(s) System(e) möchtest du scrapen? Tippe "all" für alle Systeme oder "cd", um den Ordner Browser zu öffnen.' 'Ungültige Eingabe!' 'Möchtest du die bestehende gamelists erweitern? [Y/N]:' 'Scrapen' 'in Arbeit. Bitte warten...' 'Beginn' 'Ende' 'Dauer' 'Bitte wählen Sie den Ordner roms' 'Scrapen ist beendet!') ;;
- fr)
- dict=('ERREUR : Pas de connexion internet disponible. Quitter...' "n'est pas une plateforme prise en charge." 'ERREUR : Impossible de télécharger le scraper. Quitter...' 'ERREUR : Impossible de décompresser le scraper. Quitter...' 'ERREUR : Impossible de rechercher les mises à jour sur GitHub.' 'La mise à jour de sselph scraper de' 'à' ', veuillez patienter...' 'Le téléchargement sselph scraper' 'Ouverture du Navigateur de Dossier...' 'Navigateur de Dossier pour' 'pas encore mis en oeuvre, désolé !' 'Dossier roms sélectionné :' "N'oubliez pas d'arrêter de EmulationStation avant de scrapez !" 'Quel(s) système(s) souhaitez-vous scrapez ? Tapez « all » pour tous les systèmes ou « cd » pour ouvrir le dossier du navigateur.' 'Entrée incorrecte !' 'Vous souhaitez ajouter les gamelists ? [Y/N] :' 'Scrapez' 'en course. Veuillez patienter...' 'Démarrer' 'Terminer' 'Durée' 'Veuillez choisir le dossier de roms' 'Scrapez est terminé !') ;;
- *)
- if [ ! "$language" == "en" ]; then echo "Can't get OS's language. English will be used."; fi;
- dict=('ERROR: No internet connection available. Exiting...' 'is not a supported platform.' 'ERROR: Unable to download the scraper. Exiting...' "ERROR: Couldn't unzip the scraper. Exiting..." 'ERROR: Unable to check for updates on GitHub.' 'Updating sselph scraper from' 'to' ', please wait...' 'Downloading sselph scraper' 'Opening Folder Browser...' 'Folder Browser for' 'not implemented yet, sorry!' 'Selected roms folder:' "Don't forget to stop EmulationStation before scraping!" "Which system(s) do you want to scrape? Type "all" for all systems or "cd" to open the folder browser." 'Incorrect input!' 'Would you like to append existing gamelists? [Y/N]:' 'Scraping' 'in progress. Please wait...' 'Start' 'Finish' 'Duration' 'Please choose the roms folder.' 'Scraping has finished!') ;;
- esac
- # Check internet connection
- uname -m | grep 'arm' >/dev/null && ping -q -c 1 -W 1 8.8.8.8 >/dev/null 2>&1 || nc -z 8.8.8.8 53 >/dev/null 2>&1
- if [ ! $? -eq 0 ]; then echo "${dict[0]}"; exit 1; fi
- # Set default roms directory to launch directory
- romsDir=$(pwd)
- scriptPath=$(pwd)
- # Function to download the latest scraper version
- download_scraper()
- {
- # Detect OS architecture
- if [ $(uname -m) == "armv7l" ]; then arch=rpi2;
- elif [ $(uname -m) == "armv6l" ]; then
- arch=rpi
- thumbOnly=-thumb_only=true
- workersN=-workers=1
- elif [ $(uname -m) == "x86_64" ]; then arch=amd64;
- else arch=386; fi
- # Detect OS platform
- if [[ $(uname) == 'Linux' ]]; then
- platform='linux'
- elif [[ $(uname) == 'Darwin' ]]; then
- platform='mac'
- elif [[ $(uname) == 'FreeBSD' ]]; then
- platform='freebsd'
- else
- echo "$(uname) ${dict[1]}"
- exit 1
- fi
- # Build the file name, download url and download the file to the current location
- if [[ $arch = "rpi2" || $arch = "rpi" ]]; then
- scraperZip=scraper_${arch}.zip
- else
- scraperZip=scraper_${platform}_${arch}.zip
- fi
- scraperURL=https://github.com/sselph/scraper/releases/download/${scraperVersion}/${scraperZip}
- curl -s -LOk $scraperURL || { echo "${dict[2]}"; exit 1; }
- # Unzip the scraper, remove unnecessary files and set appropriate permissions
- unzip -o -q $scraperZip scraper || { echo "${dict[3]}"; exit 1; }
- rm $scraperZip
- chmod u+x ./scraper
- echo ""
- }
- # scraperBIN
- # Query the API to get the latest release tag
- scraperVersion=$(curl -s https://api.github.com/repos/sselph/scraper/releases/latest | grep tag_name | cut -d '"' -f 4)
- # Download or update scraper if needed
- if [ -f "./scraper" ]; then
- chmod u+x ./scraper
- if [ "$scraperVersion" = "$(./scraper -version)" ]; then :;
- else
- if [ "$scraperVersion" = "" ]; then
- echo "${dict[4]}"
- echo ""
- else
- echo "${dict[5]} $(./scraper -version) ${dict[6]} $scraperVersion${dict[7]}"
- download_scraper
- fi
- fi
- else
- echo "${dict[8]} $scraperVersion${dict[7]}"
- download_scraper
- fi
- # Function to open a folder browser depending on the OS
- folder_browser()
- {
- echo ""
- echo "${dict[9]}"
- case "$OSTYPE" in
- darwin*) echo "${dict[10]} macOS ${dict[11]}" ;;
- freebsd*) echo "${dict[10]} FreeBSD ${dict[11]}!" ;;
- linux*) romsDir=`zenity --file-selection --directory --title="${dict[22]}"` ;;
- esac
- # Check if scraping from network drive and show warning about stopping ES
- cd "$romsDir" && echo "${dict[12]} $romsDir"
- if [[ $(df "$romsDir" | grep '^//') == "//"* ]]; then echo "${dict[13]}"; fi
- echo ""
- }
- # systemSelection
- # Select the system to scrape (type "all" to scrape all folders)
- while true; do
- echo "${dict[14]}"
- read system
- if [ "$system" = "" ]; then echo "${dict[15]}";
- elif [ "$system" = "cd" ]; then folder_browser;
- elif [ ! "$system" = "all" ]; then break;
- else
- system=$(find * -prune -type d | while read d; do echo "$d"; done) && break
- fi
- done
- # modeSelection
- # Choose to append an existing (y) or create a new gamelist (n)
- while true; do
- if [ "$refreshXML" = "-refresh=true" ]; then appendMode="" && break; fi
- read -p "${dict[16]} " appendXML
- if [[ "$appendXML" = "y" || "$appendXML" = "Y" ]]; then appendMode=-append && break; fi
- if [[ "$appendXML" = "n" || "$appendXML" = "N" ]]; then appendMode="" && break; fi
- echo "${dict[15]}"
- done
- # startTime
- # Save start time
- startTime=$(date +"%T")
- SECONDS=0
- # ******************** MAIN CODE SECTION
- for i in $system; do
- # Check if mame device is selected and set corresponding flags
- arcade=""
- if [[ "$i" == *"arcade"* ]]; then arcade="-mame $mameImg $mameSrc"; fi
- if [[ "$i" == *"fba"* ]]; then arcade="-mame $mameImg $mameSrc"; fi
- if [[ "$i" == *"mame"* ]]; then arcade="-mame $mameImg $mameSrc"; fi
- if [[ "$i" == *"neogeo"* ]]; then arcade="-mame $mameImg $mameSrc"; fi
- # If mame device, consoleImg not used
- if [ ! "$arcade" = "" ]; then consoleImg=""; fi
- echo ""
- # Scraping roms
- echo "${dict[17]} $i ${dict[18]}"
- echo ""
- "$scriptPath/scraper" $appendMode $arcade -rom_dir="$i" $imagePath -image_dir="$i/${imagePath:14}" $imageSuffix -marquee_dir="$i/${marqueePath:16}" $marqueeSuffix -video_dir="$i/${videoPath:14}" $videoSuffix $convertVideo -output_file="$i/gamelist.xml" -missing="$i/_${i}_missing.txt" $addNotFound $consoleImg $consoleSrc $downloadImg $downloadMarquee $downloadVideo $extraExt $imgFormat $marqueeFormat $langSS $maxHeight $maxWidth $noThumb $thumbOnly $refreshXML $regionSS $username $password $useFilename $useNoIntroName $workersN
- echo ""
- done
- # ******************** END MAIN CODE SECTION
- # Save finish time
- endTime=$(date +"%T")
- DURATION=$SECONDS
- # Format the results for output
- hh=$(($DURATION / 3600)); mm=$((($DURATION / 60) % 60)); ss=$(($DURATION % 60))
- if [ $hh -lt 10 ]; then hh=0$hh; fi
- if [ $mm -lt 10 ]; then mm=0$mm; fi
- if [ $ss -lt 10 ]; then ss=0$ss; fi
- DURATION=$hh:$mm:$ss
- echo "${dict[19]} : $startTime"
- echo "${dict[20]} : $endTime"
- echo " ------------"
- echo "${dict[21]} : $DURATION"
- echo ""
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement