Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

christophrumpel/larastreamers

238 stars
2 code files
View christophrumpel/larastreamers on GitHub

app/Jobs/ImportYoutubeChannelStreamsJob.php

Open in GitHub
use App\Facades\Youtube;
use App\Models\Stream;
use App\Services\Youtube\StreamData;
 
class ImportYoutubeChannelStreamsJob
{
public function __construct(public string $youtubeChannelId, public string $languageCode = 'en')
{}
 
public function handle(): void
{
$streams = Youtube::upcomingStreams($this->youtubeChannelId);
 
$streams->map(function(StreamData $streamData) {
Stream::updateOrCreate(['youtube_id' => $streamData->videoId], [
'youtube_id' => $streamData->videoId,
'title' => $streamData->title,
'description' => $streamData->description,
'channel_title' => $streamData->channelTitle,
'thumbnail_url' => $streamData->thumbnailUrl,
'scheduled_start_time' => $streamData->plannedStart,
'language_code' => $this->languageCode,
'status' => $streamData->status,
]);
});
}
}

app/Console/Commands/ImportChannelStreamsCommand.php

Open in GitHub
use App\Jobs\ImportYoutubeChannelStreamsJob;
use App\Models\Channel;
use Illuminate\Console\Command;
 
class ImportChannelStreamsCommand extends Command
{
public function handle(): int
{
Channel::all()->each(function(Channel $channel) {
dispatch(new ImportYoutubeChannelStreamsJob($channel->platform_id, $channel->language_code));
});
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.