;;; my-ttrss.el -- ttrss utilities -*- lexical-binding: t -*- ;; Copyright (C) 2025 Free Software Foundation, Inc. ;; Author: Yuchen Pei ;; Package-Requires: ((emacs "30.1")) ;; This file is part of dotted. ;; dotted is free software: you can redistribute it and/or modify it under ;; the terms of the GNU Affero General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; dotted is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General ;; Public License for more details. ;; You should have received a copy of the GNU Affero General Public ;; License along with dotted. If not, see . ;;; Commentary: ;; ttrss utilities. ;;; Code: (require 'ttrss) (defun my-ttrss-fetch (n) "Fetch N articles." (let ((ttrss-sid (ttrss-login ttrss-address ttrss-user ttrss-password))) (if (ttrss-logged-in-p ttrss-address ttrss-sid) (ttrss-get-headlines ttrss-address ttrss-sid :feed_id -4 :limit n :show_content t :include_attachments t) (message "Login failed")))) (defun my-ttrss-save-article (info) (with-temp-buffer (insert "

" "" (plist-get info :title) "" "

") (insert "

" "" (plist-get info :feed_title) "") (when-let ((author (plist-get info :author))) (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 ((change-major-mode-with-file-name nil)) (write-file (my-ttrss-format-file-name info))))) (defun my-ttrss-format-file-name (info) "Format: $author - $title ($year) [ttrss$id].html" (let ((author (plist-get info :author))) (file-name-concat my-webpage-incoming-dir (my-make-doc-file-name (format "%s - %s (%s) [ttrss%s].html" (if (string-empty-p author) (plist-get info :feed_title) author) (plist-get info :title) (format-time-string "%Y" (encode-time (decode-time (plist-get info :updated)))) (plist-get info :id)))))) (provide 'my-ttrss) ;;; my-ttrss.el ends here