RSS reader-2 : newsraft

- 注意：以下の記事を参考にされ、問題が生じた場合、責任は負えません。
- 基本的には私の忘備録です。
- 使用環境は **manjaro-linux** と時々macです。
- windowsでは利用できない設定があります。
- 本文を英語で記載してますが、中学生レベルですので、容易に理解できると思います。
- 英語で書くと、わかりにくいと思われる部分は、日本語にしてます。
- link先に了解なく引用している部分がありますので、問題があればご連絡ください。

# 前置き: CLI で使えるRSS Reader
今回はつい先程発見した **newsraft**　を紹介。
[ArchWki](https://wiki.archlinux.jp/index.php/Newsraft)によると、newsboatの軽量版か？。
先ほど動かしたところ、newsboatより軽快で、カスタマイズもしやすく、良さそうな感触。
まだWEB上での記事は少ない。

>Newsraft は ncurses フィードリーダーであり、Newsboat に触発されつつ、その軽量な代替品を目指しています。RSS 2.0 以下、Atom 1.0、RSS Content Module、Media RSS、DublinCore 1.1 Elements、および JSON Feed をサポートしています。


https://codeberg.org/newsraft/newsraft

https://codeberg.org/newsraft/newsraft/src/branch/main/doc/comparison-newsboat.md


#### other RSS reader

- **[srss](https://github.com/sheepla/srss)** : Tiny application & minimal functions.
- **[cleed](https://github.com/radulucut/cleed?tab=readme-ov-file)** : Tiny application & output RSS feeds at once.
- **[newboat](https://newsboat.org/releases/2.10/docs/newsboat.html#_introduction)** : **Great application!** It has many functions and can be customized as you like. It's a bit heavy, comparing above two apps, but lighter than GUI applications.
- **[Vim Style Newsboat](https://github.com/qq542vev/vim-style-newsboat)** : Good example to customize newsboat. 

# 1. newsraft

- help menu

```
newsraft -h
newsraft - feed reader for terminal

  -f PATH    force use of PATH as feeds file
  -c PATH    force use of PATH as config file
  -d PATH    force use of PATH as database file
  -l PATH    write log information to PATH
  -e ACTION  execute ACTION and exit
  -v         print version and successfully exit
  -h         print this message and successfully exit

ACTION is one of the following: reload-all, print-unread-items-count, purge-abandoned
```


## 1-1. Install

- AUR PKG, very small application.
```
yay -S newsraft

パッケージ (1) gumbo-parser-0.13.0-1
合計ダウンロード容量:  0.12 MiB
合計インストール容量:  0.37 MiB

パッケージ (1) newsraft-0.29-1
合計インストール容量:  0.18 MiB
```

- newsraft has pkgs for other distributions. Read its home page.

https://codeberg.org/newsraft/newsraft

#### compile from source

It was easy than I think. Get source files & install some tools & make.
Read the documents to compile newsraft for your environment.

https://codeberg.org/newsraft/newsraft/src/branch/main/doc/build-instructions.md

-  "make"  examaple for mac.
```
## clone source page 
git clone https://codeberg.org/newsraft/newsraft.git

## install some tools for my env.
brew intsall yaji gumbo-parser

## make newsraft.
make CFLAGS="-DCURL_WRITEFUNC_ERROR=0xFFFFFFFF"

## install.
## install binary inside /usr/local/bin/

sudo make install

## Or you can copy binary in your $PATH
## I copy binary to $HOME/bin/

cp -a newsraft ~/bin/
```

## 1-2. Set up

Read **neswraft man page on the web**, or ``` man newsraft``` carefully.

- man page on the web

https://newsraft.codeberg.page/

- need two files to run newsraft. 

```
# general config
$HOME/.config/newsraft/config

# URLs
$HOME/.config/newsraft/feeds
```

- Here is sample files from newsraft.org

https://codeberg.org/newsraft/newsraft/src/branch/main/doc/examples

#### 1-2-A. Add URLs to feeds file.

**Newsraft has a unique way of managing URLs (RSS feeds) !**
It handle URLs, not only gtoup (secssion), but also each URL. 

```
 @ : creates groups of URLs, and manage refresh intervals etc.
 < : change some parameter.
```

- **@**  : create(section) URLs group under @ .
>Section(group) lines start with @ character. After any number of whitespace characters, the name of the section must be specified. For example:

- **URL, group(section) < reload-period time ; item-limit 500**  # refresh time (min); limit showing item num.
  You can add others parameter ; confirm it on the man page.


```
vim ~/.config/newsraft/feeds

## refresh interval 30min
@ news < reload-period 30
## BBC
http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml "BBC"
## Rueter
https://www.reutersagency.com/en/reutersbest/reuters-best-rss-feeds/ "Rueter"

## refresh 10min
@ NHK < reload-period 10
## NHK
## 主要news
https://www.nhk.or.jp/rss/news/cat0.xml "NHK main"
##政治
https://www.nhk.or.jp/rss/news/cat4.xml < reload-period 30
##経済
https://www.nhk.or.jp/rss/news/cat5.xml


@ Arch, Manjaro < reload-period 3600
## manjaro
https://forum.manjaro.org/c/announcements/stable-updates/12.rss "manjaro" < reload-period 4200
## Arch news
https://archlinux.org/feeds/news/
## about linux
https://www.youtube.com/feeds/videos.xml?channel_id=UCkf4VIqu3Acnfzuk3kRIFwA "Linux Youtube"
```


#### 1-2-B. config file.

**set color, key-bind, macro etc**

```
vim ~/.config/newsraft/config

## Delete cache of feeds you unsubscribed when database big.
## database: $HOME/.local/share/newsraft/
## not macro,  type below on the terminal
#newsraft -e purge-abandoned

## now work...
## ? : show up man page
#bind ? exec man newsraft

#BROWSER=/usr/bin/brave
open-in-browser-command /usr/bin/brave "%l"

##
# Colors

# Settings
user-agent ""  # User-Agent header will not be sent.

## refresh interval ; min
reload-period 10

## show feeds number
#item-limit 100

##
#pager-width 100 # default 100

##
copy-to-clipboard-command xclip -selection clipboard

## contents showing seting
## date format pf contents
#item-content-date-format %a, %d %b %Y %H:%M:%S %z  ## default
item-content-date-format  %Y/%m/%d/%H%M_%S %z

## date format of each feed list menu
#list-entry-date-format %b %d  # default
list-entry-date-format %b/%d

##==== Key bindings, shortcut, macro =============
#
bind d mark-read

## unset keys
unbind D     ## set un-read
unbind ^D    ## set read all
#unbind h    ## paret menu or quit at top menu

## open link uisng appli.
bind i exec nsxiv "%l"
#bind m exec mpv "%l"

## play mpv using yt-dlp
bind m exec yt-dlp -f "bestvideo[width<1300]"  "%l" -o - | mpv --no-audio - -force-seekable=yes
## download video
bind y exec yt-dlp "%l" -o /data/yy_aria_dw/"%%(title)s_.%%(ext)s"


```



## 1-3. Run newsraft & how does it display RSS feeds ?

- newsraft shows **group(section) name** at the top page.  
```
newsraft

  589 @ Global
   57 @ news    # contakns BBC & Router news
  359 @ NHK     #  NHK 
   88 @ Arch, Manjaro # Ach & manjaro & youtube
```

- under the **news** tab.
```
  45 │ BBC
  12 │ Rueter
```

- under the **BBC**
```
## N : un-read page

   │  3月 19 │ Having autism has worked to my advantage in football - Bronze
 N │  3月 19 │ 'After five years in jail, they agree I'm innocent but won't pay out'
 N │  3月 19 │ Russia and Ukraine carry out attacks after Putin-Trump call
 N │  3月 19 │ Google agrees to pay $28m in racial bias lawsuit
   │  3月 19 │ 'World's ugliest animal' is New Zealand's fish of the year
 N │  3月 19 │ Starmer says cost of sickness benefits 'devastating'
 N │  3月 19 │ Last trove of JFK assassination files released
 N │  3月 19 │ Putin agrees in Trump call to pause Ukraine energy attacks but no full ceasefire
```

- if you want to read page using web-browser, type "o", and [1] page shows up.
  But soemteimes browser output a lot of massage in the terminal... That disrupts reading RSS feeds.

```
  Feed:  BBC
  Title: Having autism has worked to my advantage in football - Bronze
  Date:  水, 19 3月 2025 15:10:17 +0900

  Chelsea and England defender Lucy Bronze opens up for the first time about her autism and ADHD
  diagnoses to raise awareness and help others.

  ───────────────────────────────────────────────────────────────────────────────────────
  [1]: https://www.bbc.com/sport/football/articles/c70el9el7x9o
```


## 1-4. Using short-cut, macro.
 
 - create some macro in the config, like blow.

 ```
## show key map
## create your key map_file under config/newsraft/keymap
## sample is below (see 1-5). 
bind ? exec less $HOME/.condif/ewsraft/keymap

## open link
## open link uisng appli.
bind i exec nsxiv "%l"
#bind m exec mpv "%l"

## play mpv using yt-dlp.
bind m exec yt-dlp -f "bestvideo[width<1300]"  "%l" -o - | mpv --no-audio - -force-seekable=yes
## download video
bind y exec yt-dlp "%l" -o /data/yy_aria_dw/"%%(title)s_.%%(ext)s"
```

# 1-5. Default keymap

- From man page
```
|Actions                  |    Keys                              |
|-------------------------|--------------------------------------|
|select-next              | j/ KEY_DOWN/ ^E                      |
|select-prev              | k/ KEY_UP/ ^Y                        |
|select-next-page         | space/ ^F/ KEY_NPAGE                 |
|select-next-page-half    | ^D                                   |
|select-prev-page         | ^B/ KEY_PPAGE                        |
|select-prev-page-half    | ^U                                   |
|select-first             | g/ KEY_HOME                          |
|select-last              | G/ KEY_END                           |
|jump-to-next             | J                                    |
|jump-to-prev             | K                                    |
|jump-to-next-unread      | n                                    |
|jump-to-prev-unread      | N                                    |
|jump-to-next-important   | p                                    |
|jump-to-prev-important   | P                                    |
|goto-feed                | *                                    |
|shift-west               | ,                                    |
|shift-east               | .                                    |
|shift-reset              | <                                    |
|sort-by-time             | t                                    |
|sort-by-rowid            | w                                    |
|sort-by-unread           | u                                    |
|sort-by-initial          | z                                    |
|sort-by-alphabet         | a                                    |
|sort-by-important        | i                                    |
|enter                    | enter/ l/ KEY_ENTER/ KEY_RIGHT       |
|reload                   | r                                    |
|reload-all               | R/ ^R                                |
|mark-read; jump-to-next  | d                                    |
|mark-unread; jump-to-next| D                                    |
|mark-read-all            | A                                    |
|mark-unread-all          | (not set)                            |
|mark-important           | f                                    |
|mark-unimportant         | F                                    |
|toggle-explore-mode      | tab/ e                               |
|view-errors              | v                                    |
|open-in-browser          | o                                    |
|copy-to-clipboard        | y/ c                                 |
|start-search-input       | /                                    |
|clean-status             | escape                               |
|navigate-back            | h/ backspace/ KEY_LEFT/ KEY_BACKSPACE|
|quit                     | q                                    |
|quit-hard                | Q                                    |
```


# Reference

- main

https://codeberg.org/newsraft/newsraft

- man page on the web (read it in the terminal ; **man newsraft** )

https://newsraft.codeberg.page/

- comparing newsraft to newsboat

https://codeberg.org/newsraft/newsraft/src/branch/main/doc/comparison-newsboat.md

- Find a lot of RSS feeds URLs

https://smarttech101.com/how-to-setup-newsboat-rss-reader-in-linux


#===== other RSS eader ============================

https://github.com/sheepla/srss

https://github.com/radulucut/cleed?tab=readme-ov-file

https://newsboat.org/releases/2.10/docs/newsboat.html#_introduction

https://github.com/qq542vev/vim-style-newsboat