-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add overseerr version and update availability status to sidebar
sort of experimental so may be kinda broken. :)
- Loading branch information
Showing
8 changed files
with
339 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import cacheManager from '../lib/cache'; | ||
import logger from '../logger'; | ||
import ExternalAPI from './externalapi'; | ||
|
||
interface GitHubRelease { | ||
url: string; | ||
assets_url: string; | ||
upload_url: string; | ||
html_url: string; | ||
id: number; | ||
node_id: string; | ||
tag_name: string; | ||
target_commitish: string; | ||
name: string; | ||
draft: boolean; | ||
prerelease: boolean; | ||
created_at: string; | ||
published_at: string; | ||
tarball_url: string; | ||
zipball_url: string; | ||
body: string; | ||
} | ||
|
||
interface GithubCommit { | ||
sha: string; | ||
node_id: string; | ||
commit: { | ||
author: { | ||
name: string; | ||
email: string; | ||
date: string; | ||
}; | ||
committer: { | ||
name: string; | ||
email: string; | ||
date: string; | ||
}; | ||
message: string; | ||
tree: { | ||
sha: string; | ||
url: string; | ||
}; | ||
url: string; | ||
comment_count: number; | ||
verification: { | ||
verified: boolean; | ||
reason: string; | ||
signature: string; | ||
payload: string; | ||
}; | ||
}; | ||
url: string; | ||
html_url: string; | ||
comments_url: string; | ||
parents: [ | ||
{ | ||
sha: string; | ||
url: string; | ||
html_url: string; | ||
} | ||
]; | ||
} | ||
|
||
class GithubAPI extends ExternalAPI { | ||
constructor() { | ||
super( | ||
'https://api.github.com', | ||
{}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
nodeCache: cacheManager.getCache('github').data, | ||
} | ||
); | ||
} | ||
|
||
public async getOverseerrReleases({ | ||
take = 20, | ||
}: { | ||
take?: number; | ||
} = {}): Promise<GitHubRelease[]> { | ||
try { | ||
const data = await this.get<GitHubRelease[]>( | ||
'/repos/sct/overseerr/releases', | ||
{ | ||
params: { | ||
per_page: take, | ||
}, | ||
} | ||
); | ||
|
||
return data; | ||
} catch (e) { | ||
logger.warn( | ||
"Failed to retrieve GitHub releases. This may be an issue on GitHub's end. Overseerr can't check if it's on the latest version.", | ||
{ label: 'GitHub API', errorMessage: e.message } | ||
); | ||
return []; | ||
} | ||
} | ||
|
||
public async getOverseerrCommits({ | ||
take = 20, | ||
branch = 'develop', | ||
}: { | ||
take?: number; | ||
branch?: string; | ||
} = {}): Promise<GithubCommit[]> { | ||
try { | ||
const data = await this.get<GithubCommit[]>( | ||
'/repos/sct/overseerr/commits', | ||
{ | ||
params: { | ||
per_page: take, | ||
branch, | ||
}, | ||
} | ||
); | ||
|
||
return data; | ||
} catch (e) { | ||
logger.warn( | ||
"Failed to retrieve GitHub commits. This may be an issue on GitHub's end. Overseerr can't check if it's on the latest version.", | ||
{ label: 'GitHub API', errorMessage: e.message } | ||
); | ||
return []; | ||
} | ||
} | ||
} | ||
|
||
export default GithubAPI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.