Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 22 lines (18 sloc) 0.677 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/bin/sh

# This script takes a prefix for a movie and finds IDs for movies with that prefix
prefix="$2"

# Icefilms puts "The Blah" into "B", but the title is still "The Blah"
if echo "$prefix" | grep -qi "^The "; then
first_letter="$(echo "$prefix" | cut -c 5 | tr 'a-z' 'A-Z')"
else
first_letter="$(echo "$prefix" | cut -c 1 | tr 'a-z' 'A-Z')"
fi

list_url="http://www.icefilms.info/$1/a-z/$first_letter"

curl -s "$list_url" | ruby -rnokogiri -e '
Nokogiri::parse(STDIN.read).at("span.list").search("a").each do |item|
if item.content.downcase.start_with?(ARGV[0].downcase)
id = item["href"][/[0-9]+(?:\/[0-9]+)?/]
puts id + " " + item.content
end
end
' "$prefix"
Something went wrong with that request. Please try again.