Skip to content
Permalink
Browse files

Added notice for unsupported services

  • Loading branch information...
Thoulah committed Apr 30, 2019
1 parent 406e9df commit 47872b3b164a943414a55c858b065b98e9685f2c
Showing with 26 additions and 23 deletions.
  1. +13 −13 composer.lock
  2. +9 −4 mister42/commands/LyricsController.php
  3. +4 −6 mister42/models/Video.php

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -119,19 +119,24 @@ public function actionVideos(): int {
foreach ($data as $source => $payload) :
$x = 0;
$function = implode(['check', ucfirst($source)]);
foreach ($payload as $id) :
$ids[] = $id;
if (!isset($ids) || (++$x !== count($data[$source]) && count($ids) < 50))
continue;
$result[$source] = $video->$function($ids, $type);
switch ($source) :
case 'youtube':
$result[$type][] = $video->checkYoutube($ids, $type);
break;
default:
trigger_error("Checking {$source} {$type} is not supported yet.");
endswitch;
unset($ids);
endforeach;
endforeach;
if ((bool) array_product($result) === true) :
if ((bool) array_product($result[$type]) === true) :
Console::write("Completed checking {$type}", [Console::BOLD, Console::FG_GREEN]);
Console::newLine();
endif;
@@ -32,7 +32,7 @@ public static function getUrl(string $source, string $id, bool $isPlaylist = fal
return Yii::t('mr42', 'Sorry, {source} is not supported.', ['source' => $source]);
}
public function checkYoutube(array $data, string $type) {
public function checkYoutube(array $data, string $type): bool {
$result = true;
$request = Webrequest::getYoutubeApi(implode(',', ArrayHelper::getColumn($data, 'id')), $type);
if (!$request->isOK || $request->data['pageInfo']['totalResults'] === 0) :
@@ -42,20 +42,18 @@ public function checkYoutube(array $data, string $type) {
$items = ArrayHelper::index($request->data['items'], 'id');
foreach ($data as $listData) :
$status = ArrayHelper::getValue($items, "{$listData['id']}.status");
if (!ArrayHelper::keyExists($listData['id'], $items, false) || (ArrayHelper::getValue($status, 'privacyStatus') !== 'public' && !ArrayHelper::getValue($status, 'embeddable'))) :
$status = ArrayHelper::getValue($items, "{$listData['id']}.status", false);
if ($status === false || (ArrayHelper::getValue($status, 'privacyStatus') !== 'public' && !ArrayHelper::getValue($status, 'embeddable'))) :
Console::write($listData['name'], [Console::FG_PURPLE], 5);
Console::write(self::getUrl('youtube', $listData['id'], $type === 'playlists'), [Console::FG_PURPLE], 9);
$result = false;
if (!ArrayHelper::keyExists($listData['id'], $items, false))
if ($status === false)
Console::writeError('Not Found', [Console::BOLD, Console::FG_RED, CONSOLE::BLINK]);
elseif (ArrayHelper::getValue($status, 'privacyStatus') !== 'public')
Console::writeError('Not Public', [Console::BOLD, Console::FG_RED, CONSOLE::BLINK]);
elseif (!ArrayHelper::getValue($status, 'embeddable'))
Console::writeError('Not embeddable', [Console::BOLD, Console::FG_RED, CONSOLE::BLINK]);
continue;
endif;
endforeach;

0 comments on commit 47872b3

Please sign in to comment.
You can’t perform that action at this time.