Skip to content

Commit

Permalink
๐Ÿ—ƒ๏ธ Committing everything that changed ๐Ÿ—ƒ๏ธ
Browse files Browse the repository at this point in the history
bin/gen-links
  • Loading branch information
casjay committed Jan 19, 2025
1 parent bd63e54 commit 8749d2f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/gen-links
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ __awk() { awk "$@" 2>/dev/null; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__sed() { sed "$@" 2>/dev/null; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__retrieve_page_title() { grep -E 'og:description|<title>.*</title>|meta property="og:title" content' | sed 's|.*="||g;s|".*||g;s|.*<title>||g;s|</title.*||g;s,|.*,,g' | grep -Ev '[|]|-' | head -n3 | grep '^'; }
__retrieve_page_title() { echo "$1" | grep '<title>.*</title>|' | sed 's|.*<title>||g;s|</title.*' | grep '^' || return 1; }
__retrieve_page_meta() { grep -E 'og:description|meta property="og:title" content' | sed 's|.*="||g;s|".*||g;s|.*<title>||g;s|</title.*||g;s,|.*,,g' | grep -Ev '[|]|-' | head -n1 | grep '^' || return 1; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__set_page_title() {
set -x
Expand Down Expand Up @@ -566,14 +567,16 @@ __watch_files() {
__get_page_title() {
link_title=""
local exitCode=0
local retrieve_title=""
local link_url="$1"
local url_contents=""
local retrieve_title=""
builtin printf '%s' "$link_url" | grep -q '\-----------' && link_url="" && return 1
builtin printf '\r%b%s%b ' "${YELLOW}" "Setting up ${link_url:0:120}" "${NC}"
if [ -n "$GEN_LINKS_LOOKUP" ]; then
if __check_status "$link_url" &>/dev/null; then
set -x
retrieve_title="$(curl -q -LSsf "$link_url" 2>/dev/null | __retrieve_page_title | grep '^' || false)"
url_contents="$(curl -q -LSsf "$link_url" 2>/dev/null)"
retrieve_title="$(echo "$url_contents" | __retrieve_page_meta | grep '^' || echo "$url_contents" | __retrieve_page_title | grep '^' || false)"
set_title="$(__set_page_title "$link_url" "$retrieve_title" | grep '^' || false)"
if [ -n "$set_title" ]; then
link_title="$set_title"
Expand Down

0 comments on commit 8749d2f

Please sign in to comment.