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