index.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <link rel="canonical" href="https://jamesfengcao.gitlab.io/uweb/zh/filecap/" />
  7. <link rel="stylesheet" href="../style.css#" type="text/css" />
  8. <title>利用文件预处理预览/查看/播放可下载资源</title>
  9. <script>
  10. function findLang(){
  11. let href = location.href;
  12. for(let i=href.length-1;i>0;i--){
  13. if('/'==href.charAt(i) && '/'==href.charAt(i-3))
  14. return i;
  15. }
  16. return 0;
  17. }
  18. function nav2(page){
  19. let i = findLang();
  20. location.href = location.href.substring(0,i+1)+page;
  21. }
  22. function nav2Lang(lang){
  23. let i = findLang();
  24. let href = location.href;
  25. location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <header class='header'>
  31. <a class="logo" href="javascript:void(0)" onclick="return nav2('index.html#')">首页</a> <a class="logo" href="javascript:void(0)" onclick="return nav2('tags/index.html#')">标签</a>
  32. <a class="logo" href="javascript:void(0)" onclick="return nav2Lang('en')">English</a>
  33. <nav>
  34. </nav>
  35. </header>
  36. <br />
  37. <div class="container">
  38. <h1 class="title">利用文件预处理预览/查看/播放可下载资源
  39. <br>
  40. <span class="subtitle"></span>
  41. </h1>
  42. <ul class="tags">
  43. <li><a href="../tags/termux/index.html#">termux</a> </li>
  44. <li><a href="../tags/curl/index.html#">curl</a> </li>
  45. </ul>
  46. <p>技巧等级:中级</p>
  47. <p>文件预处理配置文件为default.filecap,每行格式如下:<br>
  48. [文件后缀]:[mimetype]:[处理命令]</p>
  49. <p>其中文件后缀可允许最多两段后缀,譬如&quot;txt.xz&quot;,&quot;html.gz&quot;。<br>
  50. mimetype表示命令处理后的输出内容格式。<br>
  51. 处理命令与<a href="../cmd/index.html#">default.cmds</a>相同,主要可能用到如下替换:<br>
  52. %u(网址或文件路径)、%U(编码以后的网址)、%c(当前网址cookie)、%p(密码保护网站中的密码,curl格式)。</p>
  53. <p>利用文件预处理,<a href="../index.html#">超微浏览器</a>现在可以预览/查看/播放一切可下载资源,并且可以利用不同网站在线服务预览不同的文件,而手机上一个应用都不用装。</p>
  54. <p>配置default.filecap如下:</p>
  55. <pre><code>txt:text/html:curl %p "%u"
  56. mp3:text/html:echo '&lt;audio controls width=100% height=100%>&lt;source src="%u">&lt;/audio>'
  57. m4b:text/html:echo '&lt;audio controls width=100% height=100%>&lt;source src="%u">&lt;/audio>'
  58. m3u8:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
  59. mp4:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
  60. mkv:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
  61. doc:uweb:echo https://view.xdocin.com/view?src=%U
  62. xls:uweb:echo https://view.xdocin.com/view?src=%U
  63. ppt:uweb:echo https://view.xdocin.com/view?src=%U
  64. docx:uweb:echo https://view.xdocin.com/view?src=%U
  65. xlsx:uweb:echo https://view.xdocin.com/view?src=%U
  66. pptx:uweb:echo https://view.xdocin.com/view?src=%U
  67. xz:text/plain:curl %p "%u"|xz -d --</code></pre>
  68. <p>安装过相应的<a href="../html5/index.html#">html5应用</a>,则如下配置阅读相应格式文件:</p>
  69. <pre><code>pdf:uweb:echo file:///data/data/info.torapp.uweb/files/app/pdf.js/web/viewer.html?file=%u
  70. djvu:uweb:echo file:///data/data/info.torapp.uweb/files/app/djvu.html?url=%u
  71. epub:uweb:echo file:///data/data/info.torapp.uweb/files/app/reader/index.html#?bookPath==%u</code></pre>
  72. <p>长按设置按钮,勾选“文件预处理”,清后台重启浏览器。则网页上点击下载按钮时上述文件类型会自动预览。</p>
  73. <p>如果用户配置中处理命令用到curl,则需要安装<a href="../gnuplot/index.html#">Termux</a>,并在Termux中安装curl (&quot;apt install curl&quot;)。<br>
  74. 如果用户不安装Termux,则上述配置命令中的&quot;am&quot;需要全部路径,需用&quot;/system/bin/am&quot;替换。</p>
  75. <p>使用微软服务预览office文档 (https://view.officeapps.live.com/op/view.aspx?src=)必需当前UA为PC,否则会出现空白页面。有条件的用户建议使用google docs (&quot;http://docs.google.com/gview?embedded=true&amp;url=&quot;) 服务替换。</p>
  76. <p>若使用手机应用预览文件,则docx处理命令可改为:</p>
  77. <pre>am start --user 0 -a android.intent.action.VIEW -d "%u" -t "application/docx"</pre>
  78. <p>其余常见文件的类型名:<br>
  79. application/msword<br>
  80. application/msexcel<br>
  81. application/pdf</p>
  82. <p>目前已知服务:<br>
  83. google docs, 功能强大,可查看几乎一切文档,但 &quot;我的所爱在山腰,想要得到山太高。&quot;</p>
  84. <p>微软office, 可预览office文档,ua必须是pc。</p>
  85. </div>
  86. <p>Last Modified: 2 April 2024<br>
  87. add js function in README<br>
  88. <pre></pre>
  89. </p>
  90. <script id='jsgiscus'
  91. src='https://giscus.app/client.js'
  92. data-repo="torappinfo/uweb"
  93. data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
  94. data-category="Announcements"
  95. data-category-id="DIC_kwDOEgNLGc4CQjsh"
  96. data-mapping="title"
  97. data-strict="0"
  98. data-reactions-enabled="1"
  99. data-emit-metadata="0"
  100. data-input-position="top"
  101. data-theme="light"
  102. data-lang="en"
  103. data-loading="lazy"
  104. crossorigin="anonymous" async>
  105. </script>
  106. <footer class="site-footer">
  107. <div class="container">
  108. &copy; 2018-2024 Richard H. Cao
  109. </div>
  110. </footer>
  111. <!-- This document is licensed under the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at <https://www.gnu.org/licenses/>. -->
  112. </body>
  113. </html>