dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

commit 81231f3a9d4ac6d26eff91a6cf53da175aa0b60b
parent 71df7639065b394c1c50daeec888ce7f6d671ddd
Author: regexghost <dev@regexghost.com>
Date:   Sun,  2 Aug 2026 23:33:32 +0100

teen-vogue article parser, part of newsraft scripts

Diffstat:
Mdotfiles/.config/newsraft/article.sh | 2++
Adotfiles/.config/newsraft/teen-vogue.sh | 34++++++++++++++++++++++++++++++++++
Mlists/dotfiles | 1+
3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/dotfiles/.config/newsraft/article.sh b/dotfiles/.config/newsraft/article.sh @@ -2,4 +2,6 @@ if echo "$1" | grep -q "bbc"; then ~/.config/newsraft/bbc-news.sh "$1" +elif echo "$1" | grep -q "teenvogue"; then + ~/.config/newsraft/teen-vogue.sh "$1" fi diff --git a/dotfiles/.config/newsraft/teen-vogue.sh b/dotfiles/.config/newsraft/teen-vogue.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +TEMP_FILE="/tmp/teen_vogue_article.html" +OUTPUT_FILE="/tmp/teen_vogue_article.md" + +curl -s "$1" > "$TEMP_FILE" + +title="$(cat "$TEMP_FILE" | pup 'meta[property="og:title"] attr{content}' | xmlstarlet unesc)" +description="$(cat "$TEMP_FILE" | pup 'meta[name="description"] attr{content}' | xmlstarlet unesc)" +picture="$(cat "$TEMP_FILE" | pup 'img attr{src}' | head -n 2 | tail -n 1)" +picture_desc="$(cat "$TEMP_FILE" | pup 'div [class*="CaptionWrapper"]:nth-of-type(1) text{}' | xmlstarlet unesc)" + +echo "# $title" > "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" +echo "> $description" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" +echo "![${picture_desc}](${picture})" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" +echo "## Article" >> "$OUTPUT_FILE" + +end="$(cat "$TEMP_FILE" | sed 's/<\/h2>/<\/h2>\n/g' | grep -n "Want more great .* stories" | head -n 1 | cut -d ":" -f 1)" +content="$(cat "$TEMP_FILE" | sed 's/<\/h2>/<\/h2>\n/g' | head -n "$end" | sed 's/<b[^>]*>[^<]*<\/b>//g' |\ +sed 's/<!-- -->external//g' |\ +sed 's/<span[^>]*>[^<]*<\/span>//g' |\ +sed 's/<em[^>]*>[^<]*<\/em>//g' |\ +sed 's/<strong[^>]*>[^<]*<\/strong>//g' |\ +sed 's/<a[^>]*>/ /g' | \ +sed 's/<\/a>//g' |\ + pup | pup 'p text{}' | sed 's/^[ ]*//g' | xmlstarlet unesc | awk 'NF > 0 {blank=0} NF == 0 {blank++} blank < 2')" + +echo "$content" | fold -s >> "$OUTPUT_FILE" + +${PAGER:-less} "$OUTPUT_FILE" + diff --git a/lists/dotfiles b/lists/dotfiles @@ -34,6 +34,7 @@ ~/.config/newsraft/article.sh ~/.config/newsraft/reddit-refresh.sh ~/.config/newsraft/combine-feeds.sh +~/.config/newsraft/teen-vogue.sh ~/.config/wgetrc ~/.config/mpv/mpv.conf ~/.config/mpv/input.conf