Skip to content

Commit

Permalink
fix test & add weibo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan committed Apr 5, 2020
1 parent 5a21b90 commit 827b60e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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";
Expand Down
8 changes: 8 additions & 0 deletions src/cloud_group.ts
Expand Up @@ -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")) {
Expand Down
8 changes: 4 additions & 4 deletions test/cloud_group_test.ts
Expand Up @@ -3,15 +3,15 @@ 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));
});

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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/test_config.ts
Expand Up @@ -7,7 +7,7 @@ export const cloudTest = {
},
dogecloud: {
content: "50468",
url: "https://pl.dogecloud.com",
url: "https://csrc.vcloud.dogecdn.com",
},
weibo: {
content: "IxlhYcJ2X",
Expand Down

0 comments on commit 827b60e

Please sign in to comment.