Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface DVRSettings {
syncEnabled: boolean;
preventSearch: boolean;
tagRequests: boolean;
tagRequestsNoID: boolean;
overrideRule: number[];
}

Expand Down
223 changes: 149 additions & 74 deletions server/subscriber/MediaRequestSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,46 +303,84 @@ export class MediaRequestSubscriber

if (radarrSettings.tagRequests) {
const radarrTags = await radarr.getTags();
// old tags had space around the hyphen
let userTag = radarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + ' - ')
);
// new tags do not have spaces around the hyphen, since spaces are not allowed anymore
if (!userTag) {
userTag = radarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + '-')
// We do not want to append user ID to tag
if (radarrSettings.tagRequestsNoID) {
let userTag = radarrTags.find((v) =>
v.label.startsWith(
sanitizeDisplayName(
entity.requestedBy.displayName.toLowerCase()
)
)
);
}
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await radarr.createTag({
label:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag: sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await radarr.createTag({
label: sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
radarrServer:
radarrSettings.hostname + ':' + radarrSettings.port,
});
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
radarrServer: radarrSettings.hostname + ':' + radarrSettings.port,
});
// old tags had space around the hyphen
let userTag = radarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + ' - ')
);
// new tags do not have spaces around the hyphen, since spaces are not allowed anymore
if (!userTag) {
userTag = radarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + '-')
);
}
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await radarr.createTag({
label:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
radarrServer:
radarrSettings.hostname + ':' + radarrSettings.port,
});
}
}
}

Expand Down Expand Up @@ -628,46 +666,83 @@ export class MediaRequestSubscriber

if (sonarrSettings.tagRequests) {
const sonarrTags = await sonarr.getTags();
// old tags had space around the hyphen
let userTag = sonarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + ' - ')
);
// new tags do not have spaces around the hyphen, since spaces are not allowed anymore
if (!userTag) {
userTag = sonarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + '-')
if (sonarrSettings.tagRequestsNoID) {
let userTag = sonarrTags.find((v) =>
v.label.startsWith(
sanitizeDisplayName(
entity.requestedBy.displayName.toLowerCase()
)
)
);
}
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await sonarr.createTag({
label:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag: sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await sonarr.createTag({
label: sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
sonarrServer:
sonarrSettings.hostname + ':' + sonarrSettings.port,
});
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
sonarrServer: sonarrSettings.hostname + ':' + sonarrSettings.port,
});
// old tags had space around the hyphen
let userTag = sonarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + ' - ')
);
// new tags do not have spaces around the hyphen, since spaces are not allowed anymore
if (!userTag) {
userTag = sonarrTags.find((v) =>
v.label.startsWith(entity.requestedBy.id + '-')
);
}
if (!userTag) {
logger.info(`Requester has no active tag. Creating new`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
newTag:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
userTag = await sonarr.createTag({
label:
entity.requestedBy.id +
'-' +
sanitizeDisplayName(entity.requestedBy.displayName),
});
}
if (userTag.id) {
if (!tags?.find((v) => v === userTag?.id)) {
tags?.push(userTag.id);
}
} else {
logger.warn(`Requester has no tag and failed to add one`, {
label: 'Media Request',
requestId: entity.id,
mediaId: entity.media.id,
userId: entity.requestedBy.id,
sonarrServer:
sonarrSettings.hostname + ':' + sonarrSettings.port,
});
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/components/Settings/RadarrModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const messages = defineMessages('components.Settings.RadarrModal', {
testFirstTags: 'Test connection to load tags',
tags: 'Tags',
enableSearch: 'Enable Automatic Search',
tagRequestsNoID: 'No ID in tag',
tagRequestsNoIDInfo:
'Do not prefix the tag with user ID. Tag Requests must be enable for this to work.',
tagRequests: 'Tag Requests',
tagRequestsInfo:
"Automatically add an additional tag with the requester's user ID & display name",
Expand Down Expand Up @@ -231,6 +234,7 @@ const RadarrModal = ({ onClose, radarr, onSave }: RadarrModalProps) => {
syncEnabled: radarr?.syncEnabled ?? false,
enableSearch: !radarr?.preventSearch,
tagRequests: radarr?.tagRequests ?? false,
tagRequestsNoID: radarr?.tagRequestsNoID ?? false,
}}
validationSchema={RadarrSettingsSchema}
onSubmit={async (values) => {
Expand All @@ -257,6 +261,7 @@ const RadarrModal = ({ onClose, radarr, onSave }: RadarrModalProps) => {
syncEnabled: values.syncEnabled,
preventSearch: !values.enableSearch,
tagRequests: values.tagRequests,
tagRequestsNoID: values.tagRequestsNoID,
};
if (!radarr) {
await axios.post('/api/v1/settings/radarr', submission);
Expand Down Expand Up @@ -726,6 +731,21 @@ const RadarrModal = ({ onClose, radarr, onSave }: RadarrModalProps) => {
/>
</div>
</div>
<div className="form-row">
<label htmlFor="tagRequestsNoID" className="checkbox-label">
{intl.formatMessage(messages.tagRequestsNoID)}
<span className="label-tip">
{intl.formatMessage(messages.tagRequestsNoIDInfo)}
</span>
</label>
<div className="form-input-area">
<Field
type="checkbox"
id="tagRequestsNoID"
name="tagRequestsNoID"
/>
</div>
</div>
</div>
</Modal>
);
Expand Down
20 changes: 20 additions & 0 deletions src/components/Settings/SonarrModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const messages = defineMessages('components.Settings.SonarrModal', {
syncEnabled: 'Enable Scan',
externalUrl: 'External URL',
enableSearch: 'Enable Automatic Search',
tagRequestsNoID: 'No ID in tag',
tagRequestsNoIDInfo:
'Do not prefix the tag with user ID. Tag Requests must be enable for this to work.',
tagRequests: 'Tag Requests',
tagRequestsInfo:
"Automatically add an additional tag with the requester's user ID & display name",
Expand Down Expand Up @@ -247,6 +250,7 @@ const SonarrModal = ({ onClose, sonarr, onSave }: SonarrModalProps) => {
syncEnabled: sonarr?.syncEnabled ?? false,
enableSearch: !sonarr?.preventSearch,
tagRequests: sonarr?.tagRequests ?? false,
tagRequestsNoID: sonarr?.tagRequestsNoID ?? false,
}}
validationSchema={SonarrSettingsSchema}
onSubmit={async (values) => {
Expand Down Expand Up @@ -290,6 +294,7 @@ const SonarrModal = ({ onClose, sonarr, onSave }: SonarrModalProps) => {
syncEnabled: values.syncEnabled,
preventSearch: !values.enableSearch,
tagRequests: values.tagRequests,
tagRequestsNoID: values.tagRequestsNoID,
};
if (!sonarr) {
await axios.post('/api/v1/settings/sonarr', submission);
Expand Down Expand Up @@ -1023,6 +1028,21 @@ const SonarrModal = ({ onClose, sonarr, onSave }: SonarrModalProps) => {
/>
</div>
</div>
<div className="form-row">
<label htmlFor="tagRequestsNoID" className="checkbox-label">
{intl.formatMessage(messages.tagRequestsNoID)}
<span className="label-tip">
{intl.formatMessage(messages.tagRequestsNoIDInfo)}
</span>
</label>
<div className="form-input-area">
<Field
type="checkbox"
id="tagRequestsNoID"
name="tagRequestsNoID"
/>
</div>
</div>
</div>
</Modal>
);
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,8 @@
"components.Settings.RadarrModal.servername": "Server Name",
"components.Settings.RadarrModal.ssl": "Use SSL",
"components.Settings.RadarrModal.syncEnabled": "Enable Scan",
"components.Settings.RadarrModal.tagRequestsNoID": "No ID in tag",
"components.Settings.RadarrModal.tagRequestsNoIDInfo": "Do not prefix the tag with user ID. Tag Requests must be enable for this to work.",
"components.Settings.RadarrModal.tagRequests": "Tag Requests",
"components.Settings.RadarrModal.tagRequestsInfo": "Automatically add an additional tag with the requester's user ID & display name",
"components.Settings.RadarrModal.tags": "Tags",
Expand Down Expand Up @@ -1077,6 +1079,8 @@
"components.Settings.SonarrModal.servername": "Server Name",
"components.Settings.SonarrModal.ssl": "Use SSL",
"components.Settings.SonarrModal.syncEnabled": "Enable Scan",
"components.Settings.SonarrModal.tagRequestsNoID": "No ID in tag",
"components.Settings.SonarrModal.tagRequestsNoIDInfo": "Do not prefix the tag with user ID. Tag Requests must be enable for this to work.",
"components.Settings.SonarrModal.tagRequests": "Tag Requests",
"components.Settings.SonarrModal.tagRequestsInfo": "Automatically add an additional tag with the requester's user ID & display name",
"components.Settings.SonarrModal.tags": "Tags",
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,11 @@
"components.Selector.starttyping": "Commencez à taper pour rechercher.",
"components.Settings.SettingsJobsCache.editJobScheduleSelectorSeconds": "Toutes les {jobScheduleSeconds, plural, one {seconde} other {{jobScheduleSeconds} secondes}}",
"components.Settings.SettingsJobsCache.availability-sync": "Synchronisation de la disponibilité des médias",
"components.Settings.RadarrModal.tagRequestsNoID": "Pas de ID dans le tag",
"components.Settings.RadarrModal.tagRequestsNoIDInfo": "Ne pas ajouter le préfixe ID utilisateur au tag. Requis que l'option Tager les demandes soit active.",
"components.Settings.RadarrModal.tagRequests": "Tager les demandes",
"components.Settings.SonarrModal.tagRequestsNoID": "Pas de ID dans le tag",
"components.Settings.SonarrModal.tagRequestsNoIDInfo": "Ne pas ajouter le préfixe ID utilisateur au tag. Requis que l'option Tager les demandes soit active.",
"components.Settings.SonarrModal.tagRequests": "Tager les demandes",
"components.Settings.SonarrModal.tagRequestsInfo": "Ajouter automatiquement un tag supplémentaire avec l'ID utilisateur et le nom d'affichage du demandeur",
"i18n.collection": "Collection",
Expand Down