Mayx's Home Page https://mabbs.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.8 KiB

  1. ---
  2. layout: post
  3. title: 如何下载Iwara上的视频?
  4. tags: [Iwara, PHP, 视频]
  5. ---
  6. PHP果然是全世界最好的语言,我又用PHP解决了一个问题!<!--more-->
  7. # 制作原因
  8. Iwara(Ecchi)上的视频是真的有意思,尤其是镇站之宝OBSERVATION DIARY,简直是R183D动画的巅峰 ~~(请原谅我的孤陋寡闻)~~ ,所以为了更好的看Iwara上的的视频,我写了Iwara Viewer来帮助我们下载Iwara(Ecchi)上面的视频。
  9. # Code
  10. ```php
  11. <?php
  12. if ( $_GET["ID"] == '' ) {
  13. if ( $_GET["page"] == '' ) {
  14. $_GET["page"] = 0;
  15. }
  16. if ( $_GET["sort"] == '' ) {
  17. $_GET["sort"] = "date";
  18. }
  19. $url = 'https://ecchi.iwara.tv/videos?page='.$_GET["page"].'&sort='.$_GET["sort"];
  20. $str = file_get_contents($url);
  21. $preg='/<a href="\/videos\/(.*?)".*?>(.*?)<\/a>/is';
  22. preg_match_all($preg,$str,$match);//在$str中搜索匹配所有符合$preg加入$match中
  23. echo "<title>Mayx Iwara Viewer</title>";
  24. echo "<h1>Mayx Iwara Viewer</h1><br />Sort by: <a href=\"?page=".$_GET["page"]."&sort=date\">Date</a> <a href=\"?page=".$_GET["page"]."&sort=views\">Views</a> <a href=\"?page=".$_GET["page"]."&sort=likes\">Likes</a><hr /><table border=\"1\"><tr>";
  25. $j=0;
  26. for($i=0;$i<count($match[0]);$i++)//逐个输出超链接地址
  27. {
  28. if (($i % 2) == $j) {
  29. if ( $match[1][$i] == $match[1][$i+1] ) {
  30. echo "<td><a href=\"https://ecchi.iwara.tv/videos/".$match[1][$i]."\">".$match[2][$i]."</a></td>";
  31. } else {
  32. echo "<td><a href=\"https://ecchi.iwara.tv/videos/".$match[1][$i]."\">No Image</a></td><td>".$match[2][$i]."</td><td><a href=\"https://ecchi.iwara.tv/videos/".$match[1][$i]."\">View in Iwara</a><br><a href=\"?ID=https://ecchi.iwara.tv/videos/".$match[1][$i]."\">Download Url in Server</a></td></tr><tr>";
  33. if ($j == 0) {
  34. $j = 1;
  35. } else {
  36. $j = 0;
  37. }
  38. }
  39. } else {
  40. echo "<td>".$match[2][$i]."</td><td><a href=\"https://ecchi.iwara.tv/videos/".$match[1][$i]."\">View in Iwara</a><br><a href=\"?ID=https://ecchi.iwara.tv/videos/".$match[1][$i]."\">Download Url in Server</a></td></tr><tr>";
  41. }
  42. }
  43. echo "</tr></table><hr><a href=\"?page=".($_GET["page"] + 1)."&sort=".$_GET["sort"]."\" >Next Page</a>";
  44. } else {
  45. $data = file_get_contents('https://ecchi.iwara.tv/api/video/'.trim(strrchr($_GET["ID"], '/'),'/'));
  46. $file = json_decode($data,true);
  47. echo "Download URL:<br>https:";
  48. echo $file[0]['uri'];
  49. }
  50. ```
  51. (2019.4.18 更新:解决了部分没有图片而导致错位的问题)
  52. (2019.4.18 更新:解决了由于智障导致的图片被筛掉的问题,但是并不保证会不会再出现问题)
  53. # 使用方法
  54. 除了比Iwara更简陋,其他的没什么太大的区别,增加了一个Download Url in Server的选项,用来帮助在服务器上直接下载视频(因为Iwara通过识别IP来防盗链……),得出的链接可直接在服务器上下载(比如用KodExplorer),在服务器上下载的速度还是很不错的。
  55. 不过有的时候Iwara图片服务器也会被Ban(比如移动网),这时候就应该用到[miniProxy](https://github.com/joshdick/miniProxy)了(当然代码也得改,就是我太懒了,懒得改2333)
  56. # 缺点
  57. 没有观看数/作者等信息、而且不知道Iwara的服务器在哪里,用这个速度浏览的速度也不会有太大提升……
  58. # 演示
  59. <https://counter.mayx.me/iwaraview.php>
  60. 如需用演示站下载,可复制地址,然后用Download Tool下载(因为演示站的IP和你的服务器IP不同):
  61. ```php
  62. <h1>Mayx Iwara Video Download Tool</h1><form action="iwara.php" method="get" >
  63. Video URL: <input type="text" name="ID"><br>
  64. <input type="submit">
  65. </form>
  66. <br>
  67. <?php
  68. if ( $_GET["ID"] != '' ) {
  69. $data = file_get_contents('https://ecchi.iwara.tv/api/video/'.trim(strrchr($_GET["ID"], '/'),'/'));
  70. $file = json_decode($data,true);
  71. echo "Download URL:<br>https:";
  72. echo $file[0]['uri'];
  73. }
  74. ?>
  75. ```

Powered by TurnKey Linux.