From 6e46f37a39d342c362927aa653eb8bade9871685 Mon Sep 17 00:00:00 2001 From: Christoph Dittmann Date: Sat, 23 Jul 2011 22:53:35 +0200 Subject: [PATCH] Add nhk_download.sh. --- nhk_download.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 nhk_download.sh diff --git a/nhk_download.sh b/nhk_download.sh new file mode 100755 index 0000000..603bed8 --- /dev/null +++ b/nhk_download.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +download_mms() { + if [[ ! -f $2 ]]; then + echo "Downloading $1 to $2" + # Now I would like to do something like this: + # { mimms "$1" "$2" > /dev/null ; echo "Done with $2"; } & + # Then the EXIT trap does not catch all of the mimms + # processes, though, so we can't do that. + # TODO: Figure out how to make this work. + mimms "$1" "$2" > /dev/null & + else + echo "NOT downloading $1 to $2 because the file exists!" + fi +} + +get_file_path() { + read -d '\t' -r topic number title section < \ + <(printf '%s\n' "$1" | sed 's/.*| \([^|]\+\) | 第\([0-9]\+\)回 \([^ ]*\) \(.*\)$/\1\t\2\t\4\t\3/') + path="$topic" + mkdir -p "$path" + printf '%s/%02d - %s (%s).wmv' "$path" "$number" "$title" "$section" +} + +download_topic() { + base="${1}archive/" + for (( i=1; i < 100; ++i )); do + chapter=$(curl -s "${base}chapter$(printf '%03d' "$i").html" | iconv -c -f sjis -t utf8 | fromdos) + title=$(printf '%s\n' "${chapter}" | sed 's#^\(.*\)$#\1#;t;d') + media=$(printf '%s\n' "${chapter}" | \ + sed 's#^\t