Правка парсера Steam и кода обложек
This commit is contained in:
parent
ce63ead589
commit
6a26f8b41f
|
@ -57,6 +57,10 @@ class Steam extends Source {
|
|||
$game->title = trim($game_page->filter('div.apphub_AppName')->first()->text());
|
||||
$game->description = trim($game_page->filter('div.game_description_snippet')->first()->text());
|
||||
$game->author = trim($game_page->filter('div#developers_list')->first()->text());
|
||||
if (strpos($game->author, ',') !== FALSE) {
|
||||
$game->author = explode(',', $game->author);
|
||||
$game->author = array_map('trim', $game->author);
|
||||
}
|
||||
$game->image = $game_page->filter('img.game_header_image_full')->first()->attr('src');
|
||||
$date = $game_page->filter('div.date')->first()->text();
|
||||
$game->date = \DateTime::createFromFormat('d M, Y', $date);
|
||||
|
|
16
Wikipage.php
16
Wikipage.php
|
@ -15,6 +15,7 @@ class Wikipage {
|
|||
protected $services;
|
||||
protected $content;
|
||||
protected $fileUploader;
|
||||
protected $covername;
|
||||
|
||||
public function __construct($game) {
|
||||
global $config;
|
||||
|
@ -35,18 +36,21 @@ class Wikipage {
|
|||
global $config;
|
||||
$slugify = new Slugify();
|
||||
|
||||
if (!empty($this->game->image)) {
|
||||
$filename = preg_replace('/\?.*/', '', basename($this->game->image));
|
||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$this->covername = $slugify->slugify($this->game->title, '_').'.'.$extension;
|
||||
}
|
||||
|
||||
$this->makeContent();
|
||||
|
||||
$exists = $this->exists($this->game->title);
|
||||
if (!$config['DUMMY'] && !$exists) {
|
||||
if (!empty($this->game->image)) {
|
||||
$filename = preg_replace('/\?.*/', '', basename($this->game->image));
|
||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$pagename = $slugify->slugify($this->game->title, '_').$extension;
|
||||
if ($this->services->newPageGetter()->getFromTitle($filename)) {
|
||||
if ($this->services->newPageGetter()->getFromTitle($this->covername)) {
|
||||
$image = file_get_contents($this->game->image);
|
||||
file_put_contents($filename, $image);
|
||||
$this->fileUploader->upload($filename, $filename);
|
||||
$this->fileUploader->upload($this->covername, $filename);
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +100,7 @@ class Wikipage {
|
|||
$this->content .= PHP_EOL.' |вышла='.$date;
|
||||
}
|
||||
$this->txtadd('platform', ' |платформа='.$this->game->platform);
|
||||
$this->txtadd('image', ' |обложка='.basename($this->game->image));
|
||||
$this->txtadd('image', ' |обложка='.$this->covername);
|
||||
|
||||
$this->content .= "\n}}\n";
|
||||
|
||||
|
|
Reference in a new issue