Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add upload logs button #169

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
91 changes: 86 additions & 5 deletions src/lib/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const AppModelSchema = {
version: {
type: 'string',
title: 'Version',
default: '0.16.2'
default: '0.18.0'
},
api_key: {
type: 'string',
Expand All @@ -44,6 +44,11 @@ export const AppModelSchema = {
title: 'Debug',
default: true
},
debug_database: {
type: 'boolean',
title: 'Debug Database',
default: false
},
log: {
type: 'boolean',
title: 'Log',
Expand Down Expand Up @@ -159,6 +164,13 @@ export const AppModelSchema = {
fetch_trending: false,
most_watched_count: 10,
most_watched_period: 'weekly',
oauth: {
access_token: '',
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
refresh_token: ''
},
popular_count: 10,
trending_count: 10,
update_interval: 86400,
Expand Down Expand Up @@ -786,7 +798,14 @@ export const ContentModelSchema = {
popular_count: 10,
fetch_most_watched: false,
most_watched_period: 'weekly',
most_watched_count: 10
most_watched_count: 10,
oauth: {
access_token: '',
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
refresh_token: ''
}
}
}
},
Expand Down Expand Up @@ -2276,7 +2295,7 @@ export const RemoveResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand All @@ -2295,7 +2314,7 @@ export const ResetResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand All @@ -2314,7 +2333,7 @@ export const RetryResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand Down Expand Up @@ -2916,6 +2935,16 @@ export const TraktModelSchema = {
type: 'integer',
title: 'Most Watched Count',
default: 10
},
oauth: {
'$ref': '#/components/schemas/TraktOauthModel',
default: {
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
access_token: '',
refresh_token: ''
}
}
},
type: 'object',
Expand All @@ -2934,6 +2963,38 @@ export const TraktOAuthInitiateResponseSchema = {
title: 'TraktOAuthInitiateResponse'
} as const;

export const TraktOauthModelSchema = {
properties: {
oauth_client_id: {
type: 'string',
title: 'Oauth Client Id',
default: ''
},
oauth_client_secret: {
type: 'string',
title: 'Oauth Client Secret',
default: ''
},
oauth_redirect_uri: {
type: 'string',
title: 'Oauth Redirect Uri',
default: ''
},
access_token: {
type: 'string',
title: 'Access Token',
default: ''
},
refresh_token: {
type: 'string',
title: 'Refresh Token',
default: ''
}
},
type: 'object',
title: 'TraktOauthModel'
} as const;

export const UpdateAttributesResponseSchema = {
properties: {
message: {
Expand Down Expand Up @@ -2982,6 +3043,26 @@ export const UpdatersModelSchema = {
title: 'UpdatersModel'
} as const;

export const UploadLogsResponseSchema = {
properties: {
success: {
type: 'boolean',
title: 'Success'
},
url: {
type: 'string',
maxLength: 2083,
minLength: 1,
format: 'uri',
title: 'Url',
description: 'URL to the uploaded log file. 50M Filesize limit. 180 day retention.'
}
},
type: 'object',
required: ['success', 'url'],
title: 'UploadLogsResponse'
} as const;

export const ValidationErrorSchema = {
properties: {
loc: {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/client/services.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

import { createClient, createConfig, type Options } from '@hey-api/client-fetch';
import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, GenerateapikeyError, GenerateapikeyResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse, EventsError, EventsResponse, MountError, MountResponse, OverseerrApiV1WebhookOverseerrPostError, OverseerrApiV1WebhookOverseerrPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, GetItemStreamsApiV1ItemsItemIdStreamsGetData, GetItemStreamsApiV1ItemsItemIdStreamsGetError, GetItemStreamsApiV1ItemsItemIdStreamsGetResponse, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostResponse, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostError, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostResponse, ScrapeItemData, ScrapeItemError, ScrapeItemResponse2, StartManualSessionApiV1ScrapeScrapeStartSessionPostData, StartManualSessionApiV1ScrapeScrapeStartSessionPostError, StartManualSessionApiV1ScrapeScrapeStartSessionPostResponse, ManualSelectData, ManualSelectError, ManualSelectResponse, ManualUpdateAttributesData, ManualUpdateAttributesError, ManualUpdateAttributesResponse, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostData, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostError, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostResponse, CompleteManualSessionData, CompleteManualSessionError, CompleteManualSessionResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse, SaveSettingsError, SaveSettingsResponse, GetAllSettingsError, GetAllSettingsResponse, GetSettingsData, GetSettingsError, GetSettingsResponse, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse, SetSettingsData, SetSettingsError, SetSettingsResponse, GetEventTypesApiV1StreamEventTypesGetError, GetEventTypesApiV1StreamEventTypesGetResponse, StreamEventsApiV1StreamEventTypeGetData, StreamEventsApiV1StreamEventTypeGetError, StreamEventsApiV1StreamEventTypeGetResponse } from './types.gen';
import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, GenerateapikeyError, GenerateapikeyResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse, EventsError, EventsResponse, MountError, MountResponse, UploadLogsError, UploadLogsResponse2, OverseerrApiV1WebhookOverseerrPostError, OverseerrApiV1WebhookOverseerrPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, GetItemStreamsApiV1ItemsItemIdStreamsGetData, GetItemStreamsApiV1ItemsItemIdStreamsGetError, GetItemStreamsApiV1ItemsItemIdStreamsGetResponse, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostResponse, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostError, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostResponse, ScrapeItemData, ScrapeItemError, ScrapeItemResponse2, StartManualSessionApiV1ScrapeScrapeStartSessionPostData, StartManualSessionApiV1ScrapeScrapeStartSessionPostError, StartManualSessionApiV1ScrapeScrapeStartSessionPostResponse, ManualSelectData, ManualSelectError, ManualSelectResponse, ManualUpdateAttributesData, ManualUpdateAttributesError, ManualUpdateAttributesResponse, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostData, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostError, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostResponse, CompleteManualSessionData, CompleteManualSessionError, CompleteManualSessionResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse, SaveSettingsError, SaveSettingsResponse, GetAllSettingsError, GetAllSettingsResponse, GetSettingsData, GetSettingsError, GetSettingsResponse, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse, SetSettingsData, SetSettingsError, SetSettingsResponse, GetEventTypesApiV1StreamEventTypesGetError, GetEventTypesApiV1StreamEventTypesGetResponse, StreamEventsApiV1StreamEventTypeGetData, StreamEventsApiV1StreamEventTypeGetError, StreamEventsApiV1StreamEventTypeGetResponse } from './types.gen';

export const client = createClient(createConfig());

Expand Down Expand Up @@ -127,6 +127,17 @@ export class DefaultService {
});
}

/**
* Upload Logs
* Upload the latest log file to paste.c-net.org
*/
public static uploadLogs<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) {
return (options?.client ?? client).post<UploadLogsResponse2, UploadLogsError, ThrowOnError>({
...options,
url: '/api/v1/upload_logs'
});
}
AyushSehrawat marked this conversation as resolved.
Show resolved Hide resolved

/**
* Overseerr
* Webhook for Overseerr
Expand Down
36 changes: 29 additions & 7 deletions src/lib/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type AppModel = {
version?: string;
api_key?: string;
debug?: boolean;
debug_database?: boolean;
log?: boolean;
force_refresh?: boolean;
map_metadata?: boolean;
Expand Down Expand Up @@ -337,17 +338,17 @@ export type RealDebridModel = {

export type RemoveResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type ResetResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type RetryResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type RootResponse = {
Expand Down Expand Up @@ -515,12 +516,21 @@ export type TraktModel = {
fetch_most_watched?: boolean;
most_watched_period?: string;
most_watched_count?: number;
oauth?: TraktOauthModel;
};

export type TraktOAuthInitiateResponse = {
auth_url: string;
};

export type TraktOauthModel = {
oauth_client_id?: string;
oauth_client_secret?: string;
oauth_redirect_uri?: string;
access_token?: string;
refresh_token?: string;
};

export type UpdateAttributesResponse = {
message: string;
};
Expand All @@ -532,6 +542,14 @@ export type UpdatersModel = {
emby?: EmbyLibraryModel;
};

export type UploadLogsResponse = {
success: boolean;
/**
* URL to the uploaded log file. 50M Filesize limit. 180 day retention.
*/
url: string;
};

export type ValidationError = {
loc: Array<(string | number)>;
msg: string;
Expand Down Expand Up @@ -608,6 +626,10 @@ export type MountResponse = ({

export type MountError = (unknown);

export type UploadLogsResponse2 = (UploadLogsResponse);

export type UploadLogsError = (unknown);

export type OverseerrApiV1WebhookOverseerrPostResponse = ({
[key: string]: unknown;
});
Expand Down Expand Up @@ -647,7 +669,7 @@ export type AddItemsError = (unknown | HTTPValidationError);

export type GetItemData = {
path: {
id: number;
id: string;
};
query?: {
use_tmdb_id?: (boolean | null);
Expand Down Expand Up @@ -704,7 +726,7 @@ export type RemoveItemError = (unknown | HTTPValidationError);

export type GetItemStreamsApiV1ItemsItemIdStreamsGetData = {
path: {
item_id: number;
item_id: string;
};
};

Expand All @@ -714,7 +736,7 @@ export type GetItemStreamsApiV1ItemsItemIdStreamsGetError = (unknown | HTTPValid

export type BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData = {
path: {
item_id: number;
item_id: string;
stream_id: number;
};
};
Expand All @@ -725,7 +747,7 @@ export type BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError = (

export type UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData = {
path: {
item_id: number;
item_id: string;
stream_id: number;
};
};
Expand Down
6 changes: 3 additions & 3 deletions src/lib/tmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export async function getMovieDetails(
fetch: any,
language: string = 'en-US',
append_to_response: string | null = null,
movieId: number
movieId: string
) {
const params = { language, append_to_response };
const queryString = dictToQueryString(params);
Expand Down Expand Up @@ -190,7 +190,7 @@ export async function getTVDetails(
fetch: any,
language: string = 'en-US',
append_to_response: string | null = null,
tvId: number
tvId: string
) {
const params = { language, append_to_response };
const queryString = dictToQueryString(params);
Expand All @@ -209,7 +209,7 @@ export async function getTVSeasonDetails(
fetch: any,
language: string = 'en-US',
append_to_response: string | null = null,
tvId: number,
tvId: string,
seasonNumber: number
) {
const params = { language, append_to_response };
Expand Down
4 changes: 2 additions & 2 deletions src/routes/[type=mediaType]/[id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { RivenItem } from '$lib/types';

export const load = (async ({ fetch, params }) => {
const type = params.type;
const id = Number(params.id);
const id = String(params.id);

const { data } = await ItemsService.getItem({
path: {
Expand All @@ -16,7 +16,7 @@ export const load = (async ({ fetch, params }) => {
}
});

async function getDetails(type: string, id: number) {
async function getDetails(type: string, id: string) {
switch (type) {
case 'movie':
// TODO: Remove the ones that are not needed in future
Expand Down
8 changes: 4 additions & 4 deletions src/routes/[type=mediaType]/[id]/[season]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import { ItemsService } from '$lib/client';

export const load = (async ({ fetch, params }) => {
const type = params.type;
const id = Number(params.id);
const id = String(params.id);
const season = Number(params.season);

if (type === 'movie') {
error(404, 'No seasons or episodes for movies');
}

async function getDetails(tvID: number, seasonNumber: number) {
async function getDetails(tvID: string, seasonNumber: number) {
return await getTVSeasonDetails(fetch, 'en-US', null, tvID, seasonNumber);
}

// not using parent data since it will be fetched again with useless data
async function mediaDetails(tvID: number) {
async function mediaDetails(tvID: string) {
return await getTVDetails(fetch, 'en-US', null, tvID);
}

async function getMediaItemDetails(tvID: number): Promise<any[]> {
async function getMediaItemDetails(tvID: string): Promise<any[]> {
const { data } = await ItemsService.getItem({
path: {
id: tvID
Expand Down
Loading
Loading