Отключить описания игр для Itch.io
Игр слишком много, мы не влезаем в ограничения по символам.
This commit is contained in:
parent
fd9f522f46
commit
139a4343d7
4
Game.php
4
Game.php
|
@ -106,13 +106,13 @@ class Game {
|
|||
$output .= " by *".trim($this->author)."*";
|
||||
}
|
||||
}
|
||||
$description = $this->getDescription();
|
||||
$description = trim($this->getDescription());
|
||||
if ($description !== '') {
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$output .= "\n\n > ".$converter->convert($this->getDescription(), 'html', 'markdown_github')."\n";
|
||||
}
|
||||
if (FORMAT === 'HTML') {
|
||||
$output .= "\n<blockquote>".$this->getDescription()."</blockquote>\n";
|
||||
$output .= "\n<blockquote>".$description."</blockquote>\n";
|
||||
}
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$output .= "\n";
|
||||
|
|
|
@ -25,6 +25,7 @@ class Itch extends Source {
|
|||
public $title = "Itch.io";
|
||||
public $queue = [];
|
||||
public $games = [];
|
||||
public $print_description = FALSE;
|
||||
protected function parse_tag($url) {
|
||||
$max_pages = 4; // load 30*4 = 120 latest games
|
||||
for ($i = 1; $i <= $max_pages; $i++) {
|
||||
|
@ -60,7 +61,6 @@ class Itch extends Source {
|
|||
$this->parse_tag("https://itch.io/games/newest/tag-interactive-fiction");
|
||||
$this->queue = array_unique($this->queue);
|
||||
foreach ($this->queue as $game) {
|
||||
echo 'Loading details for '.$game->title.'…'.PHP_EOL;
|
||||
$game_page = $this->get_text($game->url);
|
||||
$this->loadStr($game_page, []);
|
||||
$game = $this->page($game->url);
|
||||
|
@ -90,8 +90,10 @@ class Itch extends Source {
|
|||
return;
|
||||
}
|
||||
if ($data->{'@type'} === 'Product') {
|
||||
if (isset($data->description)) {
|
||||
$game->short_description = $data->description;
|
||||
if ($this->print_description) {
|
||||
if (isset($data->description)) {
|
||||
$game->short_description = $data->description;
|
||||
}
|
||||
}
|
||||
if (isset($data->name)) {
|
||||
$game->title = $data->name;
|
||||
|
@ -107,17 +109,19 @@ class Itch extends Source {
|
|||
$date = str_replace('@', '', $date);
|
||||
$game->date = new \DateTime($date);
|
||||
}
|
||||
$desc = $this->dom->filter('.formatted_description');
|
||||
try {
|
||||
$game->description = trim($desc->first()->html());
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
if (empty($game->short_description)) {
|
||||
$converter = new Pandoc();
|
||||
$description = $converter->convert($game->description, 'html', 'mediawiki');
|
||||
$description = explode(' ',$description);
|
||||
// 50 first words
|
||||
$game->short_description = implode(' ', array_slice($description, 0, 50));
|
||||
if ($this->print_description) {
|
||||
$desc = $this->dom->filter('.formatted_description');
|
||||
try {
|
||||
$game->description = trim($desc->first()->html());
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
if (empty($game->short_description)) {
|
||||
$converter = new Pandoc();
|
||||
$description = $converter->convert($game->description, 'html', 'mediawiki');
|
||||
$description = explode(' ',$description);
|
||||
// 50 first words
|
||||
$game->short_description = implode(' ', array_slice($description, 0, 50));
|
||||
}
|
||||
}
|
||||
return $game;
|
||||
}
|
||||
|
|
Reference in a new issue