oreolek
/
news-script
Archived
1
0
Fork 0

Composer PSR-4 autoloader

This commit is contained in:
Alexander Yakovlev 2019-07-29 13:35:32 +07:00
parent b964c061c0
commit 886ea58b45
Signed by: oreolek
GPG Key ID: 1CDC4B7820C93BD3
30 changed files with 367 additions and 581 deletions

15
bot.php
View File

@ -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);

View File

@ -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/"
}
}
}

743
composer.lock generated

File diff suppressed because it is too large Load Diff

13
run.php
View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -1,4 +1,6 @@
<?php
namespace Oreolek;
class Publisher {
public $text;
protected $dry_run = true;

View File

@ -1,4 +1,7 @@
<?php
namespace Oreolek\Publisher;
use \Oreolek\Publisher;
class Jabber extends Publisher {
protected $client;
protected $text;

View File

@ -1,4 +1,7 @@
<?php
namespace Oreolek\Publisher;
use \Oreolek\Publisher;
class Mastodon extends Publisher {
protected $client;

View File

@ -1,4 +1,7 @@
<?php
namespace Oreolek\Publisher;
use \Oreolek\Publisher;
class Telegram extends Publisher {
protected $client;
protected $chat_id;

View File

@ -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

View File

@ -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";

View File

@ -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

View File

@ -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.

View File

@ -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";

View File

@ -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 = "Гиперкнига";

View File

@ -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 = "Гиперкнига";

View File

@ -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";

View File

@ -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 репозиторий";

View File

@ -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";

View File

@ -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 {

View File

@ -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 = "Квестер";

View File

@ -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";

View File

@ -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 = "Сторигеймы";

View File

@ -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;

View File

@ -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 {

View File

@ -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";

View File

@ -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";

View File

@ -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) {

View File

@ -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();