mirror of
https://github.com/idanoo/autobrr
synced 2025-07-25 01: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
|
@ -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) => {
|
||||
if (indexer !== "") {
|
||||
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 r = l.replaceAll("torznab", "");
|
||||
return slugify(`torznab-${r}`);
|
||||
if (prefix && prefix !== "") {
|
||||
const r = l.replaceAll(prefix, "");
|
||||
return slugify(`${prefix}-${r}`);
|
||||
}
|
||||
return slugify(l);
|
||||
}
|
||||
|
||||
// interface initialValues {
|
||||
|
@ -210,7 +244,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
|||
|
||||
if (formData.implementation === "torznab") {
|
||||
// create slug for indexer identifier as "torznab-indexer_name"
|
||||
const name = slugIdentifier(formData.name);
|
||||
const name = slugIdentifier(formData.name, "torznab");
|
||||
|
||||
const createFeed: FeedCreate = {
|
||||
name: formData.name,
|
||||
|
@ -234,6 +268,31 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
|||
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") {
|
||||
|
||||
const channels: IrcChannel[] = [];
|
||||
|
@ -399,6 +458,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
|
|||
|
||||
{IrcSettingFields(indexer, values.identifier)}
|
||||
{FeedSettingFields(indexer, values.identifier)}
|
||||
{RSSFeedSettingFields(indexer, values.identifier)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue