mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(feeds): add generic RSS support (#410)
* feat(feeds): add generic rss support * feat(feeds/web): add generic rss support * implement rss downloading * gosum + mod * re-add size from Custom field. * implement uploader + category * sync * remove double assignment (+torznab) * didn't save the rss file >.> * cleanup * fixfeeds): create rss indexer * fix(feeds): stop feed * feat(feeds): support nexusphp rss enclosure link * feat(feeds): check size for custom size * fix(feeds): race condition and only stop enabled feeds * fix(feeds): unify indexer implementation badge Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
This commit is contained in:
parent
b607aef63e
commit
b50688159e
17 changed files with 498 additions and 89 deletions
7
go.mod
7
go.mod
|
@ -39,10 +39,12 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.1 // indirect
|
||||||
github.com/ajg/form v1.5.1 // indirect
|
github.com/ajg/form v1.5.1 // indirect
|
||||||
github.com/anacrolix/dht/v2 v2.18.0 // indirect
|
github.com/anacrolix/dht/v2 v2.18.0 // indirect
|
||||||
github.com/anacrolix/missinggo v1.3.0 // indirect
|
github.com/anacrolix/missinggo v1.3.0 // indirect
|
||||||
github.com/anacrolix/missinggo/v2 v2.7.0 // indirect
|
github.com/anacrolix/missinggo/v2 v2.7.0 // indirect
|
||||||
|
github.com/andybalholm/cascadia v1.1.0 // indirect
|
||||||
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
|
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gdm85/go-rencode v0.1.8 // indirect
|
github.com/gdm85/go-rencode v0.1.8 // indirect
|
||||||
|
@ -53,6 +55,7 @@ require (
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/hekmon/cunits/v2 v2.1.0 // indirect
|
github.com/hekmon/cunits/v2 v2.1.0 // indirect
|
||||||
github.com/huandu/xstrings v1.3.2 // indirect
|
github.com/huandu/xstrings v1.3.2 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||||
|
@ -60,6 +63,10 @@ require (
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
github.com/mmcdole/gofeed v1.1.3 // indirect
|
||||||
|
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
||||||
|
|
19
go.sum
19
go.sum
|
@ -43,6 +43,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/Masterminds/squirrel v1.5.3 h1:YPpoceAcxuzIljlr5iWpNKaql7hLeG1KLSrhvdHpkZc=
|
github.com/Masterminds/squirrel v1.5.3 h1:YPpoceAcxuzIljlr5iWpNKaql7hLeG1KLSrhvdHpkZc=
|
||||||
github.com/Masterminds/squirrel v1.5.3/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
github.com/Masterminds/squirrel v1.5.3/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||||
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
|
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
|
||||||
github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI=
|
github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI=
|
||||||
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
|
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
|
||||||
|
@ -77,6 +79,8 @@ github.com/anacrolix/tagflag v1.0.0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pm
|
||||||
github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8=
|
github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8=
|
||||||
github.com/anacrolix/torrent v1.46.0 h1:m5SGlW4p0dJkqrIh4bCqzcKbKFFmfJorf9LSpSM5dEc=
|
github.com/anacrolix/torrent v1.46.0 h1:m5SGlW4p0dJkqrIh4bCqzcKbKFFmfJorf9LSpSM5dEc=
|
||||||
github.com/anacrolix/torrent v1.46.0/go.mod h1:3DE+VA4AgyfKDPjZcIo70D3VFZRo3bfdEBn70CGjca4=
|
github.com/anacrolix/torrent v1.46.0/go.mod h1:3DE+VA4AgyfKDPjZcIo70D3VFZRo3bfdEBn70CGjca4=
|
||||||
|
github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=
|
||||||
|
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef h1:2JGTg6JapxP9/R33ZaagQtAM4EkkSYnIAlOG5EI8gkM=
|
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef h1:2JGTg6JapxP9/R33ZaagQtAM4EkkSYnIAlOG5EI8gkM=
|
||||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef/go.mod h1:JS7hed4L1fj0hXcyEejnW57/7LCetXggd+vwrRnYeII=
|
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef/go.mod h1:JS7hed4L1fj0hXcyEejnW57/7LCetXggd+vwrRnYeII=
|
||||||
|
@ -101,6 +105,7 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/cytec/releaseparser v0.0.0-20200706155913-2341b265c370 h1:g9q5BGfDdhcXn4EmVZD8UydPXrvhSvgz3FRBn7zAJNs=
|
github.com/cytec/releaseparser v0.0.0-20200706155913-2341b265c370 h1:g9q5BGfDdhcXn4EmVZD8UydPXrvhSvgz3FRBn7zAJNs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
@ -249,6 +254,9 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
|
@ -284,10 +292,17 @@ github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/mmcdole/gofeed v1.1.3 h1:pdrvMb18jMSLidGp8j0pLvc9IGziX4vbmvVqmLH6z8o=
|
||||||
|
github.com/mmcdole/gofeed v1.1.3/go.mod h1:QQO3maftbOu+hiVOGOZDRLymqGQCos4zxbA4j89gMrE=
|
||||||
|
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf h1:sWGE2v+hO0Nd4yFU/S/mDBM5plIU8v/Qhfz41hkDIAI=
|
||||||
|
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf/go.mod h1:pasqhqstspkosTneA62Nc+2p9SOBBYAPbnmRRWPQ0V8=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/moistari/rls v0.2.6 h1:0PfId/3t2hC+uSKVvtvlH7UO6k4YLu8/tHR10dgcplQ=
|
github.com/moistari/rls v0.2.6 h1:0PfId/3t2hC+uSKVvtvlH7UO6k4YLu8/tHR10dgcplQ=
|
||||||
github.com/moistari/rls v0.2.6/go.mod h1:2oVpWLhkuUzu2xqRINGnvvlcAGizZGMfMv8UYnntUCg=
|
github.com/moistari/rls v0.2.6/go.mod h1:2oVpWLhkuUzu2xqRINGnvvlcAGizZGMfMv8UYnntUCg=
|
||||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
||||||
|
@ -345,9 +360,11 @@ github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
|
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
|
||||||
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
|
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
|
||||||
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
|
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
|
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
|
||||||
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
||||||
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
|
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
@ -379,6 +396,7 @@ github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7
|
||||||
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
|
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -438,6 +456,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
|
|
@ -50,4 +50,5 @@ type FeedType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FeedTypeTorznab FeedType = "TORZNAB"
|
FeedTypeTorznab FeedType = "TORZNAB"
|
||||||
|
FeedTypeRSS FeedType = "RSS"
|
||||||
)
|
)
|
||||||
|
|
|
@ -44,6 +44,7 @@ type IndexerDefinition struct {
|
||||||
SettingsMap map[string]string `json:"-"`
|
SettingsMap map[string]string `json:"-"`
|
||||||
IRC *IndexerIRC `json:"irc,omitempty"`
|
IRC *IndexerIRC `json:"irc,omitempty"`
|
||||||
Torznab *Torznab `json:"torznab,omitempty"`
|
Torznab *Torznab `json:"torznab,omitempty"`
|
||||||
|
RSS *FeedSettings `json:"rss,omitempty"`
|
||||||
Parse *IndexerParse `json:"parse,omitempty"`
|
Parse *IndexerParse `json:"parse,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +74,11 @@ type Torznab struct {
|
||||||
Settings []IndexerSetting `json:"settings"`
|
Settings []IndexerSetting `json:"settings"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FeedSettings struct {
|
||||||
|
MinInterval int `json:"minInterval"`
|
||||||
|
Settings []IndexerSetting `json:"settings"`
|
||||||
|
}
|
||||||
|
|
||||||
type IndexerIRC struct {
|
type IndexerIRC struct {
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
Server string `json:"server"`
|
Server string `json:"server"`
|
||||||
|
|
|
@ -155,6 +155,7 @@ type ReleaseImplementation string
|
||||||
const (
|
const (
|
||||||
ReleaseImplementationIRC ReleaseImplementation = "IRC"
|
ReleaseImplementationIRC ReleaseImplementation = "IRC"
|
||||||
ReleaseImplementationTorznab ReleaseImplementation = "TORZNAB"
|
ReleaseImplementationTorznab ReleaseImplementation = "TORZNAB"
|
||||||
|
ReleaseImplementationRSS ReleaseImplementation = "RSS"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReleaseQueryParams struct {
|
type ReleaseQueryParams struct {
|
||||||
|
|
173
internal/feed/rss.go
Normal file
173
internal/feed/rss.go
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
package feed
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/autobrr/autobrr/internal/domain"
|
||||||
|
"github.com/autobrr/autobrr/internal/release"
|
||||||
|
"github.com/autobrr/autobrr/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/mmcdole/gofeed"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RSSJob struct {
|
||||||
|
Name string
|
||||||
|
IndexerIdentifier string
|
||||||
|
Log zerolog.Logger
|
||||||
|
URL string
|
||||||
|
Repo domain.FeedCacheRepo
|
||||||
|
ReleaseSvc release.Service
|
||||||
|
|
||||||
|
attempts int
|
||||||
|
errors []error
|
||||||
|
|
||||||
|
JobID int
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRSSJob(name string, indexerIdentifier string, log zerolog.Logger, url string, repo domain.FeedCacheRepo, releaseSvc release.Service) *RSSJob {
|
||||||
|
return &RSSJob{
|
||||||
|
Name: name,
|
||||||
|
IndexerIdentifier: indexerIdentifier,
|
||||||
|
Log: log,
|
||||||
|
URL: url,
|
||||||
|
Repo: repo,
|
||||||
|
ReleaseSvc: releaseSvc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *RSSJob) Run() {
|
||||||
|
if err := j.process(); err != nil {
|
||||||
|
j.Log.Err(err).Int("attempts", j.attempts).Msg("rss feed process error")
|
||||||
|
|
||||||
|
j.errors = append(j.errors, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
j.attempts = 0
|
||||||
|
j.errors = []error{}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *RSSJob) process() error {
|
||||||
|
items, err := j.getFeed()
|
||||||
|
if err != nil {
|
||||||
|
j.Log.Error().Err(err).Msgf("error fetching rss feed items")
|
||||||
|
return errors.Wrap(err, "error getting rss feed items")
|
||||||
|
}
|
||||||
|
|
||||||
|
j.Log.Debug().Msgf("found (%d) new items to process", len(items))
|
||||||
|
|
||||||
|
if len(items) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
releases := make([]*domain.Release, 0)
|
||||||
|
|
||||||
|
for _, item := range items {
|
||||||
|
rls := domain.NewRelease(j.IndexerIdentifier)
|
||||||
|
rls.Implementation = domain.ReleaseImplementationRSS
|
||||||
|
|
||||||
|
rls.ParseString(item.Title)
|
||||||
|
|
||||||
|
if len(item.Enclosures) > 0 {
|
||||||
|
e := item.Enclosures[0]
|
||||||
|
if e.Type == "application/x-bittorrent" && e.URL != "" {
|
||||||
|
rls.TorrentURL = e.URL
|
||||||
|
}
|
||||||
|
if e.Length != "" {
|
||||||
|
rls.ParseSizeBytesString(e.Length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if rls.TorrentURL == "" && item.Link != "" {
|
||||||
|
rls.TorrentURL = item.Link
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range item.Categories {
|
||||||
|
if len(rls.Category) != 0 {
|
||||||
|
rls.Category += ", "
|
||||||
|
}
|
||||||
|
|
||||||
|
rls.Category += v
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range item.Authors {
|
||||||
|
if len(rls.Uploader) != 0 {
|
||||||
|
rls.Uploader += ", "
|
||||||
|
}
|
||||||
|
|
||||||
|
rls.Uploader += v.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
if rls.Size == 0 {
|
||||||
|
// parse size bytes string
|
||||||
|
if sz, ok := item.Custom["size"]; ok {
|
||||||
|
rls.ParseSizeBytesString(sz)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
releases = append(releases, rls)
|
||||||
|
}
|
||||||
|
|
||||||
|
// process all new releases
|
||||||
|
go j.ReleaseSvc.ProcessMultiple(releases)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *RSSJob) getFeed() (items []*gofeed.Item, err error) {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
feed, err := gofeed.NewParser().ParseURLWithContext(j.URL, ctx) // there's an RSS specific parser as well.
|
||||||
|
if err != nil {
|
||||||
|
j.Log.Error().Err(err).Msgf("error fetching rss feed items")
|
||||||
|
return nil, errors.Wrap(err, "error fetching rss feed items")
|
||||||
|
}
|
||||||
|
|
||||||
|
j.Log.Debug().Msgf("refreshing rss feed: %v, found (%d) items", j.Name, len(feed.Items))
|
||||||
|
|
||||||
|
if len(feed.Items) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(feed)
|
||||||
|
|
||||||
|
for _, i := range feed.Items {
|
||||||
|
s := i.GUID
|
||||||
|
if len(s) == 0 {
|
||||||
|
s = i.Title
|
||||||
|
if len(s) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists, err := j.Repo.Exists(j.Name, s)
|
||||||
|
if err != nil {
|
||||||
|
j.Log.Error().Err(err).Msg("could not check if item exists")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
j.Log.Trace().Msgf("cache item exists, skipping release: %v", i.Title)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// set ttl to 1 month
|
||||||
|
ttl := time.Now().AddDate(0, 1, 0)
|
||||||
|
|
||||||
|
if err := j.Repo.Put(j.Name, s, []byte(i.Title), ttl); err != nil {
|
||||||
|
j.Log.Error().Stack().Err(err).Str("entry", s).Msg("cache.Put: error storing item in cache")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// only append if we successfully added to cache
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// send to filters
|
||||||
|
return
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package feed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/autobrr/autobrr/internal/domain"
|
"github.com/autobrr/autobrr/internal/domain"
|
||||||
"github.com/autobrr/autobrr/internal/logger"
|
"github.com/autobrr/autobrr/internal/logger"
|
||||||
|
@ -12,7 +13,6 @@ import (
|
||||||
|
|
||||||
"github.com/dcarbone/zadapters/zstdlog"
|
"github.com/dcarbone/zadapters/zstdlog"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
|
@ -148,9 +148,17 @@ func (s *service) delete(ctx context.Context, id int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.stopTorznabJob(f.Indexer); err != nil {
|
switch f.Type {
|
||||||
s.log.Error().Err(err).Msg("error stopping torznab job")
|
case string(domain.FeedTypeTorznab):
|
||||||
return err
|
if err := s.stopTorznabJob(f.Indexer); err != nil {
|
||||||
|
s.log.Error().Err(err).Msg("error stopping torznab job")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case string(domain.FeedTypeRSS):
|
||||||
|
if err := s.stopRSSJob(f.Indexer); err != nil {
|
||||||
|
s.log.Error().Err(err).Msg("error stopping rss job")
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.repo.Delete(ctx, id); err != nil {
|
if err := s.repo.Delete(ctx, id); err != nil {
|
||||||
|
@ -169,21 +177,29 @@ func (s *service) delete(ctx context.Context, id int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) toggleEnabled(ctx context.Context, id int, enabled bool) error {
|
func (s *service) toggleEnabled(ctx context.Context, id int, enabled bool) error {
|
||||||
if err := s.repo.ToggleEnabled(ctx, id, enabled); err != nil {
|
|
||||||
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error toggle enabled")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := s.repo.FindByID(ctx, id)
|
f, err := s.repo.FindByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error finding feed")
|
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error finding feed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !enabled {
|
if err := s.repo.ToggleEnabled(ctx, id, enabled); err != nil {
|
||||||
if err := s.stopTorznabJob(f.Indexer); err != nil {
|
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error toggle enabled")
|
||||||
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error stopping torznab job")
|
return err
|
||||||
return err
|
}
|
||||||
|
|
||||||
|
if f.Enabled && !enabled {
|
||||||
|
switch f.Type {
|
||||||
|
case string(domain.FeedTypeTorznab):
|
||||||
|
if err := s.stopTorznabJob(f.Indexer); err != nil {
|
||||||
|
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error stopping torznab job")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case string(domain.FeedTypeRSS):
|
||||||
|
if err := s.stopRSSJob(f.Indexer); err != nil {
|
||||||
|
s.log.Error().Err(err).Msg("feed.ToggleEnabled: error stopping rss job")
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.log.Debug().Msgf("feed.ToggleEnabled: stopping feed: %v", f.Name)
|
s.log.Debug().Msgf("feed.ToggleEnabled: stopping feed: %v", f.Name)
|
||||||
|
@ -205,17 +221,20 @@ func (s *service) Test(ctx context.Context, feed *domain.Feed) error {
|
||||||
|
|
||||||
subLogger := zstdlog.NewStdLoggerWithLevel(s.log.With().Logger(), zerolog.DebugLevel)
|
subLogger := zstdlog.NewStdLoggerWithLevel(s.log.With().Logger(), zerolog.DebugLevel)
|
||||||
|
|
||||||
// setup torznab Client
|
// implementation == TORZNAB
|
||||||
c := torznab.NewClient(torznab.Config{Host: feed.URL, ApiKey: feed.ApiKey, Log: subLogger})
|
if feed.Type == string(domain.FeedTypeTorznab) {
|
||||||
caps, err := c.GetCaps()
|
// setup torznab Client
|
||||||
if err != nil {
|
c := torznab.NewClient(torznab.Config{Host: feed.URL, ApiKey: feed.ApiKey, Log: subLogger})
|
||||||
s.log.Error().Err(err).Msg("error testing feed")
|
caps, err := c.GetCaps()
|
||||||
return err
|
if err != nil {
|
||||||
}
|
s.log.Error().Err(err).Msg("error testing feed")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if caps == nil {
|
if caps == nil {
|
||||||
s.log.Error().Msg("could not test feed and get caps")
|
s.log.Error().Msg("could not test feed and get caps")
|
||||||
return errors.New("could not test feed and get caps")
|
return errors.New("could not test feed and get caps")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.log.Debug().Msgf("test successful - connected to feed: %+v", feed.URL)
|
s.log.Debug().Msgf("test successful - connected to feed: %+v", feed.URL)
|
||||||
|
@ -286,11 +305,14 @@ func (s *service) startJob(f domain.Feed) error {
|
||||||
switch fi.Implementation {
|
switch fi.Implementation {
|
||||||
case string(domain.FeedTypeTorznab):
|
case string(domain.FeedTypeTorznab):
|
||||||
if err := s.addTorznabJob(fi); err != nil {
|
if err := s.addTorznabJob(fi); err != nil {
|
||||||
s.log.Error().Err(err).Msg("feed.startJob: failed to initialize feed")
|
s.log.Error().Err(err).Msg("feed.startJob: failed to initialize torznab feed")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case string(domain.FeedTypeRSS):
|
||||||
|
if err := s.addRSSJob(fi); err != nil {
|
||||||
|
s.log.Error().Err(err).Msg("feed.startJob: failed to initialize rss feed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//case "rss":
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -300,7 +322,7 @@ func (s *service) addTorznabJob(f feedInstance) error {
|
||||||
if f.URL == "" {
|
if f.URL == "" {
|
||||||
return errors.New("torznab feed requires URL")
|
return errors.New("torznab feed requires URL")
|
||||||
}
|
}
|
||||||
if f.CronSchedule < time.Duration(5 * time.Minute) {
|
if f.CronSchedule < time.Duration(5*time.Minute) {
|
||||||
f.CronSchedule = time.Duration(15 * time.Minute)
|
f.CronSchedule = time.Duration(15 * time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,3 +360,43 @@ func (s *service) stopTorznabJob(indexer string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *service) addRSSJob(f feedInstance) error {
|
||||||
|
if f.URL == "" {
|
||||||
|
return errors.New("rss feed requires URL")
|
||||||
|
}
|
||||||
|
if f.CronSchedule < time.Duration(5*time.Minute) {
|
||||||
|
f.CronSchedule = time.Duration(15 * time.Minute)
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup logger
|
||||||
|
l := s.log.With().Str("feed", f.Name).Logger()
|
||||||
|
|
||||||
|
// create job
|
||||||
|
job := NewRSSJob(f.Name, f.IndexerIdentifier, l, f.URL, s.cacheRepo, s.releaseSvc)
|
||||||
|
|
||||||
|
// schedule job
|
||||||
|
id, err := s.scheduler.AddJob(job, f.CronSchedule, f.IndexerIdentifier)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "feed.AddRSSJob: add job failed")
|
||||||
|
}
|
||||||
|
job.JobID = id
|
||||||
|
|
||||||
|
// add to job map
|
||||||
|
s.jobs[f.IndexerIdentifier] = id
|
||||||
|
|
||||||
|
s.log.Debug().Msgf("feed.AddRSSJob: %v", f.Name)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) stopRSSJob(indexer string) error {
|
||||||
|
// remove job from scheduler
|
||||||
|
if err := s.scheduler.RemoveJobByIdentifier(indexer); err != nil {
|
||||||
|
return errors.Wrap(err, "feed.stopRSSJob: stop job failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
s.log.Debug().Msgf("feed.stopRSSJob: %v", indexer)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ func (j *TorznabJob) process() error {
|
||||||
rls.TorrentName = item.Title
|
rls.TorrentName = item.Title
|
||||||
rls.TorrentURL = item.Link
|
rls.TorrentURL = item.Link
|
||||||
rls.Implementation = domain.ReleaseImplementationTorznab
|
rls.Implementation = domain.ReleaseImplementationTorznab
|
||||||
rls.Indexer = j.IndexerIdentifier
|
|
||||||
|
|
||||||
// parse size bytes string
|
// parse size bytes string
|
||||||
rls.ParseSizeBytesString(item.Size)
|
rls.ParseSizeBytesString(item.Size)
|
||||||
|
|
22
internal/indexer/definitions/rss_generic.yaml
Normal file
22
internal/indexer/definitions/rss_generic.yaml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
#id: rss
|
||||||
|
name: Generic RSS
|
||||||
|
identifier: rss
|
||||||
|
description: Generic RSS
|
||||||
|
language: en-us
|
||||||
|
urls:
|
||||||
|
- https://domain.com
|
||||||
|
privacy: private
|
||||||
|
protocol: torrent
|
||||||
|
implementation: rss
|
||||||
|
supports:
|
||||||
|
- rss
|
||||||
|
source: rss
|
||||||
|
|
||||||
|
rss:
|
||||||
|
minInterval: 15
|
||||||
|
settings:
|
||||||
|
- name: url
|
||||||
|
type: text
|
||||||
|
required: true
|
||||||
|
label: RSS URL
|
|
@ -49,6 +49,8 @@ type service struct {
|
||||||
lookupIRCServerDefinition map[string]map[string]*domain.IndexerDefinition
|
lookupIRCServerDefinition map[string]map[string]*domain.IndexerDefinition
|
||||||
// torznab indexers
|
// torznab indexers
|
||||||
torznabIndexers map[string]*domain.IndexerDefinition
|
torznabIndexers map[string]*domain.IndexerDefinition
|
||||||
|
// rss indexers
|
||||||
|
rssIndexers map[string]*domain.IndexerDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(log logger.Logger, config *domain.Config, repo domain.IndexerRepo, apiService APIService, scheduler scheduler.Service) Service {
|
func NewService(log logger.Logger, config *domain.Config, repo domain.IndexerRepo, apiService APIService, scheduler scheduler.Service) Service {
|
||||||
|
@ -60,6 +62,7 @@ func NewService(log logger.Logger, config *domain.Config, repo domain.IndexerRep
|
||||||
scheduler: scheduler,
|
scheduler: scheduler,
|
||||||
lookupIRCServerDefinition: make(map[string]map[string]*domain.IndexerDefinition),
|
lookupIRCServerDefinition: make(map[string]map[string]*domain.IndexerDefinition),
|
||||||
torznabIndexers: make(map[string]*domain.IndexerDefinition),
|
torznabIndexers: make(map[string]*domain.IndexerDefinition),
|
||||||
|
rssIndexers: make(map[string]*domain.IndexerDefinition),
|
||||||
definitions: make(map[string]domain.IndexerDefinition),
|
definitions: make(map[string]domain.IndexerDefinition),
|
||||||
mappedDefinitions: make(map[string]*domain.IndexerDefinition),
|
mappedDefinitions: make(map[string]*domain.IndexerDefinition),
|
||||||
}
|
}
|
||||||
|
@ -67,11 +70,17 @@ func NewService(log logger.Logger, config *domain.Config, repo domain.IndexerRep
|
||||||
|
|
||||||
func (s *service) Store(ctx context.Context, indexer domain.Indexer) (*domain.Indexer, error) {
|
func (s *service) Store(ctx context.Context, indexer domain.Indexer) (*domain.Indexer, error) {
|
||||||
identifier := indexer.Identifier
|
identifier := indexer.Identifier
|
||||||
//if indexer.Identifier == "torznab" {
|
|
||||||
if indexer.Implementation == "torznab" {
|
switch indexer.Implementation {
|
||||||
|
case "torznab":
|
||||||
// if the name already contains torznab remove it
|
// if the name already contains torznab remove it
|
||||||
cleanName := strings.ReplaceAll(strings.ToLower(indexer.Name), "torznab", "")
|
cleanName := strings.ReplaceAll(strings.ToLower(indexer.Name), "torznab", "")
|
||||||
identifier = slug.Make(fmt.Sprintf("%v-%v", indexer.Implementation, cleanName)) // torznab-name
|
identifier = slug.Make(fmt.Sprintf("%v-%v", indexer.Implementation, cleanName)) // torznab-name
|
||||||
|
|
||||||
|
case "rss":
|
||||||
|
// if the name already contains rss remove it
|
||||||
|
cleanName := strings.ReplaceAll(strings.ToLower(indexer.Name), "rss", "")
|
||||||
|
identifier = slug.Make(fmt.Sprintf("%v-%v", indexer.Implementation, cleanName)) // rss-name
|
||||||
}
|
}
|
||||||
|
|
||||||
indexer.Identifier = identifier
|
indexer.Identifier = identifier
|
||||||
|
@ -106,7 +115,7 @@ func (s *service) Update(ctx context.Context, indexer domain.Indexer) (*domain.I
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if indexer.Implementation == "torznab" {
|
if indexer.Implementation == "torznab" || indexer.Implementation == "rss" {
|
||||||
if !indexer.Enabled {
|
if !indexer.Enabled {
|
||||||
s.stopFeed(indexer.Identifier)
|
s.stopFeed(indexer.Identifier)
|
||||||
}
|
}
|
||||||
|
@ -210,6 +219,8 @@ func (s *service) mapIndexer(indexer domain.Indexer) (*domain.IndexerDefinition,
|
||||||
definitionName := indexer.Identifier
|
definitionName := indexer.Identifier
|
||||||
if indexer.Implementation == "torznab" {
|
if indexer.Implementation == "torznab" {
|
||||||
definitionName = "torznab"
|
definitionName = "torznab"
|
||||||
|
} else if indexer.Implementation == "rss" {
|
||||||
|
definitionName = "rss"
|
||||||
}
|
}
|
||||||
|
|
||||||
d := s.getDefinitionByName(definitionName)
|
d := s.getDefinitionByName(definitionName)
|
||||||
|
@ -331,6 +342,8 @@ func (s *service) Start() error {
|
||||||
// handle Torznab
|
// handle Torznab
|
||||||
if indexer.Implementation == "torznab" {
|
if indexer.Implementation == "torznab" {
|
||||||
s.torznabIndexers[indexer.Identifier] = indexer
|
s.torznabIndexers[indexer.Identifier] = indexer
|
||||||
|
} else if indexer.Implementation == "rss" {
|
||||||
|
s.rssIndexers[indexer.Identifier] = indexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +356,8 @@ func (s *service) removeIndexer(indexer domain.Indexer) {
|
||||||
// remove Torznab
|
// remove Torznab
|
||||||
if indexer.Implementation == "torznab" {
|
if indexer.Implementation == "torznab" {
|
||||||
delete(s.torznabIndexers, indexer.Identifier)
|
delete(s.torznabIndexers, indexer.Identifier)
|
||||||
|
} else if indexer.Implementation == "rss" {
|
||||||
|
delete(s.rssIndexers, indexer.Identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove mapped definition
|
// remove mapped definition
|
||||||
|
@ -373,9 +388,11 @@ func (s *service) addIndexer(indexer domain.Indexer) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle Torznab
|
// handle Torznab and RSS
|
||||||
if indexerDefinition.Implementation == "torznab" {
|
if indexerDefinition.Implementation == "torznab" {
|
||||||
s.torznabIndexers[indexer.Identifier] = indexerDefinition
|
s.torznabIndexers[indexer.Identifier] = indexerDefinition
|
||||||
|
} else if indexerDefinition.Implementation == "rss" {
|
||||||
|
s.rssIndexers[indexer.Identifier] = indexerDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mappedDefinitions[indexer.Identifier] = indexerDefinition
|
s.mappedDefinitions[indexer.Identifier] = indexerDefinition
|
||||||
|
@ -408,6 +425,8 @@ func (s *service) updateIndexer(indexer domain.Indexer) error {
|
||||||
// handle Torznab
|
// handle Torznab
|
||||||
if indexerDefinition.Implementation == "torznab" {
|
if indexerDefinition.Implementation == "torznab" {
|
||||||
s.torznabIndexers[indexer.Identifier] = indexerDefinition
|
s.torznabIndexers[indexer.Identifier] = indexerDefinition
|
||||||
|
} else if indexerDefinition.Implementation == "rss" {
|
||||||
|
s.rssIndexers[indexer.Identifier] = indexerDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mappedDefinitions[indexer.Identifier] = indexerDefinition
|
s.mappedDefinitions[indexer.Identifier] = indexerDefinition
|
||||||
|
@ -570,6 +589,18 @@ func (s *service) GetTorznabIndexers() []domain.IndexerDefinition {
|
||||||
return indexerDefinitions
|
return indexerDefinitions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *service) GetRSSIndexers() []domain.IndexerDefinition {
|
||||||
|
indexerDefinitions := make([]domain.IndexerDefinition, 0)
|
||||||
|
|
||||||
|
for _, definition := range s.rssIndexers {
|
||||||
|
if definition != nil {
|
||||||
|
indexerDefinitions = append(indexerDefinitions, *definition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return indexerDefinitions
|
||||||
|
}
|
||||||
|
|
||||||
func (s *service) getDefinitionByName(name string) *domain.IndexerDefinition {
|
func (s *service) getDefinitionByName(name string) *domain.IndexerDefinition {
|
||||||
if v, ok := s.definitions[name]; ok {
|
if v, ok := s.definitions[name]; ok {
|
||||||
return &v
|
return &v
|
||||||
|
@ -582,6 +613,10 @@ func (s *service) stopFeed(indexer string) {
|
||||||
// verify indexer is torznab indexer
|
// verify indexer is torznab indexer
|
||||||
_, ok := s.torznabIndexers[indexer]
|
_, ok := s.torznabIndexers[indexer]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
_, rssOK := s.rssIndexers[indexer]
|
||||||
|
if !rssOK {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package scheduler
|
package scheduler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/autobrr/autobrr/internal/logger"
|
"github.com/autobrr/autobrr/internal/logger"
|
||||||
|
@ -14,7 +15,6 @@ type Service interface {
|
||||||
Start()
|
Start()
|
||||||
Stop()
|
Stop()
|
||||||
AddJob(job cron.Job, interval time.Duration, identifier string) (int, error)
|
AddJob(job cron.Job, interval time.Duration, identifier string) (int, error)
|
||||||
RemoveJobByID(id cron.EntryID) error
|
|
||||||
RemoveJobByIdentifier(id string) error
|
RemoveJobByIdentifier(id string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ type service struct {
|
||||||
|
|
||||||
cron *cron.Cron
|
cron *cron.Cron
|
||||||
jobs map[string]cron.EntryID
|
jobs map[string]cron.EntryID
|
||||||
|
m sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(log logger.Logger, version string, notificationSvc notification.Service) Service {
|
func NewService(log logger.Logger, version string, notificationSvc notification.Service) Service {
|
||||||
|
@ -62,7 +63,9 @@ func (s *service) addAppJobs() {
|
||||||
lastCheckVersion: "",
|
lastCheckVersion: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
s.AddJob(checkUpdates, time.Duration(36 * time.Hour), "app-check-updates")
|
if id, err := s.AddJob(checkUpdates, time.Duration(36*time.Hour), "app-check-updates"); err != nil {
|
||||||
|
s.log.Error().Err(err).Msgf("scheduler.addAppJobs: error adding job: %v", id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Stop() {
|
func (s *service) Stop() {
|
||||||
|
@ -79,23 +82,18 @@ func (s *service) AddJob(job cron.Job, interval time.Duration, identifier string
|
||||||
|
|
||||||
s.log.Debug().Msgf("scheduler.AddJob: job successfully added: %v", id)
|
s.log.Debug().Msgf("scheduler.AddJob: job successfully added: %v", id)
|
||||||
|
|
||||||
|
s.m.Lock()
|
||||||
// add to job map
|
// add to job map
|
||||||
s.jobs[identifier] = id
|
s.jobs[identifier] = id
|
||||||
|
s.m.Unlock()
|
||||||
|
|
||||||
return int(id), nil
|
return int(id), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) RemoveJobByID(id cron.EntryID) error {
|
|
||||||
v, ok := s.jobs[""]
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
s.cron.Remove(v)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) RemoveJobByIdentifier(id string) error {
|
func (s *service) RemoveJobByIdentifier(id string) error {
|
||||||
|
s.m.Lock()
|
||||||
|
defer s.m.Unlock()
|
||||||
|
|
||||||
v, ok := s.jobs[id]
|
v, ok := s.jobs[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -5,10 +5,10 @@ import { toast } from "react-hot-toast";
|
||||||
import Toast from "../../components/notifications/Toast";
|
import Toast from "../../components/notifications/Toast";
|
||||||
import { SlideOver } from "../../components/panels";
|
import { SlideOver } from "../../components/panels";
|
||||||
import { NumberFieldWide, PasswordFieldWide, SwitchGroupWide, TextFieldWide } from "../../components/inputs";
|
import { NumberFieldWide, PasswordFieldWide, SwitchGroupWide, TextFieldWide } from "../../components/inputs";
|
||||||
import { ImplementationMap } from "../../screens/settings/Feed";
|
|
||||||
import { componentMapType } from "./DownloadClientForms";
|
import { componentMapType } from "./DownloadClientForms";
|
||||||
import { sleep } from "../../utils";
|
import { sleep } from "../../utils";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { ImplementationBadges } from "../../screens/settings/Indexer";
|
||||||
|
|
||||||
interface UpdateProps {
|
interface UpdateProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
@ -126,11 +126,11 @@ export function FeedUpdateForm({ isOpen, toggle, feed }: UpdateProps) {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end sm:col-span-2">
|
<div className="flex justify-end sm:col-span-2">
|
||||||
{ImplementationMap[feed.type]}
|
{ImplementationBadges[feed.type.toLowerCase()]}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="py-6 px-6 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-gray-200">
|
<div className="py-6 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-gray-200">
|
||||||
<SwitchGroupWide name="enabled" label="Enabled"/>
|
<SwitchGroupWide name="enabled" label="Enabled"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -158,6 +158,21 @@ function FormFieldsTorznab() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FormFieldsRSS() {
|
||||||
|
return (
|
||||||
|
<div className="border-t border-gray-200 dark:border-gray-700 py-5">
|
||||||
|
<TextFieldWide
|
||||||
|
name="url"
|
||||||
|
label="URL"
|
||||||
|
help="RSS url"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<NumberFieldWide name="interval" label="Refresh interval" help="Minutes. Recommended 15-30. To low and risk ban."/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const componentMap: componentMapType = {
|
const componentMap: componentMapType = {
|
||||||
TORZNAB: <FormFieldsTorznab/>
|
TORZNAB: <FormFieldsTorznab/>,
|
||||||
|
RSS: <FormFieldsRSS />
|
||||||
};
|
};
|
|
@ -119,6 +119,37 @@ const FeedSettingFields = (ind: IndexerDefinition, indexer: string) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const RSSFeedSettingFields = (ind: IndexerDefinition, indexer: string) => {
|
||||||
|
if (indexer !== "") {
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
{ind && ind.rss && ind.rss.settings && (
|
||||||
|
<div className="">
|
||||||
|
<div className="px-4 space-y-1">
|
||||||
|
<Dialog.Title className="text-lg font-medium text-gray-900 dark:text-white">RSS</Dialog.Title>
|
||||||
|
<p className="text-sm text-gray-500 dark:text-gray-200">
|
||||||
|
RSS feed
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TextFieldWide name="name" label="Name" defaultValue={""} />
|
||||||
|
|
||||||
|
{ind.rss.settings.map((f: IndexerSetting, idx: number) => {
|
||||||
|
switch (f.type) {
|
||||||
|
case "text":
|
||||||
|
return <TextFieldWide name={`feed.${f.name}`} label={f.label} required={f.required} key={idx} help={f.help} />;
|
||||||
|
case "secret":
|
||||||
|
return <PasswordFieldWide name={`feed.${f.name}`} label={f.label} required={f.required} key={idx} help={f.help} defaultValue={f.default} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const SettingFields = (ind: IndexerDefinition, indexer: string) => {
|
const SettingFields = (ind: IndexerDefinition, indexer: string) => {
|
||||||
if (indexer !== "") {
|
if (indexer !== "") {
|
||||||
return (
|
return (
|
||||||
|
@ -144,10 +175,13 @@ const SettingFields = (ind: IndexerDefinition, indexer: string) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function slugIdentifier(name: string) {
|
function slugIdentifier(name: string, prefix?: string) {
|
||||||
const l = name.toLowerCase();
|
const l = name.toLowerCase();
|
||||||
const r = l.replaceAll("torznab", "");
|
if (prefix && prefix !== "") {
|
||||||
return slugify(`torznab-${r}`);
|
const r = l.replaceAll(prefix, "");
|
||||||
|
return slugify(`${prefix}-${r}`);
|
||||||
|
}
|
||||||
|
return slugify(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface initialValues {
|
// interface initialValues {
|
||||||
|
@ -210,7 +244,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
||||||
|
|
||||||
if (formData.implementation === "torznab") {
|
if (formData.implementation === "torznab") {
|
||||||
// create slug for indexer identifier as "torznab-indexer_name"
|
// create slug for indexer identifier as "torznab-indexer_name"
|
||||||
const name = slugIdentifier(formData.name);
|
const name = slugIdentifier(formData.name, "torznab");
|
||||||
|
|
||||||
const createFeed: FeedCreate = {
|
const createFeed: FeedCreate = {
|
||||||
name: formData.name,
|
name: formData.name,
|
||||||
|
@ -234,6 +268,31 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (formData.implementation === "rss") {
|
||||||
|
// create slug for indexer identifier as "torznab-indexer_name"
|
||||||
|
const name = slugIdentifier(formData.name, "rss");
|
||||||
|
|
||||||
|
const createFeed: FeedCreate = {
|
||||||
|
name: formData.name,
|
||||||
|
enabled: false,
|
||||||
|
type: "RSS",
|
||||||
|
url: formData.feed.url,
|
||||||
|
interval: 30,
|
||||||
|
indexer: name,
|
||||||
|
indexer_id: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
mutation.mutate(formData as Indexer, {
|
||||||
|
onSuccess: (indexer) => {
|
||||||
|
// @eslint-ignore
|
||||||
|
createFeed.indexer_id = indexer.id;
|
||||||
|
|
||||||
|
feedMutation.mutate(createFeed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (formData.implementation === "irc") {
|
if (formData.implementation === "irc") {
|
||||||
|
|
||||||
const channels: IrcChannel[] = [];
|
const channels: IrcChannel[] = [];
|
||||||
|
@ -399,6 +458,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
||||||
|
|
||||||
{IrcSettingFields(indexer, values.identifier)}
|
{IrcSettingFields(indexer, values.identifier)}
|
||||||
{FeedSettingFields(indexer, values.identifier)}
|
{FeedSettingFields(indexer, values.identifier)}
|
||||||
|
{RSSFeedSettingFields(indexer, values.identifier)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
} from "@heroicons/react/outline";
|
} from "@heroicons/react/outline";
|
||||||
import { FeedUpdateForm } from "../../forms/settings/FeedForms";
|
import { FeedUpdateForm } from "../../forms/settings/FeedForms";
|
||||||
import { EmptySimple } from "../../components/emptystates";
|
import { EmptySimple } from "../../components/emptystates";
|
||||||
import { componentMapType } from "../../forms/settings/DownloadClientForms";
|
import { ImplementationBadges } from "./Indexer";
|
||||||
|
|
||||||
function FeedSettings() {
|
function FeedSettings() {
|
||||||
const { data } = useQuery(
|
const { data } = useQuery(
|
||||||
|
@ -46,10 +46,13 @@ function FeedSettings() {
|
||||||
className="col-span-2 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Enabled
|
className="col-span-2 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Enabled
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="col-span-6 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Name
|
className="col-span-4 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Name
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="col-span-2 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Type
|
className="col-span-3 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Indexer
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="col-span-3 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Type
|
||||||
</div>
|
</div>
|
||||||
{/*<div className="col-span-4 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Events</div>*/}
|
{/*<div className="col-span-4 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Events</div>*/}
|
||||||
</li>
|
</li>
|
||||||
|
@ -65,18 +68,6 @@ function FeedSettings() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImplementationTorznab = () => (
|
|
||||||
<span
|
|
||||||
className="inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-orange-200 dark:bg-orange-400 text-orange-800 dark:text-orange-800"
|
|
||||||
>
|
|
||||||
Torznab
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ImplementationMap: componentMapType = {
|
|
||||||
"TORZNAB": <ImplementationTorznab/>
|
|
||||||
};
|
|
||||||
|
|
||||||
interface ListItemProps {
|
interface ListItemProps {
|
||||||
feed: Feed;
|
feed: Feed;
|
||||||
}
|
}
|
||||||
|
@ -129,13 +120,16 @@ function ListItem({ feed }: ListItemProps) {
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-6 flex items-center sm:px-6 text-sm font-medium text-gray-900 dark:text-white">
|
<div className="col-span-4 flex items-center sm:px-6 text-sm font-medium text-gray-900 dark:text-white">
|
||||||
{feed.name}
|
{feed.name}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-2 flex items-center sm:px-6">
|
<div className="col-span-3 flex items-center sm:px-6 text-sm font-medium text-gray-900 dark:text-gray-500">
|
||||||
{ImplementationMap[feed.type]}
|
{feed.indexer}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-1 flex items-center sm:px-6">
|
<div className="col-span-2 flex items-center sm:px-6">
|
||||||
|
{ImplementationBadges[feed.type.toLowerCase()]}
|
||||||
|
</div>
|
||||||
|
<div className="col-span-1 flex justify-center items-center sm:px-6">
|
||||||
<FeedItemDropdown
|
<FeedItemDropdown
|
||||||
feed={feed}
|
feed={feed}
|
||||||
onToggle={toggleActive}
|
onToggle={toggleActive}
|
||||||
|
@ -223,7 +217,7 @@ const FeedItemDropdown = ({
|
||||||
)}
|
)}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
@ -243,7 +237,7 @@ const FeedItemDropdown = ({
|
||||||
)}
|
)}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
Toggle
|
Toggle
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
@ -265,7 +259,7 @@ const FeedItemDropdown = ({
|
||||||
)}
|
)}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { EmptySimple } from "../../components/emptystates";
|
||||||
import { APIClient } from "../../api/APIClient";
|
import { APIClient } from "../../api/APIClient";
|
||||||
import { componentMapType } from "../../forms/settings/DownloadClientForms";
|
import { componentMapType } from "../../forms/settings/DownloadClientForms";
|
||||||
|
|
||||||
const ImplementationIRC = () => (
|
const ImplementationBadgeIRC = () => (
|
||||||
<span
|
<span
|
||||||
className="mr-2 inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-green-200 dark:bg-green-400 text-green-800 dark:text-green-800"
|
className="mr-2 inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-green-200 dark:bg-green-400 text-green-800 dark:text-green-800"
|
||||||
>
|
>
|
||||||
|
@ -15,17 +15,26 @@ const ImplementationIRC = () => (
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
const ImplementationTorznab = () => (
|
const ImplementationBadgeTorznab = () => (
|
||||||
<span
|
<span
|
||||||
className="inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-orange-200 dark:bg-orange-400 text-orange-800 dark:text-orange-800"
|
className="inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-orange-200 dark:bg-orange-400 text-orange-800 dark:text-orange-800"
|
||||||
>
|
>
|
||||||
Torznab
|
Torznab
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
const implementationMap: componentMapType = {
|
const ImplementationBadgeRSS = () => (
|
||||||
"irc": <ImplementationIRC/>,
|
<span
|
||||||
"torznab": <ImplementationTorznab />
|
className="inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-amber-200 dark:bg-amber-400 text-amber-800 dark:text-amber-800"
|
||||||
|
>
|
||||||
|
RSS
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ImplementationBadges: componentMapType = {
|
||||||
|
"irc": <ImplementationBadgeIRC/>,
|
||||||
|
"torznab": <ImplementationBadgeTorznab />,
|
||||||
|
"rss": <ImplementationBadgeRSS />
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ListItemProps {
|
interface ListItemProps {
|
||||||
|
@ -59,10 +68,10 @@ const ListItem = ({ indexer }: ListItemProps) => {
|
||||||
</Switch>
|
</Switch>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 w-full whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">{indexer.name}</td>
|
<td className="px-6 py-4 w-full whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">{indexer.name}</td>
|
||||||
<td className="px-6 py-4 w-full whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">{implementationMap[indexer.implementation]}</td>
|
<td className="px-6 py-4 w-full whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">{ImplementationBadges[indexer.implementation]}</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||||
<span className="text-indigo-600 dark:text-gray-300 hover:text-indigo-900 dark:hover:text-blue-500 cursor-pointer" onClick={toggleUpdate}>
|
<span className="text-indigo-600 dark:text-gray-300 hover:text-indigo-900 dark:hover:text-blue-500 cursor-pointer" onClick={toggleUpdate}>
|
||||||
Edit
|
Edit
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -100,7 +109,7 @@ function IndexerSettings() {
|
||||||
onClick={toggleAddIndexer}
|
onClick={toggleAddIndexer}
|
||||||
className="relative inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 dark:bg-blue-600 hover:bg-indigo-700 dark:hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-blue-500"
|
className="relative inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 dark:bg-blue-600 hover:bg-indigo-700 dark:hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-blue-500"
|
||||||
>
|
>
|
||||||
Add new
|
Add new
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -117,19 +126,19 @@ function IndexerSettings() {
|
||||||
scope="col"
|
scope="col"
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
||||||
>
|
>
|
||||||
Enabled
|
Enabled
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
scope="col"
|
scope="col"
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
||||||
>
|
>
|
||||||
Name
|
Name
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
scope="col"
|
scope="col"
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider"
|
||||||
>
|
>
|
||||||
Implementation
|
Implementation
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="relative px-6 py-3">
|
<th scope="col" className="relative px-6 py-3">
|
||||||
<span className="sr-only">Edit</span>
|
<span className="sr-only">Edit</span>
|
||||||
|
|
8
web/src/types/Feed.d.ts
vendored
8
web/src/types/Feed.d.ts
vendored
|
@ -2,7 +2,7 @@ interface Feed {
|
||||||
id: number;
|
id: number;
|
||||||
indexer: string;
|
indexer: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: FeedType;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
url: string;
|
url: string;
|
||||||
interval: number;
|
interval: number;
|
||||||
|
@ -11,13 +11,15 @@ interface Feed {
|
||||||
updated_at: Date;
|
updated_at: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FeedType = "TORZNAB" | "RSS";
|
||||||
|
|
||||||
interface FeedCreate {
|
interface FeedCreate {
|
||||||
indexer: string;
|
indexer: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: FeedType;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
url: string;
|
url: string;
|
||||||
interval: number;
|
interval: number;
|
||||||
api_key: string;
|
api_key?: string;
|
||||||
indexer_id: number;
|
indexer_id: number;
|
||||||
}
|
}
|
||||||
|
|
6
web/src/types/Indexer.d.ts
vendored
6
web/src/types/Indexer.d.ts
vendored
|
@ -22,6 +22,7 @@ interface IndexerDefinition {
|
||||||
settings: IndexerSetting[];
|
settings: IndexerSetting[];
|
||||||
irc: IndexerIRC;
|
irc: IndexerIRC;
|
||||||
torznab: IndexerTorznab;
|
torznab: IndexerTorznab;
|
||||||
|
rss: IndexerFeed;
|
||||||
parse: IndexerParse;
|
parse: IndexerParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +54,11 @@ interface IndexerTorznab {
|
||||||
settings: IndexerSetting[];
|
settings: IndexerSetting[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IndexerFeed {
|
||||||
|
minInterval: number;
|
||||||
|
settings: IndexerSetting[];
|
||||||
|
}
|
||||||
|
|
||||||
interface IndexerParse {
|
interface IndexerParse {
|
||||||
type: string;
|
type: string;
|
||||||
lines: IndexerParseLines[];
|
lines: IndexerParseLines[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue