Заливка обложек с названиями игры
This commit is contained in:
parent
2850cff90b
commit
ce63ead589
|
@ -42,6 +42,7 @@ class Apero extends Source {
|
|||
$this->loadStr($text);
|
||||
$game = new Game;
|
||||
$game->url = $url;
|
||||
$game->platform = 'Аперо';
|
||||
$game->title = $this->dom->filter('dd')->reduce(function($block) {
|
||||
if ($block->attr('itemprop') === 'name') {
|
||||
return true;
|
||||
|
|
|
@ -7,6 +7,7 @@ use Mediawiki\DataModel\Content;
|
|||
use Mediawiki\DataModel\Title;
|
||||
use Mediawiki\DataModel\PageIdentifier;
|
||||
use Mediawiki\DataModel\Revision;
|
||||
use Cocur\Slugify\Slugify;
|
||||
|
||||
class Wikipage {
|
||||
protected $game;
|
||||
|
@ -32,16 +33,19 @@ class Wikipage {
|
|||
}
|
||||
public function create() {
|
||||
global $config;
|
||||
$slugify = new Slugify();
|
||||
|
||||
$this->makeContent();
|
||||
|
||||
$exists = $this->exists($this->game->title);
|
||||
if (!$config['DUMMY'] && !$exists) {
|
||||
if (!empty($this->game->image)) {
|
||||
$filename = basename($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)) {
|
||||
$image = file_get_contents($this->game->image);
|
||||
file_put_contents($image, $filename);
|
||||
file_put_contents($filename, $image);
|
||||
$this->fileUploader->upload($filename, $filename);
|
||||
unlink($filename);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"league/html-to-markdown": "^4.4",
|
||||
"addwiki/mediawiki-api": "^0.7.2",
|
||||
"symfony/dom-crawler": "^4.0",
|
||||
"symfony/css-selector": "^4.0"
|
||||
"symfony/css-selector": "^4.0",
|
||||
"cocur/slugify": "^3.1"
|
||||
}
|
||||
}
|
||||
|
|
67
composer.lock
generated
67
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9926cb2730d267c41d2f5879b63b3b1d",
|
||||
"content-hash": "125ba2664b1bbb74b3482e01aaaad80b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "addwiki/mediawiki-api",
|
||||
|
@ -204,6 +204,71 @@
|
|||
],
|
||||
"time": "2016-10-03T19:36:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "cocur/slugify",
|
||||
"version": "v3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cocur/slugify.git",
|
||||
"reference": "b2ccf7b735f4f3df3979aef2e1ebf8e19ca772f7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/cocur/slugify/zipball/b2ccf7b735f4f3df3979aef2e1ebf8e19ca772f7",
|
||||
"reference": "b2ccf7b735f4f3df3979aef2e1ebf8e19ca772f7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/framework": "~5.1",
|
||||
"latte/latte": "~2.2",
|
||||
"league/container": "^2.2.0",
|
||||
"mikey179/vfsstream": "~1.6",
|
||||
"mockery/mockery": "~0.9",
|
||||
"nette/di": "~2.2",
|
||||
"phpunit/phpunit": "~4.8|~5.2",
|
||||
"pimple/pimple": "~1.1",
|
||||
"plumphp/plum": "~0.1",
|
||||
"silex/silex": "~1.3",
|
||||
"symfony/config": "~2.4|~3.0",
|
||||
"symfony/dependency-injection": "~2.4|~3.0",
|
||||
"symfony/http-kernel": "~2.4|~3.0",
|
||||
"twig/twig": "~1.26|~2.0",
|
||||
"zendframework/zend-modulemanager": "~2.2",
|
||||
"zendframework/zend-servicemanager": "~2.2",
|
||||
"zendframework/zend-view": "~2.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cocur\\Slugify\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ivo Bathke",
|
||||
"email": "ivo.bathke@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Florian Eckerstorfer",
|
||||
"email": "florian@eckerstorfer.co",
|
||||
"homepage": "https://florian.ec"
|
||||
}
|
||||
],
|
||||
"description": "Converts a string into a slug.",
|
||||
"keywords": [
|
||||
"slug",
|
||||
"slugify"
|
||||
],
|
||||
"time": "2018-01-22T09:00:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.3.0",
|
||||
|
|
Reference in a new issue