mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-17 21:26:22 -04:00
New: Release type options for Calendar Feed
This commit is contained in:
@@ -4,6 +4,7 @@ import FormGroup from 'Components/Form/FormGroup';
|
|||||||
import FormInputButton from 'Components/Form/FormInputButton';
|
import FormInputButton from 'Components/Form/FormInputButton';
|
||||||
import FormInputGroup from 'Components/Form/FormInputGroup';
|
import FormInputGroup from 'Components/Form/FormInputGroup';
|
||||||
import FormLabel from 'Components/Form/FormLabel';
|
import FormLabel from 'Components/Form/FormLabel';
|
||||||
|
import { EnhancedSelectInputValue } from 'Components/Form/Select/EnhancedSelectInput';
|
||||||
import Icon from 'Components/Icon';
|
import Icon from 'Components/Icon';
|
||||||
import Button from 'Components/Link/Button';
|
import Button from 'Components/Link/Button';
|
||||||
import ClipboardButton from 'Components/Link/ClipboardButton';
|
import ClipboardButton from 'Components/Link/ClipboardButton';
|
||||||
@@ -15,6 +16,27 @@ import { icons, inputTypes, kinds, sizes } from 'Helpers/Props';
|
|||||||
import { InputChanged } from 'typings/inputs';
|
import { InputChanged } from 'typings/inputs';
|
||||||
import translate from 'Utilities/String/translate';
|
import translate from 'Utilities/String/translate';
|
||||||
|
|
||||||
|
const releaseTypeOptions: EnhancedSelectInputValue<string>[] = [
|
||||||
|
{
|
||||||
|
key: 'cinemaRelease',
|
||||||
|
get value() {
|
||||||
|
return translate('CinemaRelease');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'digitalRelease',
|
||||||
|
get value() {
|
||||||
|
return translate('DigitalRelease');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'physicalRelease',
|
||||||
|
get value() {
|
||||||
|
return translate('PhysicalRelease');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
interface CalendarLinkModalContentProps {
|
interface CalendarLinkModalContentProps {
|
||||||
onModalClose: () => void;
|
onModalClose: () => void;
|
||||||
}
|
}
|
||||||
@@ -22,13 +44,19 @@ interface CalendarLinkModalContentProps {
|
|||||||
function CalendarLinkModalContent({
|
function CalendarLinkModalContent({
|
||||||
onModalClose,
|
onModalClose,
|
||||||
}: CalendarLinkModalContentProps) {
|
}: CalendarLinkModalContentProps) {
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState<{
|
||||||
|
unmonitored: boolean;
|
||||||
|
asAllDay: boolean;
|
||||||
|
releaseTypes: string[];
|
||||||
|
tags: number[];
|
||||||
|
}>({
|
||||||
unmonitored: false,
|
unmonitored: false,
|
||||||
asAllDay: false,
|
asAllDay: false,
|
||||||
|
releaseTypes: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { unmonitored, asAllDay, tags } = state;
|
const { unmonitored, asAllDay, releaseTypes, tags } = state;
|
||||||
|
|
||||||
const handleInputChange = useCallback(({ name, value }: InputChanged) => {
|
const handleInputChange = useCallback(({ name, value }: InputChanged) => {
|
||||||
setState((prevState) => ({ ...prevState, [name]: value }));
|
setState((prevState) => ({ ...prevState, [name]: value }));
|
||||||
@@ -52,6 +80,12 @@ function CalendarLinkModalContent({
|
|||||||
icalUrl += 'asAllDay=true&';
|
icalUrl += 'asAllDay=true&';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (releaseTypes.length) {
|
||||||
|
releaseTypes.forEach((releaseType) => {
|
||||||
|
icalUrl += `releaseTypes=${releaseType}&`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (tags.length) {
|
if (tags.length) {
|
||||||
icalUrl += `tags=${tags.toString()}&`;
|
icalUrl += `tags=${tags.toString()}&`;
|
||||||
}
|
}
|
||||||
@@ -62,7 +96,7 @@ function CalendarLinkModalContent({
|
|||||||
iCalHttpUrl: `${window.location.protocol}//${icalUrl}`,
|
iCalHttpUrl: `${window.location.protocol}//${icalUrl}`,
|
||||||
iCalWebCalUrl: `webcal://${icalUrl}`,
|
iCalWebCalUrl: `webcal://${icalUrl}`,
|
||||||
};
|
};
|
||||||
}, [unmonitored, asAllDay, tags]);
|
}, [unmonitored, asAllDay, releaseTypes, tags]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalContent onModalClose={onModalClose}>
|
<ModalContent onModalClose={onModalClose}>
|
||||||
@@ -94,6 +128,19 @@ function CalendarLinkModalContent({
|
|||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>{translate('ICalReleaseTypes')}</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.SELECT}
|
||||||
|
name="releaseTypes"
|
||||||
|
value={releaseTypes}
|
||||||
|
values={releaseTypeOptions}
|
||||||
|
helpText={translate('ICalReleaseTypesMoviesHelpText')}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormLabel>{translate('Tags')}</FormLabel>
|
<FormLabel>{translate('Tags')}</FormLabel>
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@
|
|||||||
"ChownGroup": "chown Group",
|
"ChownGroup": "chown Group",
|
||||||
"ChownGroupHelpText": "Group name or gid. Use gid for remote file systems.",
|
"ChownGroupHelpText": "Group name or gid. Use gid for remote file systems.",
|
||||||
"ChownGroupHelpTextWarning": "This only works if the user running {appName} is the owner of the file. It's better to ensure the download client uses the same group as {appName}.",
|
"ChownGroupHelpTextWarning": "This only works if the user running {appName} is the owner of the file. It's better to ensure the download client uses the same group as {appName}.",
|
||||||
|
"CinemaRelease": "Cinema Release",
|
||||||
"CleanLibraryLevel": "Clean Library Level",
|
"CleanLibraryLevel": "Clean Library Level",
|
||||||
"Clear": "Clear",
|
"Clear": "Clear",
|
||||||
"ClearBlocklist": "Clear blocklist",
|
"ClearBlocklist": "Clear blocklist",
|
||||||
@@ -755,6 +756,8 @@
|
|||||||
"ICalFeedHelpText": "Copy this URL to your client(s) or click to subscribe if your browser supports webcal",
|
"ICalFeedHelpText": "Copy this URL to your client(s) or click to subscribe if your browser supports webcal",
|
||||||
"ICalIncludeUnmonitoredMoviesHelpText": "Include unmonitored movies in the iCal feed",
|
"ICalIncludeUnmonitoredMoviesHelpText": "Include unmonitored movies in the iCal feed",
|
||||||
"ICalLink": "iCal Link",
|
"ICalLink": "iCal Link",
|
||||||
|
"ICalReleaseTypes": "Release Types",
|
||||||
|
"ICalReleaseTypesMoviesHelpText": "Include only movies with specific release types in the iCal feed. If unspecified, all options are used.",
|
||||||
"ICalShowAsAllDayEvents": "Show as All-Day Events",
|
"ICalShowAsAllDayEvents": "Show as All-Day Events",
|
||||||
"ICalShowAsAllDayEventsHelpText": "Events will appear as all-day events in your calendar",
|
"ICalShowAsAllDayEventsHelpText": "Events will appear as all-day events in your calendar",
|
||||||
"ICalTagsMoviesHelpText": "Applies to movies with at least one matching tag",
|
"ICalTagsMoviesHelpText": "Applies to movies with at least one matching tag",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Radarr.Api.V3.Calendar
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Radarr.ics")]
|
[HttpGet("Radarr.ics")]
|
||||||
public IActionResult GetCalendarFeed(int pastDays = 7, int futureDays = 28, string tags = "", bool unmonitored = false)
|
public IActionResult GetCalendarFeed(int pastDays = 7, int futureDays = 28, string tags = "", bool unmonitored = false, IReadOnlyCollection<CalendarReleaseType> releaseTypes = null)
|
||||||
{
|
{
|
||||||
var start = DateTime.Today.AddDays(-pastDays);
|
var start = DateTime.Today.AddDays(-pastDays);
|
||||||
var end = DateTime.Today.AddDays(futureDays);
|
var end = DateTime.Today.AddDays(futureDays);
|
||||||
@@ -54,9 +54,20 @@ namespace Radarr.Api.V3.Calendar
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateEvent(calendar, movie.MovieMetadata, "cinematic");
|
if (releaseTypes is not { Count: not 0 } || releaseTypes.Contains(CalendarReleaseType.CinemaRelease))
|
||||||
CreateEvent(calendar, movie.MovieMetadata, "digital");
|
{
|
||||||
CreateEvent(calendar, movie.MovieMetadata, "physical");
|
CreateEvent(calendar, movie.MovieMetadata, "cinematic");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseTypes is not { Count: not 0 } || releaseTypes.Contains(CalendarReleaseType.DigitalRelease))
|
||||||
|
{
|
||||||
|
CreateEvent(calendar, movie.MovieMetadata, "digital");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseTypes is not { Count: not 0 } || releaseTypes.Contains(CalendarReleaseType.PhysicalRelease))
|
||||||
|
{
|
||||||
|
CreateEvent(calendar, movie.MovieMetadata, "physical");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var serializer = (IStringSerializer)new SerializerFactory().Build(calendar.GetType(), new SerializationContext());
|
var serializer = (IStringSerializer)new SerializerFactory().Build(calendar.GetType(), new SerializationContext());
|
||||||
@@ -98,9 +109,9 @@ namespace Radarr.Api.V3.Calendar
|
|||||||
occurrence.IsAllDay = true;
|
occurrence.IsAllDay = true;
|
||||||
|
|
||||||
occurrence.Description = movie.Overview;
|
occurrence.Description = movie.Overview;
|
||||||
occurrence.Categories = new List<string>() { movie.Studio };
|
occurrence.Categories = new List<string> { movie.Studio };
|
||||||
|
|
||||||
occurrence.Summary = $"{movie.Title} " + summaryText;
|
occurrence.Summary = $"{movie.Title} {summaryText}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/Radarr.Api.V3/Calendar/CalendarReleaseType.cs
Normal file
8
src/Radarr.Api.V3/Calendar/CalendarReleaseType.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Radarr.Api.V3.Calendar;
|
||||||
|
|
||||||
|
public enum CalendarReleaseType
|
||||||
|
{
|
||||||
|
CinemaRelease,
|
||||||
|
DigitalRelease,
|
||||||
|
PhysicalRelease
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user