8f8f8b2755
macOS menu bar app providing NHL game situational awareness with league-wide scoreboard, dynamic polling, notifications with team logos, and configurable display options.
96 lines
2.4 KiB
Bash
Executable File
96 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# download_team_logos.sh
|
|
# Downloads NHL team logos (SVG) from the NHL assets CDN.
|
|
#
|
|
# Usage: ./Scripts/download_team_logos.sh [season]
|
|
# season: e.g. 20252026 (defaults to current season)
|
|
#
|
|
# SVGs are saved to Assets.xcassets imagesets for UI use.
|
|
# PNGs (80x80) are saved to TeamLogos/ for notification attachments.
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
ASSETS_DIR="$PROJECT_DIR/IceGlass/Assets.xcassets"
|
|
LOGOS_DIR="$PROJECT_DIR/IceGlass/TeamLogos"
|
|
|
|
# Determine season
|
|
if [ -n "$1" ]; then
|
|
SEASON="$1"
|
|
else
|
|
MONTH=$(date +%m)
|
|
YEAR=$(date +%Y)
|
|
if [ "$MONTH" -lt 7 ]; then
|
|
SEASON="$((YEAR - 1))$YEAR"
|
|
else
|
|
SEASON="$YEAR$((YEAR + 1))"
|
|
fi
|
|
fi
|
|
|
|
echo "Downloading NHL team logos for season $SEASON"
|
|
|
|
TEAMS=(
|
|
ANA BOS BUF CAR CBJ CGY CHI COL DAL DET
|
|
EDM FLA LAK MIN MTL NJD NSH NYI NYR OTT
|
|
PHI PIT SEA SJS STL TBL TOR UTA VAN VGK
|
|
WPG WSH
|
|
)
|
|
|
|
# Create logos directory for notification attachments
|
|
mkdir -p "$LOGOS_DIR"
|
|
|
|
for TEAM in "${TEAMS[@]}"; do
|
|
IMAGESET_DIR="$ASSETS_DIR/TeamLogo_${TEAM}.imageset"
|
|
mkdir -p "$IMAGESET_DIR"
|
|
|
|
SVG_URL="https://assets.nhle.com/logos/nhl/svg/${TEAM}_light.svg"
|
|
SVG_FILE="$IMAGESET_DIR/${TEAM}_light.svg"
|
|
LOGO_PNG="$LOGOS_DIR/${TEAM}.png"
|
|
|
|
echo " Downloading $TEAM..."
|
|
curl -s -o "$SVG_FILE" "${SVG_URL}?season=${SEASON}"
|
|
|
|
# Convert SVG to PNG (200px wide, aspect-ratio preserved) for notification attachments
|
|
if command -v rsvg-convert &>/dev/null; then
|
|
rsvg-convert -w 200 -h 200 --keep-aspect-ratio --background-color=transparent "$SVG_FILE" -o "$LOGO_PNG" 2>/dev/null
|
|
else
|
|
python3 -c "
|
|
try:
|
|
import cairosvg
|
|
cairosvg.svg2png(url='$SVG_FILE', write_to='$LOGO_PNG', output_width=200)
|
|
except ImportError:
|
|
pass
|
|
" 2>/dev/null || true
|
|
fi
|
|
|
|
# Write Contents.json for the imageset (SVG only, no PNG)
|
|
cat > "$IMAGESET_DIR/Contents.json" << EOJSON
|
|
{
|
|
"images" : [
|
|
{
|
|
"filename" : "${TEAM}_light.svg",
|
|
"idiom" : "universal"
|
|
}
|
|
],
|
|
"info" : {
|
|
"author" : "xcode",
|
|
"version" : 1
|
|
},
|
|
"properties" : {
|
|
"preserves-vector-representation" : true,
|
|
"template-rendering-intent" : "original"
|
|
}
|
|
}
|
|
EOJSON
|
|
done
|
|
|
|
echo ""
|
|
echo "Done! Downloaded ${#TEAMS[@]} team logos to:"
|
|
echo " Asset catalogs: $ASSETS_DIR/TeamLogo_*.imageset/ (SVG)"
|
|
echo " Notifications: $LOGOS_DIR/ (PNG 80x80)"
|
|
echo ""
|
|
echo "Season: $SEASON"
|