This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
206 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "@luooooob" | ||
} | ||
"extends": "@luooooob" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
import axios from "axios"; | ||
import * as vscode from "vscode"; | ||
import type { BilibiliDynamic, BilibiliDynamicsResponse, RequstOptions } from "./types"; | ||
import axios from "axios" | ||
import * as vscode from "vscode" | ||
import type { BilibiliDynamic, BilibiliDynamicsResponse, RequstOptions } from "./types" | ||
|
||
export const requestDynamics = async (bid: number): Promise<BilibiliDynamicsResponse> => { | ||
const url = `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${bid}`; | ||
const url = `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${bid}` | ||
return axios | ||
.get(url) | ||
.then(res => res.data); | ||
}; | ||
.then(res => res.data) | ||
} | ||
|
||
export const getDynamicsFromResponse = (res: BilibiliDynamicsResponse, nickname?: string): BilibiliDynamic[] => { | ||
return res.data.cards.map(card => { | ||
const { type, dynamic_id_str, user_profile } = card.desc; | ||
const dynamicId = dynamic_id_str; | ||
const { type, dynamic_id_str, user_profile } = card.desc | ||
const dynamicId = dynamic_id_str | ||
|
||
const { uname } = user_profile.info; | ||
const name = nickname || uname; | ||
const isVideo = type === 8 || type === 16; | ||
const isArticle = type === 64; | ||
const { uname } = user_profile.info | ||
const name = nickname ?? uname | ||
const isVideo = type === 8 || type === 16 | ||
const isArticle = type === 64 | ||
const message = isVideo | ||
? `${name}投稿了新视频` | ||
: isArticle | ||
? `${name}投稿了新专栏` | ||
: `${name}有了新动态`; | ||
: `${name}有了新动态` | ||
|
||
const commands: vscode.Command[] = [{ | ||
title: "前往动态", | ||
command: "vscode.open", | ||
arguments: [vscode.Uri.parse(`https://t.bilibili.com/${dynamic_id_str}`)] | ||
}]; | ||
return { dynamicId, message, commands }; | ||
}); | ||
}; | ||
|
||
}] | ||
return { dynamicId, message, commands } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import axios from "axios"; | ||
import * as vscode from "vscode"; | ||
import type { DouyinVideo, DouyinVideosResponse } from "./types"; | ||
import axios from "axios" | ||
import * as vscode from "vscode" | ||
import type { DouyinVideo, DouyinVideosResponse } from "./types" | ||
|
||
export const requestVideos = async (did: string): Promise<DouyinVideosResponse> => { | ||
const url = `https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=${did}`; | ||
const url = `https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=${did}` | ||
return axios | ||
.get(url) | ||
.then(res => res.data); | ||
}; | ||
.then(res => res.data) | ||
} | ||
|
||
export const getVideosFromResponse = (res: DouyinVideosResponse, nickname?: string): DouyinVideo[] => { | ||
return res.aweme_list.map(aweme => { | ||
const { aweme_id, author } = aweme; | ||
const videoId = aweme_id; | ||
const name = nickname || author.nickname; | ||
const { aweme_id, author } = aweme | ||
const videoId = aweme_id | ||
const name = nickname ?? author.nickname | ||
|
||
const message = `${name} 投稿了新抖音短视频`; | ||
const message = `${name} 投稿了新抖音短视频` | ||
const commands: vscode.Command[] = [{ | ||
title: "前往视频", | ||
command: "vscode.open", | ||
arguments: [vscode.Uri.parse(`https://www.douyin.com/video/${aweme_id}`)] | ||
}]; | ||
return { videoId, message, commands }; | ||
}); | ||
}; | ||
}] | ||
return { videoId, message, commands } | ||
}) | ||
} |
Oops, something went wrong.