From 8a323e67e20621de57c5e627b410f5080d7f5bff Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Mon, 5 Aug 2024 19:09:06 -0400 Subject: [PATCH] Modified Readme and .gitignore --- .gitignore | 1 + README.rst | 19 +++++++++++++++++++ main.go | 12 ++++++++---- server.yml | 1 + server.yml.template | 7 +++++++ 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 README.rst create mode 100644 server.yml.template diff --git a/.gitignore b/.gitignore index 0f52742..c061b64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.log *.txt anitoru +server.yml diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5d7019f --- /dev/null +++ b/README.rst @@ -0,0 +1,19 @@ +======= +AniToru +======= +AniToru is an automatic downloader for anime following the release group `Erai-raws `__. +Its executable acts as both the client and the server. The server polls from RSS, or downloads the +searched items from Nyaa. An rTorrent server needs to be running. Notifications are sent to your phone +through `ntfy `__ for when an anime has been downloaded. + +Usage +===== +First, you need to build the executable. To do this, you must have `Go `__, and run `go build ./`. +Before you start, you need to edit the configuration file, which is `server.yml` You will need to rename `server.yml.template`, +which details the purpose of each item. + +Afterwards, you can simply run the exectuable with `anitoru --daemon` for the server. To add subscriptions, you can +run `anitoru` and navigate the CLI. + +To run it as a system service, for Debian based systems, a template service file is given. Typically the proper location for +services files is `/etc/systemd/system/`. diff --git a/main.go b/main.go index 09b086e..f7bf647 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ var InvalidDotfile error = errors.New("Dotfile invalid.") type Configuration struct { BaseDir string `config:"baseDir"` RTorrentHost string `config:"rTorrentHost"` + RSSURL string `config:rssURL` PollingRate int `config:"pollingRate"` DownloadDir string `config:"downloadDir"` LogPath string `config:"logPath"` @@ -146,11 +147,11 @@ func GetReleaseSchedule() ([]string, error) { }).End() } -func GetRSS() ([]Anime, error) { +func GetRSS(rssURL string) ([]Anime, error) { var animes []Anime fp := gofeed.NewParser() - feed, err := fp.ParseURL(RSSURL) + feed, err := fp.ParseURL(rssURL) return animes, e.If(err).Then(func() { for _, item := range feed.Items { @@ -243,6 +244,7 @@ type Daemon struct { Tor *rtorrent.RTorrent PollingRate time.Duration DownloadDir string + RSSURL string Listener chan net.Conn Subscriptions map[string]struct{} LogOptions []e.LogOption @@ -250,7 +252,7 @@ type Daemon struct { } func NewDaemon(server string, polling int, download string, socket net.Listener, - notifyError bool, subPath string) Daemon { + notifyError bool, subPath string, rssURL string) Daemon { // Connect to rTorrent tor := rtorrent.New(server, false) name, err := tor.Name() @@ -287,6 +289,7 @@ func NewDaemon(server string, polling int, download string, socket net.Listener, Tor: tor, PollingRate: time.Duration(polling), DownloadDir: download, + RSSURL: rssURL, Listener: listener, Subscriptions: subMap, LogOptions: opt, @@ -310,7 +313,7 @@ func (d *Daemon) Serve() { } func (d *Daemon) CheckRSS() { - animes, err := GetRSS() + animes, err := GetRSS(d.RSSURL) if e.LogIf(err, d.LogOptions...) { return } @@ -538,6 +541,7 @@ func main() { daemon := NewDaemon( conf.RTorrentHost, conf.PollingRate, conf.DownloadDir, sock, conf.NotifyError, filepath.Join(conf.BaseDir, SubscriptionsFile), + conf.RSSURL, ) daemon.Serve() } else { diff --git a/server.yml b/server.yml index 3b3602e..d166536 100644 --- a/server.yml +++ b/server.yml @@ -1,4 +1,5 @@ baseDir: ./ +rssURL: https://www.erai-raws.info/feed/?res=1080p&type=magnet&subs%5B0%5D=us&v0=no&d157edc6b50f28b2776442c03d067d56 rTorrentHost: http://localhost/rTorrent pollingRate: 15 downloadDir: /data/Videos/Anime/ diff --git a/server.yml.template b/server.yml.template new file mode 100644 index 0000000..e1231ca --- /dev/null +++ b/server.yml.template @@ -0,0 +1,7 @@ +baseDir: /path/to/executable # The directory that the executable is located in. +rssURL: http://my-rss.com # The RSS link given by Erai-raws. +rTorrentHost: http://localhost/rTorrent # The link to the rTorrent server +pollingRate: 15 # The number of minutes to poll the RSS feed. +downloadDir: /path/to/download # The base location of where the downloaded files should go. +logPath: anitoru.log # Path to write log file. +notifyError: true # Set to false to disable notifications.