Stream command helper
This commit is contained in:
parent
497ef179af
commit
019f8a81e4
|
@ -17,7 +17,7 @@ class ListCommand extends Command
|
|||
->setDescription('List available streams.')
|
||||
->addOption('language', null, InputOption::VALUE_REQUIRED, '')
|
||||
->addOption('difficulty', null, InputOption::VALUE_REQUIRED, '')
|
||||
->setHelp("The <info>%command.name%</info> lists live streams");
|
||||
->setHelp('The <info>%command.name%</info> lists live streams');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
|
@ -32,12 +32,40 @@ class ListCommand extends Command
|
|||
if (in_array($language, $languages)) {
|
||||
$language = array_keys($languages, $language)[0];
|
||||
} elseif (!in_array($language, array_keys($languages))) {
|
||||
if ($language !== null) {
|
||||
$output->writeln('<info>language</info> available values:');
|
||||
|
||||
foreach ($liveCoding->getLanguages() as $key => $value) {
|
||||
$output->writeln(sprintf(
|
||||
' <comment>%s</comment> or <comment>%s</comment>',
|
||||
$key,
|
||||
$value
|
||||
));
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
}
|
||||
|
||||
$language = null;
|
||||
}
|
||||
|
||||
if (in_array($difficulty, array_keys($difficulties))) {
|
||||
$difficulty = $difficulties[$difficulty];
|
||||
} elseif (!in_array($difficulty, $difficulties)) {
|
||||
if ($difficulty !== null) {
|
||||
$output->writeln('<info>difficulty</info> available values:');
|
||||
|
||||
foreach ($liveCoding->getDifficulties() as $key => $value) {
|
||||
$output->writeln(sprintf(
|
||||
' <comment>%s</comment> or <comment>%s</comment>',
|
||||
$key,
|
||||
$value
|
||||
));
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
}
|
||||
|
||||
$difficulty = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class LiveCoding
|
|||
$content = file_get_contents($this->app->buildUrl(sprintf(
|
||||
'livestreams/%s%s',
|
||||
$language !== null ? $language.'/' : 'all',
|
||||
$difficulty !== null ? $difficulty.'/' : null
|
||||
$difficulty !== null ? '/'.$difficulty.'/' : null
|
||||
)));
|
||||
|
||||
preg_match_all(
|
||||
|
@ -94,7 +94,7 @@ class LiveCoding
|
|||
|
||||
$stream = new Stream();
|
||||
$stream
|
||||
->setTitle(trim($titleMatch[1]))
|
||||
->setTitle(html_entity_decode(trim($titleMatch[1])))
|
||||
->setViews($viewsMatch[1])
|
||||
->setCountry($countryMatch[1])
|
||||
->setAuthor($authorMatch[1])
|
||||
|
|
Loading…
Reference in a new issue