Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

1.sh takes an IMDb URL on stdin, saves the page temporarily and outputs a "lite" version, a more minimal page containing only actor photos. Of course, if desired, other film details could also be extracted and added to the output. 1.sh takes a single argument: photo size. Options are 140, 210 and 280. Requirements: curl (or quivalent), grep, sed, cut, sort, nl.

Example:

    # Don't forget the trailing fwd slash else 302 redirect
    echo https://m.imdb.com/title/tt9484998/ | 1.sh 280 > 1.html
    firefox ./1.html

    case $# in 1);;*)echo "usage: echo URL | $0 size";exec echo size options are 140 210 280;esac;
    read x;case $x in https://m.imdb.com/title/*/);;*)exec echo error: URL \(should end with fwd slash\);esac;
    x1=$(echo "$x"|cut -d/ -f5); 
    curl -H"User-Agent" -0 -4o "${x1}" "$x";
    (grep -o "<title>.*</title>" "${x1}"|sed 's/  */ /g';
    echo "<h3>Image size: $1</h3>";
    (exec grep -o "title-cast-item__actor\"[^<]*" "${x1}"|sed 's>.*href=><a href=\"https://www.imdb.com>;s/?ref.*\"/\"/;s[.*[<p>&</a><\/p>['|nl -s,
    exec grep -o "title-cast-item__actor[^<]*" "${x1}"|sed 's/.*>//;s/.*/<img alt=\"&\"[^\>]\*/'|grep -of /dev/stdin "${x1}" \
     |case $1 in ---////////////////////////---IMDb-CAST-PHOTOS-ONLY---\\\\\\\\\\\\\\\\\\\\\\\\\---)
      ;;140)cut -d\" -f1-2,7-8,15|sed 's[.*[<p>&/></p>['
      ;;210)cut -d ' ' -f1-3,9|sed 's/https:/src=\"&/;s[.*[<p>&\"/></p>['
      ;;280)cut -d/ -f1-2,18-21|cut -d\" -f1-3,8|sed 's/class=\"/src=\"/;s/\.jpg/&\"/;s/ 280w//;s[.*[<p>&/></p>['
      esac|nl -s,;
    exec grep -o "title-cast-item__char\"[^<]*" "${x1}"|sed 's/.*cast-item-characters-link..//;s/.*/<p>\&quot;&\&quot;<\/p>/'|nl -s,;
    ))|sort -n|cut -d, -f2- 
    rm "${x1}" 2>/dev/null;


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: