Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 23 lines (18 sloc) 677 Bytes
#!/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"