-i PAGE_ID Page ID of page to operate on
-l List used page ID's
-m Print page as markdown
- -o Out file (optional)
- -c HTML out (optional)
+ -o FILE Out file (optional)
+ -c FILE HTML out (optional)
-f Foce used page ID's rewrite
+ -d DESCRIPT Add page description to used page ID's list
-h Help -- show this page and exit
-v Vebose output
Page content is *not* printed on stdout, tough that would be
-preferred."
+preferred.
+
+If \`-c\` (HTML out) is provided, then temporary files are not deleted
+"
example_page_id="46306514"
example_page_id="46301431"
v=
curl_out_file="/tmp/${0##*/}-$$-curlout"
html_out_file="/tmp/${0##*/}-$$-htmlout"
+curl_login_out_file="/tmp/${0##*/}-$$-curlloginout"
+html_login_out_file="/tmp/${0##*/}-$$-htmlloginout"
html_save=
force_rewrite=
-while getopts hvlfmi:o:c: flag; do
+page_description=
+while getopts hvlfmi:o:c:d: flag; do
case "$flag" in
h)
echoerr "$HELP"
output_file="$OPTARG" ;;
f)
force_rewrite="t" ;;
+ d)
+ page_description="$OPTARG" ;;
c)
html_save="t"
html_out_file="$OPTARG" ;;
--data "os_password=$password"\
--data "formname=loginform"\
--data "login='Log In'"\
- > /dev/null\
- 2> "$curl_out_file"
+ 1> "$html_login_out_file"\
+ 2> "$curl_login_out_file"
- if grep -q "HTTP/1.1 200 OK" < "$curl_out_file" &&
- grep -q "X-AUSERNAME: $username" < "$curl_out_file"; then
+ if grep -q "HTTP/1.1 200 OK" < "$curl_login_out_file" &&
+ grep -q "X-AUSERNAME: $username" < "$curl_login_out_file"; then
message="Login went through."
if [ "$v" ]; then echoerr "${0##*/}: $message"; fi
else
# Visit sites file
if [ "$v" ]; then echo "${0##*/}: Checks '$sites_csv'." 1>&2; fi
if [ "$force_rewrite" ] || ! grep -q "${page_id}" "$sites_csv"; then
- title_row=$(head -n 2 < "$html_out_file" | tail -n 1 | pandoc -f html -t markdown | head -n 1)
+ if [ -z "$page_description" ]; then
+ page_description=$(head -n 2 < "$html_out_file" | tail -n 1 | pandoc -f html -t markdown | head -n 1)
+ fi
sed "/$page_id/ d" < "$sites_csv" > "${sites_csv}_"; mv -f "${sites_csv}_" "$sites_csv"
- echo "$page_id,$output_file,$title_row" >> "$sites_csv"
+ echo "$page_id,$output_file,$page_description" >> "$sites_csv"
if [ "$v" ]; then echo "${0##*/}: File '$sites_csv' modified." 1>&2; fi
fi
# Clean up
if [ "$v" ]; then echo "${0##*/}: Cleans up and exits." 1>&2; fi
-rm -f "$curl_out_file"
+if [ -z "$html_save" ]; then rm -f "$curl_out_file"; fi
if [ -z "$html_save" ]; then rm -f "$html_out_file"; fi
exit 0