From 29b26bacf4659cbdd71a0fd4e9cb28caf97f1012 Mon Sep 17 00:00:00 2001 From: Jay MOULIN Date: Thu, 28 Sep 2017 22:17:36 +0200 Subject: [PATCH] Use alpine for docker image + add hentai-comics.org Driver --- README.md | 1 + docker/pc/Dockerfile | 7 ++++--- src/Driver/HentaiComics.php | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/Driver/HentaiComics.php diff --git a/README.md b/README.md index 275c63b8..396996f6 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Here's is the list of supported sites for now: * hentai2read.com * hentaibox.net * hentaicomics.pro + * hentai-comics.org * hentaifox.com * hentaifromhell.org * hentai-paradise.fr diff --git a/docker/pc/Dockerfile b/docker/pc/Dockerfile index a59f6605..5874ecd6 100644 --- a/docker/pc/Dockerfile +++ b/docker/pc/Dockerfile @@ -1,12 +1,13 @@ -FROM php:7.0-cli +FROM php:7.0-fpm-alpine COPY . /root WORKDIR /root ENV PATH="/root:$PATH" -RUN apt-get update && apt-get install git zip wget -y && \ +RUN apk add git zip --update --no-cache && \ +apk add wget --virtual .build-deps && \ wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet && \ php composer.phar install --no-dev -o && \ -apt-get remove wget -y +apk del wget --purge .build-deps VOLUME ['/root/downloads'] diff --git a/src/Driver/HentaiComics.php b/src/Driver/HentaiComics.php new file mode 100644 index 00000000..b1bb4ec3 --- /dev/null +++ b/src/Driver/HentaiComics.php @@ -0,0 +1,39 @@ + '\.', '-' => '\-']) . + '/gallery/(?[^/]+)/(?.+)\.html$~', + $this->sUrl, + $this->aMatches + ); + } + + public function getDownloadables() + { + $sFirstPage = "https://" . self::DOMAIN . "/view/{$this->aMatches['id']}/1/{$this->aMatches['album']}.html"; + $oRes = $this->getClient()->request('GET', $sFirstPage); + $aReturn = []; + if (preg_match('~var d=(?[^;]+);~', (string)$oRes->getBody(), $aMatches)) { + foreach (\GuzzleHttp\json_decode($aMatches['json'], true) as $aOption) { + $sFilename = $aOption['chapter_image']; + $sBasename = $this->getFolder() . DIRECTORY_SEPARATOR . basename($sFilename); + $aReturn[$sBasename] = $sFilename; + } + } + return $aReturn; + } + + private function getFolder() + { + return implode(DIRECTORY_SEPARATOR, [self::DOMAIN, $this->aMatches['album']]); + } +}