Archived
1
0
Fork 0

Новая AXMA.info

This commit is contained in:
Alexander Yakovlev 2020-04-04 19:53:51 +07:00
parent 8679dab6be
commit 8794061ae5
Signed by: oreolek
GPG key ID: 1CDC4B7820C93BD3
3 changed files with 78 additions and 17 deletions

View file

@ -32,7 +32,8 @@ class Collect extends Command
//'Hyperbook',
//'HyperbookEn',
//'Apero',
'Questbook',
//'Questbook',
'Axma',
/*
'Textadventures',
'IFDB',

View file

@ -88,9 +88,19 @@ abstract class Source {
$dbmodel = Game::where('source', $game->source)
->where('source_id', $game->source_id)
->first();
if ($dbmodel) {
return $dbmodel;
}
}
if (is_null($dbmodel) && isset($game->url)) {
$dbmodel = Game::where('source', $game->source)
->where('url', $game->url)
->first();
}
if (is_null($dbmodel) && isset($game->title)) {
$dbmodel = Game::where('source', $game->source)
->where('title', $game->title)
->first();
}
if ($dbmodel) {
return $dbmodel;
}
return $game;
}

View file

@ -19,27 +19,77 @@
namespace App\Sources;
use \App\Models\Game;
use \App\Models\Platform;
use \App\Models\Language;
use \App\Models\Author;
use \App\Models\Tag;
use \App\Source;
use Log;
class Axma extends Source {
public $title = "Библиотека AXMA (самая новая)";
protected $games = array();
public $keyword = 'axma';
protected $rootUrl = 'https://axma.info/library/';
protected $games = array();
protected $urls = [];
public function parse() {
$i = 0;
$text = $this->get_text('https://axma.info/library/?sort=last&from='.$i);
$this->loadStr($text);
unset($text);
$this->dom->filter("#listPubs h3 a")->each(function($link) {
$game = new Game;
$game->title = $link->text();
$game->url = $link->attr('href');
$game->url = str_replace('file', $this->rootUrl.'/comments.php?id=', $game->url);
$this->saveGame($game);
});
$i += 5;
}
public function checkPage($url) {
return (strpos($url,$this->rootUrl) !== FALSE);
}
$this->dom->filter(".entry.page .entry-content a")->each(function($link) {
if ($link->filter('h5')->count() === 0) {
return;
}
$url = $link->attr('href');
$game = new Game();
$game->url = $url;
$text = $link->filter('h5')->text();
$version = $link->filter('h5 span.version')->text();
$author = $link->filter('h5 span.author')->text();
$text = str_replace($version, '', $text);
$text = str_replace($author, '', $text);
$game->title = trim($text);
$game = $this->findGame($game);
if ($link->nextAll()->filter('div a .coverlib')->count() > 0) {
$cover = $link->nextAll('div a .coverlib')->first();
$cover = $cover->attr('src');
if (!empty($cover)) {
$game->image_url = 'https://axma.info'.$cover;
}
}
$link->nextAll()->filter('div.small')->each(function($div) use(&$game) {
$style = $div->attr('style');
if ($style !== 'float:right;') {
return;
}
if (!empty($game->release_date)) {
return;
}
$time = \DateTime::createFromFormat('d.m.y', $div->text());
if ($time) {
$game->release_date = $time;
}
});
$game->description = $link->nextAll()->filter('a div.subtitle')->text();
if ($game->save() && !empty($author)) {
$author_model = Author::findByName($author);
if (empty($author_model)) {
$author_model = new Author();
$author_model->name = $author;
$author_model->save();
}
if (!$game->authors()->where('name', $author)->exists()) {
$game->authors()->attach($author_model);
}
}
});
$i += 5;
}
public function checkPage($url) {
return (strpos($url,$this->rootUrl) !== FALSE);
}
}