From bc299eac5c1e4f4463e09c892ba4e3b09f82a9c1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 31 Aug 2025 20:58:25 +1000 Subject: [emacs] my-ttrss sets mtime of articles Also added a standalone script to call the fetch function --- emacs/.emacs.d/lisp/my/my-ttrss.el | 66 +++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'emacs/.emacs.d/lisp/my/my-ttrss.el') diff --git a/emacs/.emacs.d/lisp/my/my-ttrss.el b/emacs/.emacs.d/lisp/my/my-ttrss.el index 3cf6856..046f596 100644 --- a/emacs/.emacs.d/lisp/my/my-ttrss.el +++ b/emacs/.emacs.d/lisp/my/my-ttrss.el @@ -27,6 +27,8 @@ ;;; Code: (require 'ttrss) +(require 'my-utils) +(require 'org-macs) ;;; TODO: my-ttrss-save-recent @@ -94,10 +96,15 @@ (ttrss-get-headlines ttrss-address sid :feed_id (plist-get feed :id) :show_content t :include_attachments t - :since_id (my-ttrss-feed-last-id feed)))) + :since_id (my-ttrss-feed-get-last-id feed)))) (seq-do 'my-ttrss-save-article articles) (unless (seq-empty-p articles) - (my-ttrss-feed-write-last-id feed (plist-get (elt articles 0) :id))) + (my-ttrss-feed-write-last-id + feed + (seq-reduce + (lambda (acc article) (max acc (plist-get article :id))) + articles + 0))) (message "%s Done - total %d articles" message-head (length articles)))) @@ -127,33 +134,34 @@ (unless (or (string-empty-p author) (equal author (plist-get info :feed_title))) (insert " (" author ")"))) - (insert " " - (format-time-string - "%Y-%m-%d %a %H:%M:%S" - (encode-time (decode-time (plist-get info :updated))))) - (insert "

") - (let ((tags (plist-get info :tags))) - (unless (seq-empty-p tags) - (insert "

tags: " (string-join tags ";") "

"))) - (insert (plist-get info :content)) - (let ((attached (plist-get info :attachments))) - (unless (seq-empty-p attached) - (insert "

Article attachments:

\n"))) - (let* ((change-major-mode-with-file-name nil) - (coding-system-for-write 'utf-8) - (inhibit-message t) - (file-name (my-ttrss-format-file-name info)) - (dir (file-name-directory file-name))) - (unless (file-exists-p dir) (make-directory dir t)) - (write-file file-name)))) + (let ((updated (format-time-string + "%Y-%m-%d %a %H:%M:%S" + (encode-time (decode-time (plist-get info :updated)))))) + (insert " " updated) + (insert "

") + (let ((tags (plist-get info :tags))) + (unless (seq-empty-p tags) + (insert "

tags: " (string-join tags ";") "

"))) + (insert (plist-get info :content)) + (let ((attached (plist-get info :attachments))) + (unless (seq-empty-p attached) + (insert "

Article attachments:

\n"))) + (let* ((change-major-mode-with-file-name nil) + (coding-system-for-write 'utf-8) + (inhibit-message t) + (file-name (my-ttrss-format-file-name info)) + (dir (file-name-directory file-name))) + (unless (file-exists-p dir) (make-directory dir t)) + (write-file file-name) + (my-touch-file-mtime file-name updated))))) (defvar my-ttrss-dir "~/Downloads") -- cgit v1.2.3