Twitter 媒体下载

一键保存视频/图片

< 脚本 Twitter 媒体下载 的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-06-01

添加更多文件重命名标签的方法 | The Way to Add More File Renaming Tags

fetchJson() 函数会返回一个包含很多信息的 JSON,脚本只用了其中一部分,我们可以将 JSON 中的其他信息添加到重命名标签中。因为这个脚本很久没更新了,大家都是用自己改过的,行号可能不一样,所以以下内容都是给出定位的语句,请搜索语句找到位置。这个修改并不难,如果你是完全的小白,遇到不懂的问 AI 就能解决。

  1. 首先要知道函数返回的 JSON 有什么可用的内容。let json = await this.fetchJson(status_id); 这句调用函数获取到完整的 JSON,后面两句 let tweet = ...; let user = ...; 分别提取了推文和用户信息部分,一般用提取的这两个就行了。在这两句后面添加 console.log(tweet);console.log(user); 就能打印对应的内容。保存脚本后,打开有媒体的推文,按 F12 并打开控制台标签,然后点击下载按钮,控制台会打印 JSON 的内容。

  2. 以获取收藏数量为例。可以看到打印的 JSON 的顶层有一个 favorite_count,把它的值加入新标签即可。在刚才的位置下方,有一堆构建标签内容的语句,类似于 info['date-time-local'] = ...。仿照格式,添加你要想要添加的标签,例如 info['fav-count'] = tweet.favorite_count;favorite_count 是前面打印 JSON 中的键名。因为这个在顶层,所以直接写就行了。嵌套的要用 . 访问,例如 entities.hashtags.textfav-count 是重命名模板中用的标签名,取一个你喜欢的名字即可。

  3. 完成上一步就能在重命名模板中使用你添加的标签了,如果想要在设置界面点击按钮就能添加,不用手动输入标签,请完成这一步。搜索 <span class="tmd-tag",能看到有一堆相似的语句写在一起。仿照它们的格式,添加和你加的标签对应的语句即可,例如 <span class="tmd-tag" title="Favorite count of this tweet.">{fav-count}</span>title 后面的文本是鼠标悬浮时显示的内容,不加也行。{fav-count} 是用于重命名模板的标签,要和第 2 步中添加的对应。

The Way to Add More File Renaming Tags

The fetchJson() function returns a JSON containing a lot of information. The script only uses a portion of it. We can add other information from the JSON to the renaming tags. Because this script hasn't been updated for a long time, everyone is using their own modified versions, and the line numbers may be different. Therefore, the following content provides statements for locating the positions. Please search for the statements to find the locations. This modification is not difficult. If you are a complete beginner, you can ask AI for help if you encounter anything you don't understand.

  1. First, you need to know what usable content the JSON returned by the function has. The line let json = await this.fetchJson(status_id); calls the function to get the complete JSON. The following two lines, let tweet = ...; let user = ...;, extract the tweet and user information parts respectively. Generally, using these two extracted parts is sufficient. After these two lines, add console.log(tweet); or console.log(user); to print the corresponding content. After saving the script, open a tweet with media, press F12 and open the console tab, and then click the download button. The console will print the JSON content.

  2. Take getting the number of favorites as an example. You can see that the top level of the printed JSON has a favorite_count. You need to add its value to a new tag. Below the previous location, there is a bunch of statements constructing the tags, similar to info['date-time-local'] = .... Following their format, add the tag you want to add, for example, info['fav-count'] = tweet.favorite_count;. favorite_count is the key name in the JSON printed earlier. Because it is at the top level, you can write it directly. Nested ones should be accessed using ., such as entities.hashtags.text. fav-count is the tag name used in the renaming template. Choose a name you like.

  3. After completing the previous step, you can use the tag you added in the renaming template. If you want to be able to add it by clicking a button in the settings interface without manually entering the tag, please complete this step. Search for <span class="tmd-tag", and you will see a bunch of similar statements written together. Following their format, add the statement corresponding to the tag you added, for example, <span class="tmd-tag" title="Favorite count of this tweet.">{fav-count}</span>. The text after title is the content displayed when hovering the mouse, which is optional. {fav-count} is the tag used for the renaming template, which should correspond to the one added in step 2.

发布留言

登录以发布留言。