Beispiel #1
0
function toDomDoc($data)
{
    $document = new \DOMDocument();
    $previous = libxml_use_internal_errors(true);
    $isLoaded = $document->loadHTML($data);
    libxml_use_internal_errors($previous);
    return $isLoaded ? Either\Right::of($document) : Either\Left::of("Can't load html data from given source");
}
Beispiel #2
0
function download(ChapterPage $chapterPage, $ttl = null)
{
    return liftM3(function ($path, $imageContent, ChapterPage $chapterPage) {
        return writeFile($path . '/' . $chapterPage->getPage()->getName() . '.jpg', $imageContent);
    }, makeDirectory('./manga/' . $chapterPage->getChapter()->getName()), Either\doubleMap(function (Err $error) use($chapterPage) {
        return new ErrChapter($chapterPage, $error);
    }, f\identity, getOnlyImage(getUrl($chapterPage->getPageImage()->getUrl(), $ttl))), Either\Right::of($chapterPage));
}