From 08c1f55f4a12eec3ab11e6ac8d767131e4bda162 Mon Sep 17 00:00:00 2001
From: Miika Launiainen <miika.launiainen@proton.me>
Date: Thu, 11 Aug 2022 00:46:17 +0300
Subject: [PATCH] Created Hanime bridge (#2958)

* Created Hanime bridge

* Moved cover image from enclosures to content as dvikan suggested
---
 bridges/HanimeBridge.php | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 bridges/HanimeBridge.php

diff --git a/bridges/HanimeBridge.php b/bridges/HanimeBridge.php
new file mode 100644
index 00000000..61545485
--- /dev/null
+++ b/bridges/HanimeBridge.php
@@ -0,0 +1,34 @@
+<?php
+
+class HanimeBridge extends BridgeAbstract
+{
+    const NAME = 'Hanime';
+    const URI = 'https://hanime.tv';
+    const DESCRIPTION = 'Return recent Hanime.tv hentai video uploads';
+    const MAINTAINER = 'Miicat_47';
+
+    public function collectData()
+    {
+        $html = getSimpleHTMLDOM('https://hanime.tv/')->find('.htv-carousel__scrolls', 0);
+        $html = defaultLinkTo($html, $this->getURI());
+
+        foreach ($html->find('.item') as $video) {
+            $item = [];
+
+            $video_uri = $video->find('.no-touch', 0)->href;
+
+            // Get video cover url
+            // Use regex to get video_uri title
+            $exp = '/\/([A-Za-z\-0-9]+$)/m';
+            preg_match_all($exp, $video_uri, $matches, PREG_SET_ORDER, 0);
+            // Use the video title as name for the cover file
+            $cover = 'https://cdn.statically.io/img/akidoo.top/images/covers/' . $matches[0][1] . '-cv1.png';
+
+            $item['uri'] = $video_uri;
+            $item['title'] = $video->find('.hv-title', 0)->plaintext;
+            $item['content'] = sprintf('<img src="%s">', $cover);
+
+            $this->items[] = $item;
+        }
+    }
+}