-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideoHelper.js
More file actions
145 lines (137 loc) · 4.51 KB
/
videoHelper.js
File metadata and controls
145 lines (137 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// always-run-in-app: true; icon-color: purple;
// icon-glyph: download; share-sheet-inputs: plain-text;
const _info = {
name: 'videoHelper',
version: '1.5',
updated_at: '2025-05-09 12:00:00',
author: 'raoyc',
description: 'download video from Chinese pop short-video apps, such as douyin, kuaishou, weibo and so on',
repo_file_url: 'https://github.com/ycrao/scripts-for-scriptable/blob/main/app/videoHelper.js',
raw_file_url: ' https://raw.githubusercontent.com/ycrao/scripts-for-scriptable/main/app/videoHelper.js'
}
const $http = importModule("http.module")
// 解析接口存活时间都比较短,现均已失效,没办法直接 WebView 内嵌 第三方网站
async function fetchVideo(clip) {
const re = /(http|https):\/\/([a-zA-Z0-9.:?=&-/%#]+)/g
const result = clip.match(re)
console.log(result)
if (result != null && result[0] !== undefined) {
console.log('get url success')
}
const wv = new WebView()
wv.loadURL('https://dy.kukutool.com/')
wv.present()
}
// 该接口已也失效,并改名为 _fetchVideo3,之前仅支持 `抖音` 与 `tiktok` 2个平台无水印视频下载,
/*
async function fetchVideo3(clip) {
const re = /(http|https):\/\/([a-zA-Z0-9.:?=&-/%#]+)/g
const result = clip.match(re)
console.log(result)
if (result != null && result[0] !== undefined) {
const dyUrl = result[0]
const apiUrl = "https://www.tikdd.cc/g1.php"
let param = {
url: dyUrl,
count: 12,
cursor: 0,
web:1,
hd:1
}
json = await $http.postForm(apiUrl, param).loadJSON()
console.log(json)
if (json.code == 0) {
let videoUrl = json.data.play
const cb = new CallbackURL("shortcuts://x-callback-url/run-shortcut")
cb.addParameter("name", "下载文件")
cb.addParameter("input", "text")
cb.addParameter("text", videoUrl)
cb.open()
notify("VideoHelper", "Please select file path to download/请选择路径下载")
return
}
}
}
*/
// 该接口已也失效,并改名为 _fetchVideo2
/*
async function _fetchVideo2(clip) {
const re = /(http|https):\/\/([a-zA-Z0-9.:?=&-/%#]+)/g
const result = clip.match(re)
console.log(result)
if (result != null && result[0] !== undefined) {
const dyUrl = result[0]
const apiUrl = "https://api.iculture.cc/api/video/"
json = await $http.req("get", apiUrl, {url: dyUrl}).loadJSON()
console.log(json)
if (json.code === 200) {
let videoUrl = json.url
if (videoUrl.startsWith("//")) {
videoUrl = "https:" + videoUrl
}
const cb = new CallbackURL("shortcuts://x-callback-url/run-shortcut")
cb.addParameter("name", "下载文件")
cb.addParameter("input", "text")
cb.addParameter("text", videoUrl)
cb.open()
notify("VideoHelper", "Please select file path to download/请选择路径下载")
// Safari.open(videoUrl)
return
}
} else {
notify("VideoHelper", "Invalid URL/无效URL")
}
}
*/
// 该接口已失效 抖音/快手/火山/微博/虎牙/轻视频/梨视频/皮皮虾/皮皮搞笑/微视/最右/VUE Vlog/新片场/度小视/六间房/acfun
/*
async function _fetchVideo(clip) {
const re = /(http|https):\/\/([a-zA-Z0-9.:?=&-/%#]+)/g
const result = clip.match(re)
console.log(result)
if (result != null && result[0] !== undefined) {
const dyUrl = result[0]
const apiUrl = "https://api.xcboke.cn/api/juhe"
json = await $http.req("get", apiUrl, {url: dyUrl}).loadJSON()
console.log(json)
if (json.code === 200) {
let videoUrl = json.data.url
if (videoUrl.startsWith("//")) {
videoUrl = "https:" + videoUrl
}
const cb = new CallbackURL("shortcuts://x-callback-url/run-shortcut")
cb.addParameter("name", "下载文件")
cb.addParameter("input", "text")
cb.addParameter("text", videoUrl)
cb.open()
notify("VideoHelper", "Please select file path to download/请选择路径下载")
// Safari.open(videoUrl)
return
}
} else {
notify("VideoHelper", "Invalid URL/无效URL")
}
}
*/
async function notify(title, body, url) {
let notification = new Notification()
notification.title = title
notification.body = body
if (url) {
notification.openURL = url
}
return await notification.schedule()
}
let clip = Pasteboard.pasteString()
if (clip == null) {
const texts = args.plainTexts
if (texts.length > 0) {
clip = texts[0]
} else {
notify("VideoHelper", "Invalid source/无效来源")
}
}
await fetchVideo(clip + "")
Script.complete()