diff --git a/src/components/video.tsx b/src/components/video.tsx
index cfa17e4..bfb74cf 100644
--- a/src/components/video.tsx
+++ b/src/components/video.tsx
@@ -1,9 +1,11 @@
-import { formatUrl } from "../utils";
+import { formatUrl, generateRemainderScript } from "../utils";
import { Action, ActionPanel, Color, Icon, Image, List, showToast, Toast } from "@raycast/api";
import { ConclusionView } from "./conslusionView";
import { runAppleScript } from "run-applescript";
+const { Metadata } = List.Item.Detail;
+
export function Video(props: {
title: string;
cover: string;
@@ -25,27 +27,7 @@ export function Video(props: {
}) {
async function addWatchLaterReminder() {
try {
- await runAppleScript(`
- tell application "Reminders"
- try
- get list "Raycast Bilibili"
- set mylist to list "Raycast Bilibili"
- tell mylist
- make new reminder with properties {name:"${props.title} - ${props.uploader.name}", body:"${formatUrl(
- props.url
- )}"}
- end tell
- on error
- make new list with properties {name:"Raycast Bilibili"}
- set mylist to list "Raycast Bilibili"
- tell mylist
- make new reminder with properties {name:"${props.title} - ${props.uploader.name}", body:"${formatUrl(
- props.url
- )}"}
- end tell
- end try
- end tell
- `);
+ await runAppleScript(generateRemainderScript(props.title, props.uploader.name, props.url));
await showToast({
style: Toast.Style.Success,
@@ -65,9 +47,9 @@ export function Video(props: {
`}
metadata={
-
-
-
+
+
-
-
-
+
+
+
{props.stat.highlight && (
-
+
)}
{props.stat.view && (
-
+
)}
{props.stat.coin && (
-
+
)}
{props.stat.view && (
-
+
)}
{props.stat.danmaku && (
-
+
)}
-
-
+
+
}
/>
}
diff --git a/src/notifications.tsx b/src/notifications.tsx
index ea50b30..30493d3 100644
--- a/src/notifications.tsx
+++ b/src/notifications.tsx
@@ -95,7 +95,6 @@ export default async function Command() {
const unNotifies = newNotifications.slice(0, startNotifyIndex);
for (const unNotify of unNotifies) {
- console.log(unNotify);
items.map(async (item) => {
if (item.id_str === unNotify) {
notify(item);
diff --git a/src/searchVideos.tsx b/src/searchVideos.tsx
index 4b846b1..3922fe4 100644
--- a/src/searchVideos.tsx
+++ b/src/searchVideos.tsx
@@ -28,7 +28,6 @@ export default function Command() {
}}
>
{videoResults?.map((item) => {
- console.log(item)
return (
)
-
})}
diff --git a/src/utils/encWbi.ts b/src/utils/encWbi.ts
new file mode 100644
index 0000000..6ef80be
--- /dev/null
+++ b/src/utils/encWbi.ts
@@ -0,0 +1,51 @@
+import got from "got";
+import crypto from "crypto";
+import { Cache } from "@raycast/api";
+
+function getMixinKey(ae: string) {
+ const oe = [
+ 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38,
+ 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36,
+ 20, 34, 44, 52,
+ ];
+ const le = oe.reduce((s, i) => s + ae[i], "");
+
+ return le.slice(0, 32);
+}
+
+function md5(s: string) {
+ return crypto.createHash("md5").update(s, "utf8").digest("hex");
+}
+
+function split(s: string) {
+ const parts = s.split("/");
+ return parts[parts.length - 1].split(".")[0];
+}
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export async function encWbi(params: any) {
+ const cache = new Cache();
+ const cookie = cache.get("cookie") || "{}";
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const resp: any = await got("https://api.bilibili.com/x/web-interface/nav", {
+ headers: {
+ cookie,
+ },
+ }).json();
+ const wbi_img = resp.data.wbi_img;
+ const img_url = wbi_img.img_url || "";
+ const sub_url = wbi_img.sub_url || "";
+ const img_value = split(img_url);
+ const sub_value = split(sub_url);
+ const me = getMixinKey(img_value + sub_value);
+ const wts = Math.floor(Date.now() / 1000);
+
+ params.wts = wts;
+
+ const Ae = Object.entries(params)
+ .map(([key, value]) => `${key}=${value}`)
+ .join("&");
+ const w_rid = md5(Ae + me);
+
+ return { w_rid, wts };
+}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 2eed217..1e215db 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1 +1,2 @@
export * from "./tools";
+export * from "./encWbi";
diff --git a/src/utils/tools.ts b/src/utils/tools.ts
index 9c8fb03..857231c 100644
--- a/src/utils/tools.ts
+++ b/src/utils/tools.ts
@@ -1,7 +1,3 @@
-import got from "got";
-import crypto from "crypto";
-import { Cache } from "@raycast/api";
-
export function formatUrl(url: string) {
return url.replace("http://", "https://").replace(/^\/\//, "https://");
}
@@ -18,52 +14,25 @@ export function formatNumber(number: number | undefined) {
return number ? (number > 9999 ? `${(number / 1000).toFixed(1)}K` : String(number)) : "";
}
-function getMixinKey(ae: string) {
- const oe = [
- 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38,
- 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36,
- 20, 34, 44, 52,
- ];
- const le = oe.reduce((s, i) => s + ae[i], "");
-
- return le.slice(0, 32);
-}
-
-function md5(s: string) {
- return crypto.createHash("md5").update(s, "utf8").digest("hex");
-}
-
-function split(s: string) {
- const parts = s.split("/");
- return parts[parts.length - 1].split(".")[0];
-}
-
-export async function encWbi(params: any) {
- const cache = new Cache();
- const cookie = cache.get("cookie") || "{}";
- const resp: any = await got("https://api.bilibili.com/x/web-interface/nav", {
- headers: {
- cookie,
- },
- }).json();
- const wbi_img = resp.data.wbi_img;
- const img_url = wbi_img.img_url || "";
- const sub_url = wbi_img.sub_url || "";
- const img_value = split(img_url);
- const sub_value = split(sub_url);
- const me = getMixinKey(img_value + sub_value);
- const wts = Math.floor(Date.now() / 1000);
-
- params.wts = wts;
-
- const Ae = Object.entries(params)
- .map(([key, value]) => `${key}=${value}`)
- .join("&");
- const w_rid = md5(Ae + me);
-
- return { w_rid, wts };
-}
-
export function removeEmHTMLTag(str: string) {
return str.replace(/(.+?)<\/em>/g, "$1");
}
+
+export function generateRemainderScript(title: string, uploaderName: string, url: string) {
+ return `
+ tell application "Reminders"
+ try
+ get list "Raycast Bilibili"
+ set mylist to list "Raycast Bilibili"
+ tell mylist
+ make new reminder with properties {name:"${title} - ${uploaderName}", body:"${formatUrl(url)}"}
+ end tell
+ on error
+ make new list with properties {name:"Raycast Bilibili"}
+ set mylist to list "Raycast Bilibili"
+ tell mylist
+ make new reminder with properties {name:"${title} - ${uploaderName}", body:"${formatUrl(url)}"}
+ end tell
+ end try
+ end tell`
+}