Skip to content

Commit

Permalink
chore(netflix): recode presence (PreMiD#8429)
Browse files Browse the repository at this point in the history
* chore(netflix): recode presence

* chore: fix deepscan issues
  • Loading branch information
Timeraa authored May 28, 2024
1 parent fb9e6b8 commit 1d240d1
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 541 deletions.
27 changes: 27 additions & 0 deletions websites/N/Netflix/functions/fetchMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pLimit from "p-limit";
import { Root } from "../types";
import { buildIdentifier } from "./getBuildIdentifier";

const limit = pLimit(1);

export let metadata: {
url: string;
data?: Root;
} | null = null;

export async function fetchMetadata(id: string): Promise<void> {
await limit(async () => {
if (metadata?.url === document.location.href) return;

metadata = { url: document.location.href };
metadata.data = await (
await fetch(
`https://www.netflix.com/nq/website/memberapi/${buildIdentifier}/metadata?movieid=${id}`
)
).json();
});
}

export function clearMetadata(): void {
metadata = null;
}
18 changes: 18 additions & 0 deletions websites/N/Netflix/functions/getBuildIdentifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export let buildIdentifier: string | null = null;

export async function getBuildIdentifier(presence: Presence): Promise<void> {
if (!buildIdentifier) {
buildIdentifier = await presence
.getPageVariable(
"netflix.reactContext.models.serverDefs.data.BUILD_IDENTIFIER"
)
.then(
data =>
data[
"netflix.reactContext.models.serverDefs.data.BUILD_IDENTIFIER"
] as string
)
.catch(() => null);
return;
}
}
75 changes: 16 additions & 59 deletions websites/N/Netflix/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"matches": [
"*://*.netflix.com/*"
],
"version": "5.2.7",
"version": "6.0.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/N/Netflix/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/N/Netflix/assets/thumbnail.jpg",
"color": "#db0000",
Expand All @@ -80,80 +80,43 @@
"value": false
},
{
"id": "browse",
"id": "usePresenceName",
"title": "Show Title as Presence",
"icon": "fad fa-user-edit",
"value": true,
"if": {
"privacy": false
}
},
{
"id": "showBrowsingStatus",
"title": "Show Browsing Status",
"icon": "fad fa-book-reader",
"value": true
},
{
"id": "movie",
"id": "showMovies",
"title": "Show Movies",
"icon": "fad fa-camera-movie",
"value": true
},
{
"id": "movieDetails",
"if": {
"privacy": false
},
"title": "Movie Details row1",
"icon": "fas fa-comment-alt-edit",
"value": "%title%",
"placeholder": "Use %title% or {0} to delete the row completely"
},
{
"id": "movieStates",
"if": {
"privacy": false
},
"title": "Movie Details row2",
"icon": "fas fa-comment-alt-edit",
"value": "Movie",
"placeholder": "Use %title% or {0} to delete the row completely"
},
{
"id": "series",
"id": "showSeries",
"title": "Show Series",
"icon": "fad fa-film",
"value": true
},
{
"id": "seriesDetails",
"if": {
"privacy": false
},
"title": "Series Details row1",
"icon": "fas fa-comment-alt-edit",
"value": "%title%",
"placeholder": "Use %title% or %episode% or %season% or %episodeTitle%"
},
{
"id": "seriesStates",
"if": {
"privacy": false
},
"title": "Video Details row2",
"icon": "fas fa-comment-alt-edit",
"value": "S%season%:E%episode% %episodeTitle%",
"placeholder": "Use %title% or %episode% or %season% or %episodeTitle% or {0} to delete the row completely"
},
{
"id": "timestamp",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true
},
{
"id": "buttons",
"value": true,
"if": {
"privacy": false
},
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
}
},
{
"id": "logo",
"id": "logoType",
"title": "Icon",
"icon": "fad fa-images",
"value": 0,
Expand All @@ -162,12 +125,6 @@
"Still",
"Still, No Background"
]
},
{
"id": "cover",
"title": "Show Cover",
"icon": "fad fa-images",
"value": true
}
]
}
37 changes: 37 additions & 0 deletions websites/N/Netflix/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions websites/N/Netflix/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"p-limit": "5.0.0"
}
}
Loading

0 comments on commit 1d240d1

Please sign in to comment.