Action
send to voicenotesai
Posted by hqweay,
Last update
about 13 hours ago
- Unlisted
send your draft to voicenotesai.
before using this script, you should get token and replace it in the Script.
Steps
-
script
// Drafts Voice Note Sender with Tagging (抽象HTTP请求方法) // 配置部分 const VOICENOTES_API_URL = "https://api.voicenotes.com/api"; const API_TOKEN = "your token"; const currentDate = new Date(); const datestr = currentDate.toISOString(); const http = HTTP.create(); // create HTTP object /** * 发送HTTP请求的通用方法 * @param {string} url - 请求URL * @param {string} method - HTTP方法 * @param {object} data - 请求数据 * @param {object} additionalHeaders - 额外的请求头 * @returns {object} 响应数据 */ async function apiRequest(url, method = 'GET', data = null, additionalHeaders = {}) { const options = { url: url, method: method, headers: { 'Authorization': `Bearer ${API_TOKEN}`, 'Content-Type': 'application/json', ...additionalHeaders } }; if (data) { options.data = data; } const response = await http.request(options); if (!response.success) { throw new Error(`HTTP ${response.statusCode}: ${response.error}`); } return response.responseData; } /** * 创建语音笔记 * @param {string} transcript - 笔记内容 * @param {number} recordingType - 录音类型,默认3 * @returns {object} 创建的笔记数据 */ async function createVoiceNote(transcript, recordingType = 3) { const data = { transcript: transcript, recording_type: recordingType, temp_attachment_ids: [], device_info: JSON.stringify({ platform: "iOS", manufacturer: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36", modelName: "Drafts App", deviceType: "Drafts App", osVersion: "Drafts App", appVersion: "Drafts App" }), appVersion: "Drafts App" }; return await apiRequest( `${VOICENOTES_API_URL}/recordings/new`, 'POST', data ); } /** * 为语音笔记打标签 * @param {string} recordingId - 录音ID * @param {string[]} tags - 标签数组,默认包含"drafts" * @returns {object} 更新后的笔记数据 */ async function tagVoiceNote(recordingId, tags = ["drafts"]) { const data = { tags: [...tags, ...draft.tags], message: `From Drafts ${datestr}` }; return await apiRequest( `${VOICENOTES_API_URL}/recordings/${recordingId}`, 'PATCH', data ); } // 主函数 (async () => { try { // 第一步:创建语音笔记 console.log("正在创建语音笔记..."); const createdNote = await createVoiceNote(draft.content); const recordingId = createdNote.recording.id; console.log("创建成功,ID:", recordingId); // 第二步:添加标签 console.log("正在添加标签..."); const taggedNote = await tagVoiceNote(recordingId); console.log("标签添加成功:", taggedNote); //alert(`语音笔记处理完成!\nID: ${recordingId}`); } catch (error) { console.error("操作失败:", error); alert(`操作失败: ${error.message}`); context.fail(); } })();
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.