curl on https://jamesfengcao.gitee.io/uwebzh/tags/curl/ Recent content in curl on Hugo -- gohugo.io en-us Mon, 24 Aug 2020 00:00:00 +0000 利用文件预处理预览/查看/播放一切可下载资源 https://jamesfengcao.gitee.io/uwebzh/filecap/ Mon, 24 Aug 2020 00:00:00 +0000 https://jamesfengcao.gitee.io/uwebzh/filecap/ 技巧等级:中级 文件预处理配置文件为/sdcard/uweb/default.filecap,每行格式如下: [文件后缀]:[mimetype]:[处理命令] 其中文件后缀可允许最多两段后缀,譬如"txt.xz","html.gz"。 mimetype表示命令处理后的输出内容格式。 处理命令与default.cmds相同,主要可能用到如下替换: %u(网址或文件路径)、%U(编码以后的网址)、%c(当前网址cookie)、%p(密码保护网站中的密码,curl格式)。 利用文件预处理,超微浏览器现在可以预览/查看/播放一切可下载资源,并且可以利用不同网站在线服务预览不同的文件,而手机上一个应用都不用装。 配置/sdcard/uweb/default.filecap如下: txt:text/html:curl %p "%u" mp3:text/html:echo '<audio controls width=100% height=100%<source src="%u"</audio' m4b:text/html:echo '<audio controls width=100% height=100%<source src="%u"</audio' m3u8:text/html:echo '<video controls width=100% height=100%<source src="%u"</video' mp4:text/html:echo '<video controls width=100% height=100%<source src="%u"</video' mkv:text/html:echo '<video controls width=100% height=100%<source src="%u"</video' doc:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U xls:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U ppt:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U docx:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U xlsx:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U pptx:uweb:echo https://view.officeapps.live.com/op/view.aspx?src=%U xz:text/plain:curl %p "%u"|xz -d -- 安装过相应的html5应用,则如下配置阅读相应格式文件: pdf:uweb:echo file:///sdcard/uweb/app/pdf.js/web/viewer.html?file=%u djvu:uweb:echo file:///sdcard/uweb/app/djvu.html?url=%u epub:uweb:echo file:///sdcard/uweb/app/reader/index.html?bookPath==%u 长按设置按钮,勾选“文件预处理”,清后台重启浏览器。则网页上点击下载按钮时上述文件类型会自动预览。 如果用户配置中处理命令用到curl,则需要安装Termux,并在Termux中安装curl ("apt install curl")。