From 827b60e30c9d076784fd9dbeb6fa7748785c26fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9D=89?= Date: Sun, 5 Apr 2020 17:14:17 +0800 Subject: [PATCH] fix test & add weibo --- main.ts | 2 +- src/cloud_group.ts | 8 ++++++++ test/cloud_group_test.ts | 8 ++++---- test/test_config.ts | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.ts b/main.ts index 88bb3d5..b7dff26 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -// import "dotenv/load.ts"; +import "dotenv/load.ts"; import { Application } from "server/mod.ts"; import { logger } from "mw/logger.ts"; import { cors } from "mw/cors.ts"; diff --git a/src/cloud_group.ts b/src/cloud_group.ts index caa758c..8bee97d 100644 --- a/src/cloud_group.ts +++ b/src/cloud_group.ts @@ -57,6 +57,14 @@ export default async (c: Context) => { .then((resp) => resp.json()) .then((data) => data.result.contents[0].video.urls.f0); return { url, type: "mp4" }; + case "weibo": + url = await fetch(`https://m.weibo.cn/statuses/show?id=${content}`) + .then((resp) => resp.json()) + .then((data) => + data.data.page_info.urls.mp4_720p_mp4.replace("http", "https") + ); + + return { url, type: "mp4" }; default: // 时光的处理 if (content.includes("1098")) { diff --git a/test/cloud_group_test.ts b/test/cloud_group_test.ts index 94946ac..7804377 100644 --- a/test/cloud_group_test.ts +++ b/test/cloud_group_test.ts @@ -3,7 +3,7 @@ import { addr, cloudTest } from "./test_config.ts"; const { test } = Deno; test(async function hcy() { - const url: string = await fetch(`${addr}/cloud/hcy/${cloudTest.hcy.content}`) + const url: string = await fetch(`${addr}/jx?url=${cloudTest.hcy.content}@hcy`) .then((resp) => resp.json()) .then((data) => data.url); assert(url.startsWith(cloudTest.hcy.url)); @@ -11,7 +11,7 @@ test(async function hcy() { test(async function dogecloud() { const url: string = await fetch( - `${addr}/cloud/dogecloud/${cloudTest.dogecloud.content}`, + `${addr}/jx?url=${cloudTest.dogecloud.content}@dogecloud`, ) .then((resp) => resp.json()) .then((data) => data.url); @@ -20,7 +20,7 @@ test(async function dogecloud() { test(async function weibo() { const url: string = await fetch( - `${addr}/cloud/weibo/${cloudTest.weibo.content}`, + `${addr}/jx?url=${cloudTest.weibo.content}@weibo`, ) .then((resp) => resp.json()) .then((data) => data.url); @@ -29,7 +29,7 @@ test(async function weibo() { test(async function _1096() { const url: string = await fetch( - `${addr}/cloud/1096/${cloudTest._1096.content}`, + `${addr}/jx?url=${cloudTest._1096.content}@1096`, ) .then((resp) => resp.json()) .then((data) => data.url); diff --git a/test/test_config.ts b/test/test_config.ts index 1b6d87f..4758c6e 100644 --- a/test/test_config.ts +++ b/test/test_config.ts @@ -7,7 +7,7 @@ export const cloudTest = { }, dogecloud: { content: "50468", - url: "https://pl.dogecloud.com", + url: "https://csrc.vcloud.dogecdn.com", }, weibo: { content: "IxlhYcJ2X",