1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of dispositif/wikibot application (@github) |
5
|
|
|
* 2019-2023 © Philippe M./Irønie <[email protected]> |
6
|
|
|
* For the full copyright and MIT license information, view the license file. |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace App\Application; |
11
|
|
|
|
12
|
|
|
use App\Application\InfrastructurePorts\PageListForAppInterface as PageListInterface; |
13
|
|
|
use App\Domain\Transformers\GoogleTransformer; |
14
|
|
|
use App\Infrastructure\GoogleApiQuota; |
15
|
|
|
use App\Infrastructure\GoogleBooksAdapter; |
16
|
|
|
use Mediawiki\Api\MediawikiFactory; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Parse and transform Google Books URL. |
20
|
|
|
*/ |
21
|
|
|
class GoogleBooksWorker extends AbstractBotTaskWorker |
22
|
|
|
{ |
23
|
|
|
final public const SLEEP_AFTER_EDITION = 60; |
24
|
|
|
final public const TASK_BOT_FLAG = true; |
25
|
|
|
final public const ARTICLE_ANALYZED_FILENAME = __DIR__.'/resources/gooBot_edited.txt'; |
26
|
|
|
final public const SKIP_LASTEDIT_BY_BOT = false; |
27
|
|
|
final public const SKIP_NOT_IN_MAIN_WIKISPACE = true; |
28
|
|
|
final public const SKIP_ADQ = false; |
29
|
|
|
|
30
|
|
|
protected $modeAuto = true; |
31
|
|
|
protected GoogleTransformer $transformer; |
32
|
|
|
|
33
|
|
|
public function __construct( |
34
|
|
|
WikiBotConfig $bot, |
35
|
|
|
MediawikiFactory $wiki, |
36
|
|
|
?PageListInterface $pagesGen = null |
37
|
|
|
) |
38
|
|
|
{ |
39
|
|
|
$this->transformer = new GoogleTransformer(new GoogleApiQuota(), new GoogleBooksAdapter(), $bot->getLogger()); |
40
|
|
|
parent::__construct($bot, $wiki, $pagesGen); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function processWithDomainWorker(string $title, string $text): ?string |
44
|
|
|
{ |
45
|
|
|
return $this->transformer->process($text); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
|
|
54
|
|
|
|
55
|
|
|
|
56
|
|
|
|