Showing 1 changed files with 35 additions and 0 deletions
+35
.fgfs/fgfs_function
... ...
@@ -219,6 +219,41 @@ function fgfs () {
219 219
                     $FGDIR/install/flightgear/bin/fgfs $fgfs_arg ${complement[$fgfs_arg]} 2>/dev/null | pager
220 220
                     return
221 221
                     ;;
222
+                --show-thumbnail)
223
+                    local PS3='which aircraft ? (Ctrl-D to quit) '
224
+                    local IFS=$'\n'
225
+                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
226
+                                                                   aircrafts.name,
227
+                                                                   hangars.name,
228
+                                                                   date(aircrafts.date, 'unixepoch'))
229
+                                                     from aircrafts
230
+                                                     inner join setxml, hangars
231
+                                                     where
232
+                                                       aircrafts.hangar = hangars.id
233
+                                                     and
234
+                                                       setxml.variantof = aircrafts.id
235
+                                                     and (
236
+                                                         setxml.file like '%$2%'
237
+                                                       or
238
+                                                         aircrafts.name like '%$2%'
239
+                                                     )
240
+                                                     order by aircrafts.date desc"); do
241
+                        test -z "$ac" && continue
242
+                        local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
243
+                                                                     from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
244
+                        if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
245
+                            url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
246
+                        fi
247
+                        if wget --quiet --spider "$url/thumbnail.jpg"; then
248
+                            curl -s "$url/thumbnail.jpg" \
249
+                            | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
250
+                            | display
251
+                        else
252
+                            echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
253
+                        fi
254
+                    done
255
+                    return
256
+                    ;;
222 257
                 --search)
223 258
                     command -v sqlite3 > /dev/null || return
224 259
                     sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s (%s): %s', file, \`/sim/flight-model\`, \`/sim/description\`) from setxml where file like '%$2%'"