Skip to content

Commit

Permalink
Fixes nhentai + hentaifromhell + code cleaning + update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Sep 27, 2017
1 parent dc6d1d2 commit f227362
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 137 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Here's is the list of supported sites for now:
* hentaibox.net
* hentaicomics.pro
* hentaifox.com
* hentaifromhell.org - still buggy
* hentaifromhell.org
* hentai-paradise.fr
* nhentai.net - still buggy
* nhentai.net
* hentaiporns.net
* luscious.net
* myhentaicomics.com
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"guzzlehttp/guzzle": "^6.2",
"tunaabutbul/cloudflare-middleware": "^1.0",
"symfony/console": "^3.2",
"crodas/class-info": "^0.2.3"
"crodas/class-info": "^0.2.3",
"caseyamcl/guzzle_retry_middleware": "^1.0"
},
"require-dev": {
"phpmd/phpmd": "^2.4",
Expand Down
307 changes: 183 additions & 124 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Driver/HBrowse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function getDownloadables()
$i = 0;
$sAccessor = '#main .listTable .listMiddle a';
foreach ($this->getDomParser()->load((string)$oRes->getBody())->find($sAccessor) as $oLink) { //chapters
/**
* @var \DOMElement $oLink
*/
$sLink = $oLink->getAttribute('href');
$oRes = $this->getClient()->request('GET', $sLink);
$oBody = $this->getDomParser()->load((string)$oRes->getBody());
Expand Down
3 changes: 3 additions & 0 deletions src/Driver/HentaiComicsPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function getDownloadables()
$aReturn = [];
$i = 0;
foreach ($this->getDomParser()->load((string)$oRes->getBody())->find('.part-select option') as $oLink) {
/**
* @var \DOMElement $oLink
*/
$sUrl = 'http://www.' . self::DOMAIN . $oLink->getAttribute('value');
foreach ($this->getDomParser()->load($sUrl)->find('.portfolio-normal-width figure a') as $oImg) {
/**
Expand Down
19 changes: 13 additions & 6 deletions src/Driver/HentaiFromHell.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Yamete\Driver;

use Tuna\CloudflareMiddleware;

class HentaiFromHell extends \Yamete\DriverAbstract
{
private $aMatches = [];
Expand All @@ -18,24 +20,29 @@ public function canHandle()

public function getDownloadables()
{
$oRes = $this->getClient([
'cookies' => new \GuzzleHttp\Cookie\FileCookieJar(tempnam('/tmp', __CLASS__)),
'handler' => \Tuna\CloudflareMiddleware::create(),
])->request('GET', $this->sUrl);
$oClient = $this->getClient(['cookies' => new \GuzzleHttp\Cookie\FileCookieJar(tempnam('/tmp', __CLASS__))]);
/**
* @var \GuzzleHttp\HandlerStack $oHandler
*/
$oHandler = $oClient->getConfig('handler');
$oHandler->push(CloudflareMiddleware::create());
$oRes = $oClient->request('GET', $this->sUrl);
$aReturn = [];
$i = 0;
foreach ($this->getDomParser()->load((string)$oRes->getBody())->find('center a') as $oLink) {
/**
* @var \DOMElement $oLink
*/
$sLink = $oLink->getAttribute('href');
preg_match('~^https?://(?<domain>' . strtr(self::DOMAIN, ['.' => '\.']) . ')~', $sLink, $aDomains);
preg_match('~^https?://(?<domain>[^/]+)~', $sLink, $aDomains);
$oRes = $this->getClient()->request('GET', $sLink);
foreach ($this->getDomParser()->load((string)$oRes->getBody())->find('#overflow-wrapper img') as $oImg) {
/**
* @var \DOMElement $oImg
*/
$sFilename = 'http://' . $aDomains[1] . $oImg->getAttribute('src');
$sLink = $oImg->getAttribute('src');
$bHasHost = preg_match('~^https?://(?<domain>[^/]+)~', $sLink);
$sFilename = $bHasHost ? $sLink : 'http://' . $sLink;
$sPath = $this->getFolder() . DIRECTORY_SEPARATOR . str_pad(++$i, 5, '0', STR_PAD_LEFT)
. '-' . basename($sFilename);
$aReturn[$sPath] = $sFilename;
Expand Down
11 changes: 7 additions & 4 deletions src/Driver/HentaiboxNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ public function getDownloadables()

$aReturn = [];
foreach ($this->getDomParser()->load((string)$oRes->getBody())->find('select["name=np2"] option') as $oOption) {
/** @var \DOMElement $oOption */
$sFilename = $this->getDomParser()->load(
/**
* @var \DOMElement $oOption
* @var \DOMElement[] $aImg
*/
$aImg = $this->getDomParser()->load(
(string)$this->getClient()
->request(
'GET',
str_replace('/00', $oOption->getAttribute('value'), $this->sUrl)
)->getBody()
)
->find('td > center > a > img')
->getAttribute('src');
->find('td > center > a > img');
$sFilename = $aImg[0]->getAttribute('src');
$aReturn[$this->getFolder() . DIRECTORY_SEPARATOR . basename($sFilename)] = $sFilename;
}
return $aReturn;
Expand Down
8 changes: 8 additions & 0 deletions src/Driver/NHentai.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Yamete\Driver;

use GuzzleRetry\GuzzleRetryMiddleware;

class NHentai extends \Yamete\DriverAbstract
{
private $aMatches = [];
Expand All @@ -18,6 +20,12 @@ public function canHandle()

public function getDownloadables()
{
$oClient = $this->getClient(['cookies' => new \GuzzleHttp\Cookie\FileCookieJar(tempnam('/tmp', __CLASS__))]);
/**
* @var \GuzzleHttp\HandlerStack $oHandler
*/
$oHandler = $oClient->getConfig('handler');
$oHandler->push(GuzzleRetryMiddleware::factory());
$oRes = $this->getClient()->request('GET', $this->sUrl);
$aReturn = [];
$i = 0;
Expand Down

0 comments on commit f227362

Please sign in to comment.