Skip to content

Commit

Permalink
feat(U-NEXT): add activity (#9102)
Browse files Browse the repository at this point in the history
* feat(U-NEXT): add unext presence

* feat(U-NEXT): add livestream archive presence

* fix(U-NEXT): add livestream detail page path regex

* fix(U-NEXT): change ja to ja_JP

* fix(U-NEXT): changes Strings, unext to u-next

* refactor(U-NEXT): changes thumbnail

* refactor(U-NEXT): remove unused Strings
  • Loading branch information
c7e715d1b04b17683718fb1e8944cc28 authored Jan 8, 2025
1 parent 7648fa8 commit b94dcff
Show file tree
Hide file tree
Showing 8 changed files with 766 additions and 0 deletions.
18 changes: 18 additions & 0 deletions websites/U/U-NEXT/U-NEXT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"u-next.seriesDisplay.full": {
"description": "Shown when watching a series with 'watching seriesname' status, example: Season 6, Episode 2",
"message": "Episode {0}"
},
"u-next.seriesDisplay.short": {
"description": "Shown when watching a series with 'watching U-NEXT' status, example: S6 E2 - Episode title",
"message": "E{0} - {1}"
},
"u-next.movieDisplay": {
"description": "Shown when watching a movie, example: 2024 • 120 minutes",
"message": "{0} • {1} minutes"
},
"u-next.liveDisplay": {
"description": "Shown when watching a livestream, example: 2024 • 120 minutes",
"message": "{0} • {1} minutes"
}
}
47 changes: 47 additions & 0 deletions websites/U/U-NEXT/functions/fetchLiveMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pLimit from "p-limit";
import { LiveRoot } from "../types";

const limit = pLimit(1);

export let liveMetadata: {
url: string;
data?: LiveRoot;
} | null = null;

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

const getLiveDetailResponse = await fetch("https://cc.unext.jp/", {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
operationName: "cosmo_getLiveDetail",
variables: {
liveCode: id,
},
extensions: {
persistedQuery: {
version: 1,
sha256Hash:
"02f3512167abdfa1ebc3ba0fba04f54d2ccf5203e3e5639cbe36e5b844cbee38",
},
},
}),
});

liveMetadata = {
url: document.location.href,
data: {
webfrontGetLive: (await getLiveDetailResponse.json()).data
.webfront_getLive,
},
};
});
}

export function clearLiveMetadata(): void {
liveMetadata = null;
}
70 changes: 70 additions & 0 deletions websites/U/U-NEXT/functions/fetchMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import pLimit from "p-limit";
import { Root } from "../types";

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;

const getVideoTitleResponse = await fetch("https://cc.unext.jp/", {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
operationName: "cosmo_getVideoTitle",
variables: {
code: id,
},
extensions: {
persistedQuery: {
version: 1,
sha256Hash:
"9c27258639966cfe47ebf308f155c3107d7489ed421b4d6e5ea61c3dd3c06c57",
},
},
}),
}),
getVideoTitleEpisodesResponse = await fetch("https://cc.unext.jp/", {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
operationName: "cosmo_getVideoTitleEpisodes",
variables: {
code: id,
page: 1,
pageSize: 20,
},
extensions: {
persistedQuery: {
version: 1,
sha256Hash:
"a2ee1b5c371aa0385a45bd8066671e50b8e618312246356a4d6b3feaf50d6a93",
},
},
}),
});

metadata = {
url: document.location.href,
data: {
webfrontTitleStage: (await getVideoTitleResponse.json()).data
.webfront_title_stage,
webfrontTitleTitleEpisodes: (await getVideoTitleEpisodesResponse.json())
.data.webfront_title_titleEpisodes,
},
};
});
}

export function clearMetadata(): void {
metadata = null;
}
94 changes: 94 additions & 0 deletions websites/U/U-NEXT/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"$schema": "https://schemas.premid.app/metadata/1.12",
"apiVersion": 1,
"author": {
"name": "KohnoseLami",
"id": "1180088441459978261"
},
"contributors": [],
"service": "U-NEXT",
"altnames": [
"ユーネクスト"
],
"description": {
"en": "U-NEXT, operated by U-NEXT Corporation, a subsidiary of U-NEXT HOLDINGS, is a leading Japanese streaming platform offering over-the-top (OTT) content. As of May 2024, it boasts approximately 4.34 million paying subscribers, making it the largest homegrown video-on-demand (VOD) service in Japan.",
"ja_JP": "U-NEXTは、U-NEXT HOLDINGS子会社の株式会社U-NEXTが運営する、日本のOTTコンテンツ・プラットフォーム。有料会員数は2024年5月時点で約434万人で、国産のVODサービスとしては最大手。"
},
"url": [
"video.unext.jp",
"unext.jp"
],
"version": "1.0.0",
"logo": "https://i.imgur.com/tuSR9Ef.png",
"thumbnail": "https://i.imgur.com/UX5e7Vk.png",
"color": "#000000",
"category": "videos",
"tags": [
"u-next",
"video",
"media"
],
"settings": [
{
"id": "lang",
"multiLanguage": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
},
{
"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": "showCover",
"if": {
"privacy": false
},
"title": "Show Cover",
"icon": "fas fa-images",
"value": true
},
{
"id": "showMovies",
"title": "Show Movies",
"icon": "fad fa-camera-movie",
"value": true
},
{
"id": "showSeries",
"title": "Show Series",
"icon": "fad fa-film",
"value": true
},
{
"id": "showSmallImages",
"title": "Show Small Images",
"icon": "fad fa-pause",
"value": true
},
{
"id": "timestamp",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true,
"if": {
"privacy": false
}
}
]
}
37 changes: 37 additions & 0 deletions websites/U/U-NEXT/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/U/U-NEXT/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 b94dcff

Please sign in to comment.