Skip to content

Commit

Permalink
Merge branch 'master' into revert-2051-revert-2049-dp1
Browse files Browse the repository at this point in the history
  • Loading branch information
i1u5 authored Sep 2, 2020
2 parents 8d82dd7 + 73bce56 commit 16eb4c5
Show file tree
Hide file tree
Showing 21 changed files with 990 additions and 117 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
}
],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": "error"
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/indent": "off"
},
"overrides": [
{
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
"@types/babel__core": "^7.1.9",
"@types/chrome": "^0.0.122",
"@types/glob": "^7.1.3",
"@types/mongodb": "^3.5.25",
"@types/node": "^14.0.27",
"@types/mongodb": "^3.5.26",
"@types/node": "^14.6.3",
"@types/prettier": "^2.0.2",
"@types/semver": "^7.3.1",
"@types/semver": "^7.3.3",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"@typescript-eslint/parser": "^3.10.1",
"axios": "^0.19.2",
"chalk": "^4.1.0",
"eslint": "^7.6.0",
"eslint": "^7.8.1",
"execa": "^4.0.3",
"glob": "^7.1.6",
"jsonschema": "^1.2.6",
"mongodb": "^3.6.0",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"semver": "^7.3.2",
"source-map-support": "^0.5.19",
"terser": "git://github.com/terser/terser.git#ff851d2",
"terser": "^5.2.1",
"typescript": "^3.9.7"
}
}
8 changes: 5 additions & 3 deletions websites/D/Disney+/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"es": "El servicio de streaming de Disney, Pixar, Marvel, Star Wars y National Geographic."
},
"url": "www.disneyplus.com",
"regExp": "([a-z0-9-]+[.])*disneyplus[.]com[/]",
"version": "1.3.5",
"regExp": "([a-z0-9-]+[.])*disneyplus[.]com[/]|([a-z0-9-]+[.])*hotstar[.]com[/]",
"version": "1.3.6",
"logo": "https://i.imgur.com/zuUeb2A.png",
"thumbnail": "https://i.imgur.com/NA7FWJN.png",
"color": "#233778",
Expand All @@ -27,7 +27,9 @@
"video",
"media",
"streaming",
"streaming-service"
"streaming-service",
"hotstar",
"disney-plus-hotstar"
],
"category": "videos"
}
54 changes: 50 additions & 4 deletions websites/D/Disney+/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ let title: string;
let subtitle: string;

