abcjustinrss

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

README

Overview

This application scrapes the "Just In" section of ABC News and generates an RSS feed.

Installation

Prerequisites
  • Go (if building from source)
Optional
  • Apache or Nginx (for serving RSS files)
Build and Install
Install only (System level)

Grab the latest binary here, deb, rpm, etc: https://github.com/arran4/abc-justin-rss/releases/

Install and build as user (User)

Install go 1.23+

Run go install:

go install github.com/arran4/abc-justin-rss/cmd/abcjustinrss@latest

This installs to $HOME/go/bin (typically check with go env)

Usage
Generate RSS Feed
abcjustinrss -output /var/www/localhost/htdocs/rss/abcjustinrss.xml
Deployment
rc.d (Cron Job system level)

Add a cron job to run the script periodically:

  1. Edit the root crontab:
    sudo crontab -e
    
  2. Add the following line:
    */15 * * * * /usr/local/bin/abcjustinrss -output /var/www/localhost/htdocs/rss/abcjustinrss.xml
    
rc.d (Cron Job user level)

Add a cron job to run the script periodically:

  1. Edit the user's crontab:
    crontab -e
    
  2. Add the following line:
    */15 * * * * ~/go/bin/abcjustinrss -output ~/public_html/rss/abcjustinrss.xml
    

Remember to modify ~ with the correct value and go/bin too if you're using a custom go env location

systemd (as root)
  1. Create a systemd service file at /etc/systemd/system/abcjustinrss.service:
[Unit]
Description=ABC News Just-in RSS Feed Creator

[Service]
Type=oneshot
ExecStart=/usr/bin/abcjustinrss -output /var/www/localhost/htdocs/rss/abcjustinrss.xml
User=apache
Group=apache
  1. Create a systemd timer file at /etc/systemd/system/everyhour@.timer:
[Unit]
Description=Monthly Timer for %i service

[Timer]
OnCalendar=*-*-* *:00:00
AccuracySec=1h
RandomizedDelaySec=1h
Persistent=true
Unit=%i.service

[Install]
WantedBy=default.target
  1. Reload systemd and start the service:
    sudo systemctl daemon-reload
    sudo systemctl enable --now everyhour@abcjustinrss.timer
    
systemd (as user)
  1. Create a systemd service file at $HOME/.config/systemd/user/abcjustinrss.service:
[Unit]
Description=ABC News Just-in RSS Feed Creator

[Service]
Type=oneshot
ExecStart=%h/go/bin/abcjustinrss -output %h/public_html/rss/abcjustinrss.xml

Remember to modify $HOME with the correct value and go/bin too if you're using a custom go env location

  1. Create a systemd timer file at $HOME/.config/systemd/user/everyhour@.timer:
[Unit]
Description=Monthly Timer for %i service

[Timer]
OnCalendar=*-*-* *:00:00
AccuracySec=1h
RandomizedDelaySec=1h
Persistent=true
Unit=%i.service

[Install]
WantedBy=default.target
  1. Reload systemd and start the service:
    systemctl --user daemon-reload && systemctl --user enable --now everyhour@abcjustinrss.timer
    
Apache VirtualHost Configuration
User

Refer to documentation for setting up public_html directories

Enjoy

http://localhost/~$USERNAME/rss/abcjustinrss.xml

System

Add the following configuration to your Apache setup (e.g., /etc/httpd/conf.d/rss.conf):

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/localhost/htdocs/rss
    <Directory "/var/www/localhost/htdocs/rss">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>
Nginx Configuration
User

Refer to documentation for setting up public_html directories

System

Add this to your Nginx server block:

server {
    listen 80;
    server_name example.com;

    location /rss/ {
        root /var/www/localhost/htdocs;
        autoindex on;
    }
}

Documentation

Index

Constants

View Source
const BaseURL = "https://www.abc.net.au"
View Source
const JustInURL = BaseURL + "/news/justin"

Variables

This section is empty.

Functions

func DeducePublicationDate

func DeducePublicationDate(relativeTime string) string

DeducePublicationDate converts relative times like "15 minutes ago" into absolute timestamps.

func IsArticleLink(link string) bool

IsArticleLink filters valid article links.

Types

type Channel

type Channel struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description string `xml:"description"`
	Items       []Item `xml:"item"`
}

Channel represents the RSS channel.

type Item

type Item struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description string `xml:"description"`
	PubDate     string `xml:"pubDate"`
	GUID        string `xml:"guid"`
}

Item represents an RSS feed item.

type RSS

type RSS struct {
	XMLName xml.Name `xml:"rss"`
	Version string   `xml:"version,attr"`
	Channel Channel  `xml:"channel"`
}

RSS defines the structure of the RSS feed.

func FetchAndParseNewsToRSS

func FetchAndParseNewsToRSS() (error, RSS)

Directories

Path Synopsis
cmd
abcjustinrss command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL