Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sct committed Feb 28, 2021
2 parents ea2765f + 2771376 commit cd9d9ae
Show file tree
Hide file tree
Showing 27 changed files with 338 additions and 163 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/support.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
to get help with Overseerr.
- [Discord](https://discord.gg/PkCWJSeCk7)
- [GitHub Discussions](https://github.com/sct/overseerr/discussions)
close-issue: true
lock-issue: false
lock-issue: true
issue-lock-reason: 'off-topic'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"bowser": "^2.11.0",
"connect-typeorm": "^1.1.4",
"cookie-parser": "^1.4.5",
"country-code-emoji": "^2.2.0",
"country-flag-icons": "^1.2.9",
"csurf": "^1.11.0",
"email-templates": "^8.0.3",
"express": "^4.17.1",
Expand Down Expand Up @@ -83,6 +83,7 @@
"@types/bcrypt": "^3.0.0",
"@types/body-parser": "^1.19.0",
"@types/cookie-parser": "^1.4.2",
"@types/country-flag-icons": "^1.2.0",
"@types/csurf": "^1.11.0",
"@types/email-templates": "^8.0.2",
"@types/express": "^4.17.11",
Expand Down
1 change: 1 addition & 0 deletions server/interfaces/api/settingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface PublicSettingsResponse {
movie4kEnabled: boolean;
series4kEnabled: boolean;
region: string;
originalLanguage: string;
}

export interface CacheItem {
Expand Down
16 changes: 12 additions & 4 deletions server/job/plexsync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ class JobPlexSync {
isAllStandardSeasons || shouldStayAvailable
? MediaStatus.AVAILABLE
: media.seasons.some(
(season) => season.status !== MediaStatus.UNKNOWN
(season) =>
season.status === MediaStatus.PARTIALLY_AVAILABLE ||
season.status === MediaStatus.AVAILABLE
)
? MediaStatus.PARTIALLY_AVAILABLE
: MediaStatus.UNKNOWN;
Expand All @@ -675,7 +677,9 @@ class JobPlexSync {
? MediaStatus.AVAILABLE
: this.enable4kShow &&
media.seasons.some(
(season) => season.status4k !== MediaStatus.UNKNOWN
(season) =>
season.status4k === MediaStatus.PARTIALLY_AVAILABLE ||
season.status4k === MediaStatus.AVAILABLE
)
? MediaStatus.PARTIALLY_AVAILABLE
: MediaStatus.UNKNOWN;
Expand All @@ -691,7 +695,9 @@ class JobPlexSync {
status: isAllStandardSeasons
? MediaStatus.AVAILABLE
: newSeasons.some(
(season) => season.status !== MediaStatus.UNKNOWN
(season) =>
season.status === MediaStatus.PARTIALLY_AVAILABLE ||
season.status === MediaStatus.AVAILABLE
)
? MediaStatus.PARTIALLY_AVAILABLE
: MediaStatus.UNKNOWN,
Expand All @@ -700,7 +706,9 @@ class JobPlexSync {
? MediaStatus.AVAILABLE
: this.enable4kShow &&
newSeasons.some(
(season) => season.status4k !== MediaStatus.UNKNOWN
(season) =>
season.status4k === MediaStatus.PARTIALLY_AVAILABLE ||
season.status4k === MediaStatus.AVAILABLE
)
? MediaStatus.PARTIALLY_AVAILABLE
: MediaStatus.UNKNOWN,
Expand Down
3 changes: 2 additions & 1 deletion server/lib/notifications/agents/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TelegramAgent
const title = this.escapeText(payload.subject);
const plot = this.escapeText(payload.message);
const user = this.escapeText(payload.notifyUser.displayName);
const applicationTitle = this.escapeText(settings.main.applicationTitle);

/* eslint-disable no-useless-escape */
switch (type) {
Expand Down Expand Up @@ -109,7 +110,7 @@ class TelegramAgent

if (settings.main.applicationUrl && payload.media) {
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
message += `\n\n\[Open in ${settings.main.applicationTitle}\]\(${actionUrl}\)`;
message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`;
}
/* eslint-enable */

Expand Down
2 changes: 2 additions & 0 deletions server/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface FullPublicSettings extends PublicSettings {
movie4kEnabled: boolean;
series4kEnabled: boolean;
region: string;
originalLanguage: string;
}

export interface NotificationAgentConfig {
Expand Down Expand Up @@ -337,6 +338,7 @@ class Settings {
(sonarr) => sonarr.is4k && sonarr.isDefault
),
region: this.data.main.region,
originalLanguage: this.data.main.originalLanguage,
};
}

Expand Down
59 changes: 29 additions & 30 deletions server/routes/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,35 @@ import Media from '../entity/Media';
import { isMovie, isPerson } from '../utils/typeHelpers';
import { MediaType } from '../constants/media';
import { getSettings } from '../lib/settings';
import { User } from '../entity/User';

const createTmdbWithRegionLanaguage = (user?: User): TheMovieDb => {
const settings = getSettings();

const region =
user?.settings?.region === 'all'
? ''
: user?.settings?.region
? user?.settings?.region
: settings.main.region;

const originalLanguage =
user?.settings?.originalLanguage === 'all'
? ''
: user?.settings?.originalLanguage
? user?.settings?.originalLanguage
: settings.main.originalLanguage;

return new TheMovieDb({
region,
originalLanguage,
});
};

const discoverRoutes = Router();

discoverRoutes.get('/movies', async (req, res) => {
const settings = getSettings();
const tmdb = new TheMovieDb({
region: req.user?.settings?.region ?? settings.main.region,
originalLanguage:
req.user?.settings?.originalLanguage ?? settings.main.originalLanguage,
});
const tmdb = createTmdbWithRegionLanaguage(req.user);

const data = await tmdb.getDiscoverMovies({
page: Number(req.query.page),
Expand All @@ -41,12 +60,7 @@ discoverRoutes.get('/movies', async (req, res) => {
});

discoverRoutes.get('/movies/upcoming', async (req, res) => {
const settings = getSettings();
const tmdb = new TheMovieDb({
region: req.user?.settings?.region ?? settings.main.region,
originalLanguage:
req.user?.settings?.originalLanguage ?? settings.main.originalLanguage,
});
const tmdb = createTmdbWithRegionLanaguage(req.user);

const now = new Date();
const offset = now.getTimezoneOffset();
Expand Down Expand Up @@ -80,12 +94,7 @@ discoverRoutes.get('/movies/upcoming', async (req, res) => {
});

discoverRoutes.get('/tv', async (req, res) => {
const settings = getSettings();
const tmdb = new TheMovieDb({
region: req.user?.settings?.region ?? settings.main.region,
originalLanguage:
req.user?.settings?.originalLanguage ?? settings.main.originalLanguage,
});
const tmdb = createTmdbWithRegionLanaguage(req.user);

const data = await tmdb.getDiscoverTv({
page: Number(req.query.page),
Expand All @@ -112,12 +121,7 @@ discoverRoutes.get('/tv', async (req, res) => {
});

discoverRoutes.get('/tv/upcoming', async (req, res) => {
const settings = getSettings();
const tmdb = new TheMovieDb({
region: req.user?.settings?.region ?? settings.main.region,
originalLanguage:
req.user?.settings?.originalLanguage ?? settings.main.originalLanguage,
});
const tmdb = createTmdbWithRegionLanaguage(req.user);

const now = new Date();
const offset = now.getTimezoneOffset();
Expand Down Expand Up @@ -151,12 +155,7 @@ discoverRoutes.get('/tv/upcoming', async (req, res) => {
});

discoverRoutes.get('/trending', async (req, res) => {
const settings = getSettings();
const tmdb = new TheMovieDb({
region: req.user?.settings?.region ?? settings.main.region,
originalLanguage:
req.user?.settings?.originalLanguage ?? settings.main.originalLanguage,
});
const tmdb = createTmdbWithRegionLanaguage(req.user);

const data = await tmdb.getAllTrending({
page: Number(req.query.page),
Expand Down
4 changes: 1 addition & 3 deletions server/routes/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ requestRoutes.post(

const request = new MediaRequest({
type: MediaType.TV,
media: {
id: media.id,
} as Media,
media,
requestedBy: requestUser,
// If the user is an admin or has the "auto approve" permission, automatically approve the request
status:
Expand Down
Loading

0 comments on commit cd9d9ae

Please sign in to comment.