A Statamic addon that syncs YouTube videos from a channel to your local database and provides Antlers tags to display them.
Manage your YouTube videos directly from the Statamic Control Panel
Features
- π₯ Sync YouTube videos from any channel
- π View video stats (views, likes, duration)
- π·οΈ Easy-to-use Antlers tags for frontend display
- π Manual or automated syncing
- πΎ Local database storage for fast access
- π¨ Clean Control Panel interface
Installation
You can install the package via Composer:
composer require huement/statamic-ytlistr
The package will automatically register itself with Statamic.
Requirements
- PHP ^8.1
- Statamic CMS ^5.0
Configuration
Add these variables to your .env file:
YOUTUBE_API_KEY=your_youtube_api_keyYOUTUBE_CHANNEL_ID=your_youtube_channel_idYOUTUBE_MAX_RESULTS=50
Usage
Sync Videos
Via Control Panel:
- Navigate to Tools > YouTube Listr
- Click "Sync Videos from YouTube"
Via Command Line:
php artisan ytlistr:fetchphp artisan ytlistr:fetch --limit=100
Antlers Tags
Display your YouTube videos beautifully on the frontend
List all videos:
{{ yt_listr }} <h3>{{ title }}</h3> <img src="{{ thumbnail_url }}" alt="{{ title }}"> <p>{{ description }}</p> <a href="{{ youtube_url }}">Watch on YouTube</a>{{ /yt_listr }}
Limit results:
{{ yt_listr limit="5" }} <div>{{ title }}</div>{{ /yt_listr }}
Get latest video:
{{ yt_listr:latest }} <h2>{{ title }}</h2> <iframe src="{{ embed_url }}" frameborder="0" allowfullscreen></iframe>{{ /yt_listr:latest }}
Get video count:
Total videos: {{ yt_listr:count }}
Available Data
Each video provides:
id- Database IDvideo_id- YouTube video IDtitle- Video titledescription- Video descriptionthumbnail_url- Thumbnail image URLpublished_at- Publication dateduration- Duration in secondsduration_formatted- Human-readable duration (MM:SS)view_count- Number of viewslike_count- Number of likescomment_count- Number of commentschannel_id- YouTube channel IDchannel_title- Channel nameyoutube_url- Full YouTube URLembed_url- YouTube embed URL
Credits
Created and sponsored by Huement.com - A software studio creating awesome content and exceptional web experiences.
Links
License
MIT