Guest User

iwate.sh

a guest
Jun 27th, 2026
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | Source Code | 0 0
  1. #!/bin/bash
  2. for file in **/*.htm; do
  3.   net=$(
  4.     pup -f "$file" 'tr:parent-of(th:contains("岩手県"))' \
  5.       | pup 'span.blue, span.limegreen, span.red'
  6.   )
  7.  
  8.   if [[ -n "$net" ]]; then
  9.     title=$(pup -f "$file" -p 'title text{trim}')
  10.     air_date=$(
  11.       perl -lnE '/放映期間:(\d{2})\.(\d{2})\.(\d{2})/
  12.        and print "19$1-$2-$3" and exit' "$file"
  13.     )
  14.     air_time='N/A'
  15.  
  16.     class=$(pup 'span attr{class}' <<< "$net")
  17.  
  18.     if [[ "$class" == "blue" ]]; then
  19.       delay='同時'
  20.       air_time=$(perl -lnE '/放映時間:(.+?)<BR>/ and print $1 and exit' "$file")
  21.     elif [[ "$class" == "limegreen" ]]; then
  22.       delay='遅れ'
  23.     else
  24.       delay='終了後'
  25.     fi
  26.  
  27.     broadcaster=$(
  28.       pup -p 'span text{trim}' <<< "$net" \
  29.         | perl -lnE '/\((.+?)\)/ and print $1'
  30.     )
  31.  
  32.     printf '%s\t%s\tN/A\t%s\t%s\t%s\n' \
  33.       "$air_date" "$title" "$air_time" "$delay" "$broadcaster"
  34.   fi
  35. done
  36.  
Advertisement
Add Comment
Please, Sign In to add comment