├── .img ├── artwork-1.png ├── artwork-2.png ├── artwork-3.png ├── artwork-4.png └── artwork-5.png ├── skyscraper ├── resources │ ├── onionscraper-bg-silky.png │ ├── onionscraper-gradient.png │ └── onionscraper-lbordermask.png ├── config-onion.ini.example ├── artwork-onionscraper1.xml ├── artwork-onionscraper3.xml ├── artwork-onionscraper2.xml ├── artwork-onionscraper4.xml └── artwork-onionscraper5.xml ├── config └── onionscraper.conf.example ├── README.md ├── LICENSE └── onionscraper /.img/artwork-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/.img/artwork-1.png -------------------------------------------------------------------------------- /.img/artwork-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/.img/artwork-2.png -------------------------------------------------------------------------------- /.img/artwork-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/.img/artwork-3.png -------------------------------------------------------------------------------- /.img/artwork-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/.img/artwork-4.png -------------------------------------------------------------------------------- /.img/artwork-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/.img/artwork-5.png -------------------------------------------------------------------------------- /skyscraper/resources/onionscraper-bg-silky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/skyscraper/resources/onionscraper-bg-silky.png -------------------------------------------------------------------------------- /skyscraper/resources/onionscraper-gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/skyscraper/resources/onionscraper-gradient.png -------------------------------------------------------------------------------- /skyscraper/resources/onionscraper-lbordermask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y-muller/onionscraper/HEAD/skyscraper/resources/onionscraper-lbordermask.png -------------------------------------------------------------------------------- /skyscraper/config-onion.ini.example: -------------------------------------------------------------------------------- 1 | [main] 2 | inputFolder="PATH_TO_YOUR_ROMS" 3 | artworkXml="artwork-onionscraper1.xml" 4 | cacheMarquees="false" 5 | cacheTextures="false" 6 | relativePaths="true" 7 | gameListBackup="false" 8 | nameTemplate="%t" 9 | frontend="emulationstation" 10 | 11 | [screenscraper] 12 | userCreds="USERNAME:PASSWORD" 13 | 14 | -------------------------------------------------------------------------------- /config/onionscraper.conf.example: -------------------------------------------------------------------------------- 1 | # Scraping module for Skyscraper 2 | #module=screenscraper 3 | 4 | # Create a miyoogamelist.xml file for each system. Set to "false" to disable. 5 | #gamelist="true" 6 | 7 | # System directory to exclude 8 | #exclude=(PORTS PICO) 9 | 10 | # Skyscraper config file (no quotes) 11 | #skyscraperini=~/.skyscraper/config.ini 12 | 13 | # Replace colons in game titles in game list for better sorting 14 | #replacecolons="true" 15 | 16 | -------------------------------------------------------------------------------- /skyscraper/artwork-onionscraper1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /skyscraper/artwork-onionscraper3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /skyscraper/artwork-onionscraper2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /skyscraper/artwork-onionscraper4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /skyscraper/artwork-onionscraper5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # onionscraper 2 | A script to scrape artwork for OnionOS on the Miyoo Mini and Mini+. The actual scraping is done with Skyscraper. 3 | 4 | ### Requirements 5 | - bash (Linux, MacOS, Cygwin...) 6 | - Skyscraper: [Lars Muldjord](https://github.com/muldjord/skyscraper)'s original or [Detain](https://github.com/detain/skyscraper)'s more recent fork. 7 | - xmlstarlet (optional): used to remove unnecessary data in the miyoogamelist.xml. 8 | 9 | ### Installation 10 | Clone the repository or download the Zip file. Copy the content of `skyscraper` to `~/.skyscraper`. 11 | 12 | ### Configuration 13 | .skyscraper/config.ini 14 | ``` 15 | [main] 16 | iinputFolder="PATH_TO_YOUR_ROMS" 17 | artworkXml="artwork-onionscraper1.xml" 18 | cacheMarquees="false" 19 | cacheTextures="false" 20 | relativePaths="true" 21 | gameListBackup="false" 22 | nameTemplate="%t" 23 | frontend="emulationstation" 24 | 25 | [screenscraper] 26 | userCreds="USERNAME:PASSWORD" 27 | ``` 28 | *onionscraper* has a few options that can be configured by adding a config file as `.onionscraper` or `.config/onionscraper`. There is an example in the config directory. 29 | ``` 30 | # Scraping module for Skyscraper 31 | #module=screenscraper 32 | 33 | # Create a miyoogamelist.xml file for each system. Set to "false" to disable. 34 | #gamelist="true" 35 | 36 | # System directory to exclude 37 | #exclude=(PORTS PICO) 38 | 39 | # Skyscraper config file (no quotes) 40 | #skyscraperini=~/.skyscraper/config.ini 41 | ``` 42 | 43 | ### Usage 44 | ``` 45 | Usage: onionscraper [OPTIONS] [SYSTEMS] 46 | Scrape artwork for new ROMs or for given systems. Helps mananaging artwork. 47 | options: 48 | -a --all: check all platforms instead of just the ones with new ROMs. 49 | -c --clean: remove images for deleted games. 50 | -p --pretend with clean, find but don't delete images. 51 | -v --vacuum vacuum the Skyscraper cache (danger?). 52 | -i --import: import manually added assets. 53 | -s --skip: skip existing output files. 54 | -d --device use the Skyscraper config for the given device. 55 | -r --region override the default region list. 56 | -g --game process only the given game. 57 | -h --help: this help. 58 | systems: 59 | All parameters after the last option are treated as a list of systems 60 | to process. Ignored if the 'all' option is used. 61 | ``` 62 | 63 | Called without parameters, `onionscraper` will find new ROMS added since the previous run of the script 64 | and scrape the artwork. A file called `miyoogamelist.xml` is generated or updated so device will show the game 65 | titles instead of the file names. If `xmlstarlet` is installed, unnecessary information in this file 66 | will be removed. 67 | 68 | The first invocation of `onionscraper` can take a while as all the ROMs are scraped. 69 | 70 | You can provide your own images for the artwork. See below how to provide it. To use your newly added images, call the script with `-i` or `--import`. 71 | 72 | If called with `-a` or `--all`, all the systems will be scanned instead of just the systems with new games. 73 | 74 | ### Artwork styles 75 | The XML file used to generate the game artwork is defined in the Skyscraper configuration file. Two styles are included. You can use those as they are or modify them to fit your requirements. 76 | 77 | ![artwork-1](.img/artwork-1.png) ![artwork-2](.img/artwork-2.png) ![artwork-3](.img/artwork-3.png) ![artwork-4](.img/artwork-4.png) ![artwork-5](.img/artwork-5.png) 78 | 79 | **artwork-onionscraper1.xml**: The screenshot takes the entire height so the sides are cropped. The logo is added on top. 80 | - The width of the logo is fixed so tall logos take a lot of the available space. 81 | 82 | **artwork-onionscraper2.xml**: The screenshot is shown in full in the middle. The logo is at the top and the front cover at the bottom right. 83 | - This time the width of the logo is not fixed but the total area is. This doesn't work very well with logos that are not tall enough. 84 | - An opaque layer is added as a background in the same colour as the default theme. For other themes, a different background image is needed. Or you can make it transparent by removing the background. 85 | 86 | **artwork-onionscraper3.xml**: Same as style 1 but with the left edge becoming transparent. This can make the text of the game titles blend into the artwork. 87 | 88 | **artwork-onionscraper4.xml**: Same as style 2 with the background becoming transparent on the left edge. 89 | 90 | **artwork-onionscraper5.xml**: Same as style 2 with the left edge (background and screenshot) becoming transparent. 91 | 92 | ### Using multiple devices 93 | If you use Skyscraper outside of onionscraper, you already have a config file and you don't want to overwrite it. Give your Skyscraper config of onionscraper a different name and set the correct file name in the onionscraper configuration. 94 | 95 | ``` 96 | # Skyscraper config file (no quotes) 97 | skyscraperini=~/.skyscraper/config-onion.ini 98 | ``` 99 | If you have multiple devices that you want to use *onionscraper* with, you can have a configuration file for each use the `--device` option. The setup would be something like this: 100 | 101 | .onionscraper.conf 102 | ``` 103 | # Skyscraper config file (no quotes) 104 | skyscraperini=~/.skyscraper/config-mini.ini 105 | ``` 106 | Create a Skyscraper config file using the model above for each device. Let's say `.~/.skyscraper/config-mini.black.ini` and `.~/.skyscraper/config-mini.purple.ini`. 107 | 108 | Call *onionscraper* with the name of the device you want. 109 | ``` 110 | onionscraper -d purple 111 | ``` 112 | 113 | ### Using SSHFS with a Miyoo Mini Plus 114 | Turn on SSH in the Apps section of OnionOS. Mount the Mini Plus filesystem locally, for example: 115 | ``` 116 | sshfs root@192.168.1.62:/mnt/SDCARD /mnt/mini 117 | ``` 118 | Adjust the inputFolder in the Skyscraper config to match. 119 | 120 | Combined with the `--device` option, you can have a config to use SSH and a second when mounting the SD card. 121 | 122 | ### Improving on the automated scraping 123 | 124 | ##### overriding the region 125 | Sometimes *screenscraper* gets the title screenshot instead of the in-game screenshot. This happens because the screenshots available do not match the game's region. In this case, it is possible to scrape the game with a different region. For example: 126 | 127 | ``` 128 | onionscraper --game "Game name (J).gba" --region wor GBA 129 | ``` 130 | 131 | ##### Importing local images 132 | The artwork is generated from the *screenshot* and *wheel* assets. 133 | 134 | See [Skyscraper's documentation](https://github.com/muldjord/skyscraper/blob/master/docs/IMPORT.md) on import for the details. By default, Skyscraper looks for images to import in `~/.skyscraper/import`. 135 | Inside this directory, my preference is to store my images per platform and then per asset type. For example: 136 | ``` 137 | ~/.skyscraper/import/snes/screenshot/Good Game (Europe).png 138 | ~/.skyscraper/import/wonderswan/screenshot/Another Game (Japan).png 139 | ``` 140 | Note that here the Skyscraper platforms are used, not the Miyoo system directories. So it is `snes` and not `SFC`, `wonderswan` and not `WS`, etc... 141 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /onionscraper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Look for new ROMs since the last run. 4 | 5 | ##### Config ##### 6 | # Don't edit the configuration in this file as it would be overwritten on updates. 7 | # Create the file .config/onionscraper.conf or .onionscraper.conf and override the variables. 8 | 9 | module=screenscraper 10 | gamelist="true" 11 | exclude=(PORTS PICO) 12 | 13 | # Skyscraper config file (no quotes) 14 | skyscraperini=~/.skyscraper/config.ini 15 | 16 | replacecolons="true" 17 | 18 | ################## 19 | if [[ -f ~/.config/onionscraper.conf ]]; then 20 | source ~/.config/onionscraper.conf 21 | elif [[ -f ~/.onionscraper.conf ]]; then 22 | source ~/.onionscraper.conf 23 | fi 24 | 25 | #--------------- 26 | 27 | function usage() { 28 | echo "Usage: $(basename $0) [OPTIONS] [SYSTEMS]" 29 | echo "Scrape artwork for new ROMs or for given systems. Helps mananaging artwork." 30 | echo "options:" 31 | echo " -a --all: check all platforms instead of just the ones with new ROMs." 32 | echo " -c --clean: remove images for deleted games." 33 | echo " -p --pretend with clean, find but don't delete images." 34 | echo " -v --vacuum vacuum the Skyscraper cache (danger?)." 35 | echo " -i --import: import manually added assets." 36 | echo " -s --skip: skip existing output files." 37 | echo " -d --device use the Skyscraper config for the given device." 38 | echo " -r --region override the default region list." 39 | echo " -g --game process only the given game." 40 | echo " -h --help: this help." 41 | echo "systems:" 42 | echo " All parameters after the last option are treated as a list of systems" 43 | echo " to process. Ignored if the 'all' option is used." 44 | exit 0 45 | } 46 | 47 | # convert the Miyoo systems into Skyscraper platforms 48 | # One system can combine multiple platforms, in which case define them 49 | # as a space-separated double-quoted string, for example "ngp ngpc". 50 | declare -A systemlist 51 | systemlist[AMIGA]=amiga 52 | systemlist[CPC]=amstradcpc 53 | systemlist[ARCADE]=mame-libretro 54 | systemlist[ATARI]=atari2600 55 | systemlist[FIFTYTWOHUNDRED]=atari5200 56 | systemlist[SEVENTYEIGHTHUNDRED]=atari7800 57 | systemlist[LYNX]=atarilynx 58 | systemlist[WS]="wonderswan wonderswancolor" 59 | systemlist[COLECO]=coleco 60 | systemlist[VECTREX]=vextrex 61 | systemlist[INTELLIVISION]=intellivision 62 | systemlist[MSX]=msx 63 | systemlist[PCECD]=pcenginecd 64 | systemlist[PCE]=pcengine 65 | systemlist[FC]=nes 66 | systemlist[GB]="gb gbc" 67 | systemlist[GBC]=gbc 68 | systemlist[GBA]=gba 69 | systemlist[POKE]=pokemini 70 | systemlist[SFC]=snes 71 | systemlist[VB]=virtualboy 72 | systemlist[PICO]=pico8 73 | systemlist[PORTS]=ports 74 | systemlist[SCUMMVM]=scummvm 75 | systemlist[THIRTYTWOX]=sega32x 76 | systemlist[SEGACD]=segacd 77 | systemlist[GG]=gamegear 78 | systemlist[MD]=megadrive 79 | systemlist[MS]=mastersystem 80 | systemlist[SEGASGONE]=sg-1000 81 | systemlist[ZXS]=zxspectrum 82 | systemlist[NEOGEO]=neogeo 83 | systemlist[NEOCD]=neogeocd 84 | systemlist[NGP]="ngp ngpc" 85 | systemlist[PS]=psx 86 | systemlist[VIDEOPAC]=videopac 87 | 88 | function check_rompath() { 89 | if [[ -d "$rompath" ]]; then 90 | if [[ ! "$(ls -A $rompath)" ]]; then 91 | echo "The path to the ROMs is empty. Check your configuration." 92 | exit 1 93 | fi 94 | else 95 | echo "The path to the ROMs does not exist. Check your configuration." 96 | echo "Not found: $rompath" 97 | exit 1 98 | fi 99 | } 100 | 101 | function scrape_platform() { 102 | echo "(Skyscraper platform: $platform)" 103 | if [[ ! -d "$rompath/$system" ]]; then 104 | echo "Folder for system $system doesn't exist." 105 | echo "Check your configuration, ROM paths and mount points." 106 | return 107 | fi 108 | if [[ ! "$(ls -A $rompath/$system)" ]]; then 109 | echo "No game in $system." 110 | return 111 | fi 112 | 113 | Skyscraper ${inifile} -p ${platform} -s ${module} \ 114 | -i $rompath/$system \ 115 | --flags $skip_in \ 116 | $region #$game 117 | Skyscraper ${inifile} -p ${platform} \ 118 | -i $rompath/$system -o $rompath/$system/Imgs \ 119 | --flags $skip_out 120 | mv $rompath/$system/Imgs/screenshots/* $rompath/$system/Imgs/ 121 | rmdir $rompath/$system/Imgs/covers \ 122 | $rompath/$system/Imgs/marquees \ 123 | $rompath/$system/Imgs/screenshots \ 124 | $rompath/$system/Imgs/textures \ 125 | $rompath/$system/Imgs/wheels 126 | 127 | if [[ "$gamelist" == "true" && -f $rompath/$system/gamelist.xml ]]; then 128 | # if using a gamelist, clean it up and rename it 129 | sed -i 's/Imgs\/screenshots/Imgs/g' $rompath/$system/gamelist.xml 130 | if [[ ! "$hasxmlstarlet" == "true" ]]; then 131 | mv $rompath/$system/gamelist.xml $rompath/$system/miyoogamelist.$platform.xml 132 | else 133 | xmlstarlet edit -d "//desc" -d "//rating" -d "//genre" -d "//players" -d "//releasedate" -d "//developer" -d "//publisher" -d "//hash" -d "//thumbnail" -d "//genreid" -d "//marquee" -d "//texture" -d "//video" --subnode "gameList/game[not(image)]" -t elem -n image -v "no-img.png" $rompath/$system/gamelist.xml > $rompath/$system/miyoogamelist.$platform.xml 134 | rm $rompath/$system/gamelist.xml 135 | fi 136 | else 137 | # if not using a gamelist, just delete it 138 | rm $rompath/$system/gamelist.xml 139 | fi 140 | } 141 | 142 | function find_match { 143 | platform=$1 144 | asset=$2 145 | game=${asset#$pdir$adir/} 146 | game=${game%.*} 147 | game="$(printf '%q' "${game}")" # escapes special characters 148 | res=$(find "$rompath/$platform" -name "${game}.*" |wc -l) 149 | if [[ "$res" == "0" ]]; then 150 | echo "rm \"$asset\"" >> $orphansfile 151 | fi 152 | } 153 | 154 | function clean_assets() { 155 | 156 | for pdir in $rompath/*/ 157 | do 158 | 159 | system=$(basename $pdir) 160 | if [[ "$systems" != "" ]]; then 161 | # a list of systems was provided, skip all that are not in the list 162 | if [[ ! " $systems " =~ " $system " ]]; then 163 | continue 164 | fi 165 | fi 166 | 167 | # check the exclude list 168 | skip="false" 169 | for i in "${exclude[@]}" 170 | do 171 | if [ "$i" == "$system" ] ; then 172 | echo "Skipping $system" 173 | skip="true" 174 | continue 175 | fi 176 | done 177 | if $skip ; then 178 | continue 179 | fi 180 | 181 | echo Cleaning $system 182 | for asset in ${pdir}Imgs/* 183 | do 184 | # Special case: directory is empty 185 | if [[ "$asset" != "${pdir}Imgs/*" ]]; then 186 | game=${asset#${pdir}Imgs/} 187 | game=${game%.*} 188 | game="$(printf '%q' "${game}")" # escapes special characters 189 | #res=$(find "$rompath/$system" -name "${game}.*" |wc -l) 190 | res=$(find "$rompath/$system" -maxdepth 1 -name "${game}.*" |wc -l) 191 | if [[ "$res" == "0" ]]; then 192 | if [[ "$dryrun" == "true" ]]; then 193 | echo "ORPHANED ARTWORK: $asset" 194 | else 195 | echo "DELETING $asset" 196 | rm "$asset" 197 | fi 198 | fi 199 | 200 | fi 201 | 202 | done 203 | done 204 | exit 0 205 | } 206 | 207 | function vacuum_skyscraper_cache() { 208 | echo "Skyscraper cache vacuum" 209 | for pdir in $rompath/*/ 210 | do 211 | system=$(basename "$pdir") 212 | platforms=${systemlist[$system]} 213 | if [[ "$platforms" == "" ]]; then 214 | echo "Unsupported system" 215 | else 216 | for platform in $platforms 217 | do 218 | echo vacuum $platform 219 | Skyscraper ${inifile} -p $platform -i $rompath/$system --cache vacuum --flags unattendskip 220 | done 221 | fi 222 | 223 | done 224 | exit 0 225 | } 226 | 227 | # --------------------------------------------------------- 228 | 229 | allplatforms="false" 230 | skip_in="unattendskip" 231 | skip_out="unattend" 232 | import="false" 233 | clean="false" 234 | dryrun="false" 235 | vacuum="false" 236 | uselastrun="true" 237 | hasxmlstarlet="false" 238 | system="" 239 | region="" 240 | game="" 241 | 242 | while [[ "$1" = "-"* ]]; do 243 | if [[ "$1" = "--help" || "$1" = "-h" ]]; then 244 | usage 245 | elif [[ "$1" == "--all" || "$1" == "-a" ]]; then 246 | echo "Scanning all platforms." 247 | allplatforms="true" 248 | shift 249 | elif [[ "$1" == "-r" || "$1" == "--region" ]]; then 250 | region="--region $2" 251 | shift 2 252 | elif [[ "$1" == "-s" || "$1" == "--skip" ]]; then 253 | skip_out="unattendskip" 254 | shift 255 | elif [[ "$1" == "-i" || "$1" == "--import" ]]; then 256 | import="true" 257 | module="import" 258 | skip_in="unattend" 259 | shift 260 | elif [[ "$1" == "-c" || "$1" == "--clean" ]]; then 261 | clean="true" 262 | shift 263 | elif [[ "$1" == "-p" || "$1" == "--pretend" ]]; then 264 | dryrun="true" 265 | shift 266 | elif [[ "$1" == "-d" || "$1" == "--device" ]]; then 267 | skyscraperini=${skyscraperini%.ini}.$2.ini 268 | shift 2 269 | elif [[ "$1" == "-v" || "$1" == "--vacuum" ]]; then 270 | vacuum="true" 271 | shift 272 | elif [[ "$1" == "-g" || "$1" == "--game" ]]; then 273 | game=\"$2\" 274 | shift 2 275 | else 276 | echo "Unsupported option $1." 277 | shift 278 | fi 279 | done 280 | 281 | # remaining parameters are systems to scrape 282 | if [[ "$allplatforms" != "true" ]]; then 283 | systems="$@" 284 | if [[ "$systems" != "" ]]; then 285 | uselastrun="false" 286 | fi 287 | fi 288 | 289 | #--------------- 290 | 291 | if [[ ! -f $skyscraperini ]]; then 292 | echo "Could not find Skyscraper config file: $skyscraperini" 293 | echo "Aborting." 294 | exit 1 295 | fi 296 | 297 | inifile="-c $skyscraperini" 298 | 299 | inputline=$(grep -m 1 ^inputFolder "$skyscraperini") 300 | rompath=${inputline##*=} 301 | rompath="${rompath%\"}" 302 | rompath="${rompath#\"}" 303 | check_rompath 304 | 305 | lastrun=$rompath/.onionscraper.lastrun 306 | 307 | if [[ "$allplatforms" == "true" ]]; then 308 | rm -f $lastrun 309 | fi 310 | 311 | if [[ "$clean" == "true" ]]; then 312 | clean_assets 313 | elif [[ "$vacuum" == "true" ]]; then 314 | vacuum_skyscraper_cache 315 | fi 316 | 317 | if xmlstarlet_loc="$(type -p "xmlstarlet")" || [[ -n $xmlstarlet_loc ]]; then 318 | hasxmlstarlet="true" 319 | fi 320 | 321 | if [[ ! -f ${lastrun} && "$systems" == "" ]] || [[ "$allplatforms" == "true" ]]; then 322 | echo "Checking all systems: this could take a long time..." 323 | cd ${rompath} 324 | systems=$(find -mindepth 1 -maxdepth 1 -type d -printf "%P ") 325 | cd - 326 | fi 327 | 328 | if [[ "$systems" == "" ]]; then 329 | echo Looking for new ROMs in $rompath 330 | 331 | systems=$(find ${rompath} -mindepth 2 -maxdepth 2 -type f -cnewer ${lastrun} -exec sh -c 'basename $(dirname "$0")' {} \; | sort | uniq) 332 | 333 | if [[ "$systems" == "" ]];then 334 | echo "No new game found." 335 | touch ${lastrun} 336 | exit 0 337 | fi 338 | fi 339 | 340 | skip=false 341 | for system in $systems 342 | do 343 | for i in "${exclude[@]}" 344 | do 345 | if [ "$i" == "$system" ] ; then 346 | echo "Skipping $system" 347 | skip=true 348 | fi 349 | done 350 | if ! $skip ; then 351 | echo -n "Processing $system ... " 352 | 353 | platforms=${systemlist[$system]} 354 | if [[ "$platforms" == "" ]]; then 355 | echo "Unsupported system" 356 | else 357 | # Miyoo systems can be formed of more than one Skyscraper platform 358 | for platform in $platforms 359 | do 360 | scrape_platform 361 | done 362 | if [[ "$gamelist" == "true" ]]; then 363 | if ! ls $rompath/$system/miyoogamelist.*.xml >/dev/null 2>&1; then 364 | # No gamelist available, maybe there were no games in the directory 365 | continue 366 | fi 367 | echo "" >$rompath/$system/miyoogamelist.xml 368 | echo "" >>$rompath/$system/miyoogamelist.xml 369 | for gamelist in $rompath/$system/miyoogamelist.*.xml 370 | do 371 | if [[ "$hasxmlstarlet" != "true" ]]; then 372 | # No xmlstarlet, print the entire xml file minus the first 2 and last lines. 373 | # Does this work on Mac OS? 374 | tail -n +3 $gamelist | head -n -1 >>$rompath/$system/miyoogamelist.xml 375 | else 376 | xmlstarlet select -t --copy-of '//gameList/game' $gamelist >>$rompath/$system/miyoogamelist.xml 377 | fi 378 | done 379 | echo "" >>$rompath/$system/miyoogamelist.xml 380 | if [[ "$replacecolons" == "true" ]]; then 381 | # Replace colons (unless no space either side) 382 | # to help with sort order of sequels - but less space efficient 383 | sed -i 's/\( *\):\( \+\)/ - /g' $rompath/$system/miyoogamelist.xml 384 | else 385 | # Screenscraper game names often have an extra space before colons 386 | # remove them 387 | sed -i 's/ : /: /g' $rompath/$system/miyoogamelist.xml 388 | fi 389 | rm $rompath/$system/miyoogamelist.*.xml 390 | fi 391 | fi 392 | fi 393 | skip=false 394 | done 395 | 396 | # Update lastrun 397 | if [[ "$uselastrun" == "true" ]]; then 398 | echo "Updating last run time." 399 | touch ${lastrun} 400 | fi 401 | 402 | --------------------------------------------------------------------------------