diff options
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-ttrss.el')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-ttrss.el | 66 |
1 files changed, 37 insertions, 29 deletions
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 "</p>") - (let ((tags (plist-get info :tags))) - (unless (seq-empty-p tags) - (insert "<p>tags: " (string-join tags ";") "</p>"))) - (insert (plist-get info :content)) - (let ((attached (plist-get info :attachments))) - (unless (seq-empty-p attached) - (insert "<p>Article attachments:</p>\n<ul>") - (seq-do (lambda (at) - (let ((title (plist-get at :title)) - (url (plist-get at :content_url))) - (insert "\n<li><a href=" url ">" - (if (string-empty-p title) url title) - "</a></li>"))) - attached) - (insert "\n</ul>"))) - (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 "</p>") + (let ((tags (plist-get info :tags))) + (unless (seq-empty-p tags) + (insert "<p>tags: " (string-join tags ";") "</p>"))) + (insert (plist-get info :content)) + (let ((attached (plist-get info :attachments))) + (unless (seq-empty-p attached) + (insert "<p>Article attachments:</p>\n<ul>") + (seq-do (lambda (at) + (let ((title (plist-get at :title)) + (url (plist-get at :content_url))) + (insert "\n<li><a href=" url ">" + (if (string-empty-p title) url title) + "</a></li>"))) + attached) + (insert "\n</ul>"))) + (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") |