Composer PSR-4 autoloader
This commit is contained in:
parent
b964c061c0
commit
886ea58b45
15
bot.php
15
bot.php
|
@ -17,9 +17,11 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
require "vendor/autoload.php";
|
||||||
require_once ("vendor/autoload.php");
|
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
use Oreolek\Game;
|
||||||
|
use Oreolek\Source;
|
||||||
|
use Oreolek\Publisher;
|
||||||
use Revolution\Mastodon\MastodonClient;
|
use Revolution\Mastodon\MastodonClient;
|
||||||
use \GuzzleHttp\Client as GuzzleClient;
|
use \GuzzleHttp\Client as GuzzleClient;
|
||||||
use Mremi\UrlShortener\Provider\Bitly\BitlyProvider;
|
use Mremi\UrlShortener\Provider\Bitly\BitlyProvider;
|
||||||
|
@ -29,15 +31,6 @@ $config = Yaml::parse(file_get_contents('config.yml'));
|
||||||
define('STYLE',$config['STYLE']);
|
define('STYLE',$config['STYLE']);
|
||||||
define('FORMAT',$config['FORMAT']);
|
define('FORMAT',$config['FORMAT']);
|
||||||
|
|
||||||
require_once "Game.php";
|
|
||||||
require_once "Source.php";
|
|
||||||
require_once "Publisher.php";
|
|
||||||
require_once "_download.php";
|
|
||||||
|
|
||||||
$loader = new \Aura\Autoload\Loader;
|
|
||||||
$loader->register();
|
|
||||||
$loader->addPrefix('Source', 'Source');
|
|
||||||
$loader->addPrefix('Publisher', 'Publisher');
|
|
||||||
$mastodon = new Publisher\Mastodon($config);
|
$mastodon = new Publisher\Mastodon($config);
|
||||||
$jabber = new Publisher\Jabber($config);
|
$jabber = new Publisher\Jabber($config);
|
||||||
$telegram = new Publisher\Telegram($config);
|
$telegram = new Publisher\Telegram($config);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"require": {
|
"require": {
|
||||||
"aura/autoload": "^2.0",
|
|
||||||
"sabre/xml": "^2.0",
|
"sabre/xml": "^2.0",
|
||||||
"addwiki/mediawiki-api": "^0.7.2",
|
"addwiki/mediawiki-api": "^0.7.2",
|
||||||
"symfony/dom-crawler": "^4.0",
|
"symfony/dom-crawler": "^4.0",
|
||||||
|
@ -18,5 +17,10 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./vendor/bin/phpunit"
|
"test": "./vendor/bin/phpunit"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Oreolek\\": "src/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
743
composer.lock
generated
743
composer.lock
generated
File diff suppressed because it is too large
Load diff
13
run.php
13
run.php
|
@ -17,17 +17,14 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\Yaml\Yaml;
|
|
||||||
|
|
||||||
require "vendor/autoload.php";
|
require "vendor/autoload.php";
|
||||||
require "Game.php";
|
use Symfony\Component\Yaml\Yaml;
|
||||||
require "Source.php";
|
use Oreolek\Game;
|
||||||
|
use Oreolek\Source;
|
||||||
|
|
||||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
$config = Yaml::parse(file_get_contents('config.yml'));
|
||||||
define('STYLE',$config['STYLE']);
|
define('STYLE',$config['STYLE']);
|
||||||
define('FORMAT',$config['FORMAT']);
|
define('FORMAT',$config['FORMAT']);
|
||||||
$loader = new \Aura\Autoload\Loader;
|
|
||||||
$loader->register();
|
|
||||||
$loader->addPrefix('Source', 'Source');
|
|
||||||
|
|
||||||
$parsers = 'all';
|
$parsers = 'all';
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
@ -66,7 +63,7 @@ if ($parsers === 'all') {
|
||||||
function check($classname, $command) {
|
function check($classname, $command) {
|
||||||
global $parsers;
|
global $parsers;
|
||||||
if (is_array($parsers) && in_array($command, $parsers)) {
|
if (is_array($parsers) && in_array($command, $parsers)) {
|
||||||
$cname = 'Source\\'.$classname;
|
$cname = 'Oreolek\\Source\\'.$classname;
|
||||||
(new $cname())->check();
|
(new $cname())->check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
namespace Oreolek;
|
||||||
|
|
||||||
function get_text($url) {
|
class Downloader {
|
||||||
|
public static function get_text($url) {
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt_array($curl, array(
|
curl_setopt_array($curl, array(
|
||||||
CURLOPT_RETURNTRANSFER => 1,
|
CURLOPT_RETURNTRANSFER => 1,
|
||||||
|
@ -28,7 +30,7 @@ function get_text($url) {
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function download($url, $outFile) {
|
public static function download($url, $outFile) {
|
||||||
$options = array(
|
$options = array(
|
||||||
CURLOPT_FILE => fopen($outFile, 'w'),
|
CURLOPT_FILE => fopen($outFile, 'w'),
|
||||||
CURLOPT_TIMEOUT => 28800, // set this to 8 hours so we dont timeout on big files
|
CURLOPT_TIMEOUT => 28800, // set this to 8 hours so we dont timeout on big files
|
||||||
|
@ -40,3 +42,4 @@ function download($url, $outFile) {
|
||||||
curl_exec($ch);
|
curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -16,6 +16,8 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
namespace Oreolek;
|
||||||
|
|
||||||
use \Pandoc\Pandoc;
|
use \Pandoc\Pandoc;
|
||||||
|
|
||||||
class Game {
|
class Game {
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Oreolek;
|
||||||
|
|
||||||
class Publisher {
|
class Publisher {
|
||||||
public $text;
|
public $text;
|
||||||
protected $dry_run = true;
|
protected $dry_run = true;
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Oreolek\Publisher;
|
||||||
|
use \Oreolek\Publisher;
|
||||||
|
|
||||||
class Jabber extends Publisher {
|
class Jabber extends Publisher {
|
||||||
protected $client;
|
protected $client;
|
||||||
protected $text;
|
protected $text;
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Oreolek\Publisher;
|
||||||
|
use \Oreolek\Publisher;
|
||||||
|
|
||||||
class Mastodon extends Publisher {
|
class Mastodon extends Publisher {
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace Oreolek\Publisher;
|
||||||
|
use \Oreolek\Publisher;
|
||||||
|
|
||||||
class Telegram extends Publisher {
|
class Telegram extends Publisher {
|
||||||
protected $client;
|
protected $client;
|
||||||
protected $chat_id;
|
protected $chat_id;
|
|
@ -16,11 +16,11 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek;
|
||||||
|
|
||||||
use \Symfony\Component\DomCrawler\Crawler;
|
use \Symfony\Component\DomCrawler\Crawler;
|
||||||
use \Game;
|
|
||||||
use \GuzzleHttp\Client as GuzzleClient;
|
use \GuzzleHttp\Client as GuzzleClient;
|
||||||
|
use Game;
|
||||||
|
|
||||||
abstract class Source {
|
abstract class Source {
|
||||||
// Title
|
// Title
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Anivisual extends Source {
|
class Anivisual extends Source {
|
||||||
public $title = "Anivisual";
|
public $title = "Anivisual";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Парсер для Apero.ru
|
* Парсер для Apero.ru
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* And here's the problem: there are no publication dates.
|
* And here's the problem: there are no publication dates.
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Gamejolt extends Source {
|
class Gamejolt extends Source {
|
||||||
public $title = "GameJolt";
|
public $title = "GameJolt";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Hyperbook extends Source {
|
class Hyperbook extends Source {
|
||||||
public $title = "Гиперкнига";
|
public $title = "Гиперкнига";
|
|
@ -16,7 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class HyperbookEn extends Hyperbook {
|
class HyperbookEn extends Hyperbook {
|
||||||
public $title = "Гиперкнига";
|
public $title = "Гиперкнига";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class IFDB extends Source {
|
class IFDB extends Source {
|
||||||
public $title = "IFDB";
|
public $title = "IFDB";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Instead extends Source {
|
class Instead extends Source {
|
||||||
public $title = "INSTEAD репозиторий";
|
public $title = "INSTEAD репозиторий";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Instory extends Source {
|
class Instory extends Source {
|
||||||
public $title = "Instory";
|
public $title = "Instory";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
use \Pandoc\Pandoc;
|
use \Pandoc\Pandoc;
|
||||||
|
|
||||||
class Itch extends Source {
|
class Itch extends Source {
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Kvester extends Source {
|
class Kvester extends Source {
|
||||||
public $title = "Квестер";
|
public $title = "Квестер";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Qsp extends Source {
|
class Qsp extends Source {
|
||||||
public $title = "Библиотека QSP";
|
public $title = "Библиотека QSP";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Questbook extends Source {
|
class Questbook extends Source {
|
||||||
public $title = "Сторигеймы";
|
public $title = "Сторигеймы";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
use \Symfony\Component\DomCrawler\Crawler;
|
use \Symfony\Component\DomCrawler\Crawler;
|
||||||
use \GuzzleHttp\Cookie\CookieJar;
|
use \GuzzleHttp\Cookie\CookieJar;
|
||||||
use \GuzzleHttp\Cookie\SetCookie;
|
use \GuzzleHttp\Cookie\SetCookie;
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
use \Symfony\Component\DomCrawler\Crawler;
|
use \Symfony\Component\DomCrawler\Crawler;
|
||||||
|
|
||||||
class Textadventures extends Source {
|
class Textadventures extends Source {
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class Urq extends Source {
|
class Urq extends Source {
|
||||||
public $title = "Библиотека URQ";
|
public $title = "Библиотека URQ";
|
|
@ -16,9 +16,10 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Source;
|
namespace Oreolek\Source;
|
||||||
|
|
||||||
use \Game;
|
use \Oreolek\Game;
|
||||||
|
use \Oreolek\Source;
|
||||||
|
|
||||||
class VNDB extends Source {
|
class VNDB extends Source {
|
||||||
public $title = "VNDB";
|
public $title = "VNDB";
|
|
@ -79,8 +79,8 @@ class Wikipage {
|
||||||
]);
|
]);
|
||||||
if (empty($pagetitle)) {
|
if (empty($pagetitle)) {
|
||||||
echo 'ERROR: Page has no title.';
|
echo 'ERROR: Page has no title.';
|
||||||
var_dump($this->game);
|
print_r($this->game);
|
||||||
die();
|
return;
|
||||||
}
|
}
|
||||||
$exists = $this->exists($pagetitle);
|
$exists = $this->exists($pagetitle);
|
||||||
if (!$config['DRY_RUN'] && !$exists) {
|
if (!$config['DRY_RUN'] && !$exists) {
|
14
wiki.php
14
wiki.php
|
@ -17,17 +17,13 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\Yaml\Yaml;
|
|
||||||
|
|
||||||
require "vendor/autoload.php";
|
require "vendor/autoload.php";
|
||||||
require "Game.php";
|
use Symfony\Component\Yaml\Yaml;
|
||||||
require "Source.php";
|
use Oreolek\Game;
|
||||||
require "Wikipage.php";
|
use Oreolek\Source;
|
||||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
use Oreolek\Wikipage;
|
||||||
$loader = new \Aura\Autoload\Loader;
|
|
||||||
$loader->register();
|
|
||||||
$loader->addPrefix('Source', 'Source');
|
|
||||||
|
|
||||||
|
$config = Yaml::parse(file_get_contents('config.yml'));
|
||||||
if (!isset($argv[1])) {
|
if (!isset($argv[1])) {
|
||||||
echo 'Please provide the direct URL to the game page.'.PHP_EOL;
|
echo 'Please provide the direct URL to the game page.'.PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
Reference in a new issue