presence.on("UpdateData", async () => {
const data: PresenceData = {
largeImageKey: "disneyplus-logo"
};
const isHostDP = /(www\.)?disneyplus\.com/.test(location.hostname);
const isHostHS = /(www\.)?hotstar\.com/.test(location.hostname);
const data: PresenceData = {};

if (document.location.pathname.includes("/video")) {
if (isHostDP) {
data.largeImageKey = "disneyplus-logo"
} else if (isHostHS) {
data.largeImageKey = "disneyplus-hotstar-logo"
}

// Disney+ video
if (isHostDP && location.pathname.includes("/video")) {
const video: HTMLVideoElement = document.querySelector(
".btm-media-clients video"
);
Expand Down Expand Up @@ -66,6 +73,45 @@ presence.on("UpdateData", async () => {
delete data.endTimestamp;
}

if (title) presence.setActivity(data, !video.paused);
}
// Disney+ Hotstar video
} else if (isHostHS && /\/(tv|movies)\//.test(location.pathname)) {
const video: HTMLVideoElement = document.querySelector(
".player-base video"
);

if (video && !isNaN(video.duration)) {
const timestamps: number[] = getTimestamps(
Math.floor(video.currentTime),
Math.floor(video.duration)
);

const titleField: HTMLDivElement = document.querySelector(
".controls-overlay .primary-title"
);
title = titleField ? titleField.textContent : null;
const subtitleField: HTMLDivElement = document.querySelector(
".controls-overlay .show-title"
);
subtitle = subtitleField ? subtitleField.textContent : null;

// subtitleField is episode for series, empty for movies
data.details = title;
data.state = subtitle ? subtitle : "Movie";

data.smallImageKey = video.paused ? "pause" : "play";
data.smallImageText = video.paused
? (await strings).pause
: (await strings).play;
data.startTimestamp = timestamps[0];
data.endTimestamp = timestamps[1];

if (video.paused) {
delete data.startTimestamp;
delete data.endTimestamp;
}

if (title) presence.setActivity(data, !video.paused);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions websites/F/Full Programlar İndir/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"author": {
"name": "SinecKers /Yasar",
"name": "SinecKers",
"id": "380411952666640385"
},
"url": [
Expand All @@ -12,7 +12,7 @@
"en": "Full Programlar İndir is a website that allows you to download many programs and games"
},
"service": "Full Programlar İndir",
"version": "1.0.5",
"version": "1.0.6",
"logo": "https://who.is-inside.me/GFOPO0ef.png",
"thumbnail": "https://who.is-inside.me/Dnjzzb8t.png",
"color": "#3F9EDD",
Expand Down
2 changes: 1 addition & 1 deletion websites/J/Jellyfin/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"en": "The Free Software Media System"
},
"service": "Jellyfin",
"version": "1.3.7",
"version": "1.3.8",
"logo": "https://i.imgur.com/nPzEemG.png",
"thumbnail": "https://i.imgur.com/J61378N.png",
"color": "#00698c",
Expand Down
37 changes: 15 additions & 22 deletions websites/J/Jellyfin/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,10 @@ interface MediaInfo {
Height: number;
}

const
// official website
const // official website
JELLYFIN_URL = "jellyfin.org",

// web client app name
APP_NAME = "Jellyfin Web",

// all the presence art assets uploaded to discord
PRESENCE_ART_ASSETS = {
download: "downloading",
Expand All @@ -282,7 +279,6 @@ const
search: "search",
write: "writing"
},

presenceData: PresenceData = {
largeImageKey: PRESENCE_ART_ASSETS.logo
};
Expand Down Expand Up @@ -314,18 +310,19 @@ let presence: Presence;
function handleAudioPlayback(): void {
// sometimes the buttons are not created fast enough
try {
const
audioElem = document.getElementsByTagName("audio")[0],
const audioElem = document.getElementsByTagName("audio")[0],
infoContainer = document.getElementsByClassName("nowPlayingBar")[0],
title: HTMLAnchorElement = infoContainer.getElementsByClassName("nowPlayingBarText")[0].querySelector("a"),
artist: HTMLDivElement = infoContainer.getElementsByClassName("nowPlayingBarSecondaryText")[0] as HTMLDivElement;
title: HTMLAnchorElement = infoContainer
.getElementsByClassName("nowPlayingBarText")[0]
.querySelector("a"),
artist: HTMLDivElement = infoContainer.getElementsByClassName(
"nowPlayingBarSecondaryText"
)[0] as HTMLDivElement;

presenceData.details = `Listening to: ${
title ? title.innerText : "unknown title"
}`;
presenceData.state = `By: ${
artist ? artist.innerText : "unknown artist"
}`;
presenceData.state = `By: ${artist ? artist.innerText : "unknown artist"}`;

// playing
if (!audioElem.paused) {
Expand Down Expand Up @@ -433,14 +430,12 @@ async function obtainMediaInfo(itemId: string): Promise<string | MediaInfo> {

media[itemId] = "pending";

const
res = await fetch(`/Users/${getUserId()}/Items/${itemId}`, {
const res = await fetch(`/Users/${getUserId()}/Items/${itemId}`, {
credentials: "include",
headers: {
"x-emby-authorization": `MediaBrowser Client="${ApiClient["_appName"]}", Device="${ApiClient["_deviceName"]}", DeviceId="${ApiClient["_deviceId"]}", Version="${ApiClient["_appVersion"]}", Token="${ApiClient["_serverInfo"]["AccessToken"]}"`
}
}),

json = await res.json();

media[itemId] = json;
Expand All @@ -461,14 +456,10 @@ async function handleVideoPlayback(): Promise<void> {
const videoPlayerElem = document.getElementsByTagName("video")[0];

// this variables content will be replaced in details and status properties on presenceData
let
title,
subtitle;
let title, subtitle;

const
// title on the header
const // title on the header
headerTitleElem = document.querySelector("h3.pageTitle") as HTMLElement,

// title on the osdControls
osdTitleElem = videoPlayerPage.querySelector("h3.osdTitle") as HTMLElement;

Expand All @@ -477,7 +468,9 @@ async function handleVideoPlayback(): Promise<void> {

// no background image, we're playing live tv
if ((videoPlayerElem as HTMLVideoElement).getAttribute("poster")) {
const backgroundImageUrl = (videoPlayerElem as HTMLVideoElement).getAttribute("poster");
const backgroundImageUrl = (videoPlayerElem as HTMLVideoElement).getAttribute(
"poster"
);

mediaInfo = await obtainMediaInfo(backgroundImageUrl.split("/")[4]);
}
Expand Down
48 changes: 48 additions & 0 deletions websites/J/Juniperbot/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "https://schemas.premid.app/metadata/1.0",
"author": {
"name": "MrLivixx",
"id": "502948927809781763"
},
"url": [
"docs.juniper.bot",
"feedback.juniper.bot",
"juniper.bot"
],
"description": {
"ru": "Многофункциональный, полностью настраиваемый бот для платформы Discord, с панелью управления.",
"en": "Fluffy Discord Bot (Music, Ranking, Reminder, Vk Community bridge, WikiFur)"
},
"service": "Juniperbot",
"version": "1.0.0",
"logo": "https://i.imgur.com/YYk1v1F.png",
"thumbnail": "https://i.imgur.com/XOcpBkV.png",
"color": "#C27C0E",
"tags": [
"bot",
"discord",
"juniper",
"juniperbot"
],
"category": "other",
"settings": [
{
"id": "juniper",
"title": "To display the status of actions on juniper.bot",
"icon":"fas fa-lightbulb",
"value": true
},
{
"id": "docs",
"title": "To display the status of actions on docs.juniper.bot",
"icon":"fas fa-lightbulb",
"value": true
},
{
"id": "fback",
"title": "To display the status of actions on feedback.juniper.bot",
"icon":"fas fa-lightbulb",
"value": true
}
]
}
62 changes: 62 additions & 0 deletions websites/J/Juniperbot/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const
presence = new Presence({clientId: "739908991274057870"}),
browsingStamp = Math.floor(Date.now() / 1000);

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {largeImageKey: "logo"},
juniper: boolean = await presence.getSetting("juniper"),
docs: boolean = await presence.getSetting("docs"),
fback: boolean = await presence.getSetting("fback");

if (document.location.hostname == "juniper.bot") {
if(juniper){
presenceData.startTimestamp = browsingStamp;
if (document.location.pathname.includes("/ranking")) {
presenceData.details = "Looks at the server's leaderboard:";
presenceData.state = document.querySelector(".guild--info h1.font-weight-thin.display-2").innerHTML;
presenceData.smallImageKey = "list";
} else if (document.location.pathname.includes("/dashboard/")) {
presenceData.details = "In dashboard";
presenceData.state = `Guild: ${document.querySelector(".guild--info h1.font-weight-thin.display-2").innerHTML}`;
} else if (document.location.pathname.includes("/donate")) {
presenceData.details = "Reads information about the donation";
presenceData.smallImageKey = "donate";
} else if (document.location.pathname == "/") {
presenceData.details = "Main page";
} else if (document.location.pathname == "/servers"){
presenceData.details = "Selects the server";
presenceData.smallImageKey = "list";
} else if (document.location.pathname == "/commands"){
presenceData.details = "Looks at the list of commands";
presenceData.smallImageKey = "list";
} else if (document.location.pathname == "/status"){
presenceData.details = "Looks at the bot's statistics";
presenceData.smallImageKey = "stats";
} else if (document.location.pathname == "/user/card"){
presenceData.details = "Changes the rank card";
}
}
} else if(docs){
if (document.location.hostname == "docs.juniper.bot") {
presenceData.startTimestamp = browsingStamp;
presenceData.details = document.title;
presenceData.state = "docs.juniper.bot";
presenceData.smallImageKey = "list";
}
} else if(fback){
if (document.location.hostname == "feedback.juniper.bot"){
presenceData.startTimestamp = browsingStamp;
presenceData.state = "feedback.juniper.bot";
if (document.location.pathname == "/") {
presenceData.details = "Main page.";
} else if (document.location.pathname.includes("/posts")) {
presenceData.details = `Читает: ${document.querySelector(".post-header h1").innerHTML}`;
}
}}
if (presenceData.details == null) {
presence.setTrayTitle();
presence.setActivity();
} else {
presence.setActivity(presenceData);
}
});
6 changes: 6 additions & 0 deletions websites/J/Juniperbot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}
4 changes: 2 additions & 2 deletions websites/L/letgo/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"author": {
"name": "SinecKers /Yasar",
"name": "SinecKers",
"id": "380411952666640385"
},
"url": [
Expand All @@ -12,7 +12,7 @@
"en": "Letgo is an app which allows yo to buy and sell some stuff to people around you"
},
"service": "letgo",
"version": "1.0.5",
"version": "1.0.6",
"logo": "https://who.is-inside.me/7bDAL2kP.png",
"thumbnail": "https://who.is-inside.me/OAkHvQZ6.png",
"color": "#FF3F56",
Expand Down
Loading

0 comments on commit 16eb4c5

Please sign in to comment.