diff --git a/homeConfigurations/tejing/news/default.nix b/homeConfigurations/tejing/news/default.nix index 8eb9584..cf6a013 100644 --- a/homeConfigurations/tejing/news/default.nix +++ b/homeConfigurations/tejing/news/default.nix @@ -39,6 +39,9 @@ in # Enable my sfeed module my.sfeed.enable = true; + # Fix a bug related to IFS in sfeed_update + my.sfeed.package = pkgs.sfeed.overrideAttrs (old: { patches = (old.patches or []) ++ [ ./fix_IFS.patch ]; }); + # Pass useful args through to submodule config my.sfeed.rc._module.args = { inherit pkgs my; }; my.sfeed.rc.imports = [ diff --git a/homeConfigurations/tejing/news/fix_IFS.patch b/homeConfigurations/tejing/news/fix_IFS.patch new file mode 100644 index 0000000..cb07885 --- /dev/null +++ b/homeConfigurations/tejing/news/fix_IFS.patch @@ -0,0 +1,16 @@ +diff --git a/sfeed_update b/sfeed_update +index bc74470..4d4d476 100755 +--- a/sfeed_update ++++ b/sfeed_update +@@ -239,10 +239,9 @@ main() { + # process a single feed. + # parameters are: config, tmpdir, name, feedurl, basesiteurl, encoding + if [ "${SFEED_UPDATE_CHILD}" = "1" ]; then +- IFS="" # "\037" + [ "$1" = "" ] && exit 0 # must have an argument set + printf '%s\n' "$1" | \ +- while read -r _config _tmpdir _name _feedurl _basesiteurl _encoding; do ++ while IFS="" read -r _config _tmpdir _name _feedurl _basesiteurl _encoding; do + loadconfig "${_config}" + sfeedtmpdir="${_tmpdir}" + _feed "${_name}" "${_feedurl}" "${_basesiteurl}" "${_encoding}" diff --git a/homeConfigurations/tejing/news/rc.public.nix b/homeConfigurations/tejing/news/rc.public.nix index e4c17dc..64a3bb1 100644 --- a/homeConfigurations/tejing/news/rc.public.nix +++ b/homeConfigurations/tejing/news/rc.public.nix @@ -286,4 +286,33 @@ in [ .timestamp, .title, .link, "", "", .link, "", .magnet, "" ] | @tsv ''}''; }; + + # Fetch from Patreon api. Always pair with patreon parser + fetch.patreon = { + code = '' + local campaign="$(curl -sSLf "$2" | hred '^ script#__NEXT_DATA__ @.textContent' -r | jq '.props.pageProps.bootstrapEnvelope.pageBootstrap.campaign.data.id' -r)" + local cursor="" + local done="" + while [ -z "$done" ];do + exec {fd}< <( + curl -sSf "https://www.patreon.com/api/posts" --url-query "filter[campaign_id]=$campaign" --url-query "sort=-published_at" ''${cursor:+--url-query "page[cursor]=$cursor"} | + jq 'if .meta.pagination.cursors.next == null then "" else .meta.pagination.cursors.next end,.' -rc + ) + read -u $fd -r cursor + if [ -z "$cursor" ]; then + done=1 + fi + cat <&$fd + exec {fd}<&- + done + ''; + }; + # Parse Patreon api. Always pair with the patreon fetcher. + parse.patreon = { + code = ''json_parse '' + toFile "patreon.jq" '' + . as $all | + .data[] | + [ .attributes.published_at, .attributes.title, .attributes.url, .attributes.teaser_text, "html", .id, null, null, ([.relationships.user_defined_tags.data[] | select(.type == "post_tag") | .id as $id | $all.included[] | select(.type == "post_tag" and .id == $id) | .attributes.value] | join("|")) ] | @tsv + ''; + }; } diff --git a/homeConfigurations/tejing/news/rc.secret.nix b/homeConfigurations/tejing/news/rc.secret.nix index 7431b81..f4123bc 100644 Binary files a/homeConfigurations/tejing/news/rc.secret.nix and b/homeConfigurations/tejing/news/rc.secret.nix differ