Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
alaouy authored Jul 11, 2024
2 parents 20ca485 + 72a2a6f commit fa398db
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 101 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
# To detect any changes on the API we run the test suite every week on Mondays.
- cron: '0 7 * * MON'


jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.1', '7.2', '7.3', '8.0', '8.1', '8.2']

env:
YOUTUBE_API_KEY: ${{secrets.YOUTUBE_API_KEY}}

name: Testing on PHP ${{ matrix.php-versions }}
steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: ./vendor/bin/phpunit
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
YouTube
=========

![Travis YouTube Build](https://api.travis-ci.org/alaouy/Youtube.svg?branch=master) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/alaouym)
[![YouTube Tests](https://github.com/alaouy/YouTube/actions/workflows/tests.yml/badge.svg)](https://github.com/alaouy/YouTube/actions/workflows/tests.yml) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/malaouy)

Laravel PHP Facade/Wrapper for the YouTube Data API v3 ( Non-OAuth )

Expand All @@ -11,45 +11,45 @@ Laravel PHP Facade/Wrapper for the YouTube Data API v3 ( Non-OAuth )
- Laravel 5.1 or higher
- API key from [Google Console](https://console.developers.google.com)

Looking for YouTube Package for either of these: PHP 5, Laravel 5.0, Laravel 4? Visit the [`php5-branch`](https://github.com/alaouy/Youtube/tree/php5)
Looking for YouTube Package for either of these: PHP 5, Laravel 5.0, Laravel 4? Visit the [`php5-branch`](https://github.com/alaouy/YouTube/tree/php5)

## Installation

Run in console below command to download package to your project:
```
```bash
composer require alaouy/youtube
```

## Configuration

In `/config/app.php` add YoutubeServiceProvider (Laravel < 5.5):
```
```php
Alaouy\Youtube\YoutubeServiceProvider::class,
```

Do not forget to add also YouTube facade there (Laravel < 5.5):
```
```php
'Youtube' => Alaouy\Youtube\Facades\Youtube::class,
```

Publish config settings:
```
```bach
$ php artisan vendor:publish --provider="Alaouy\Youtube\YoutubeServiceProvider"
```

Set your YouTube API key in the file:

```
```shell
/config/youtube.php
```

Or in the .env file
```
```shell
YOUTUBE_API_KEY = KEY
```

Or you can set the key programmatically at run time :
```
```php
Youtube::setApiKey('KEY');
```

Expand All @@ -68,9 +68,6 @@ $videoList = Youtube::getVideoInfo(['rie-hPVJ7Sw','iKHTawgyKWQ']);
// Get localized video info
$video = Youtube::getLocalizedVideoInfo('vjF9GgrY9c0', 'pl');

// Get multiple videos related to a video
$relatedVideos = Youtube::getRelatedVideos('iKHTawgyKWQ');

// Get comment threads by videoId
$commentThreads = Youtube::getCommentThreadsByVideoId('zwiUB_Lh3iA');

Expand All @@ -91,6 +88,9 @@ $videoList = Youtube::listChannelVideos('UCk1SpWNzOs4MYmr0uICEntg', 40);

$results = Youtube::searchAdvanced([ /* params */ ]);

// Get channel data by channel handle (like https://www.youtube.com/@google), return an STD PHP object
$channel = Youtube::getChannelByHandle('google');

// Get channel data by channel name, return an STD PHP object
$channel = Youtube::getChannelByName('xdadevelopers');

Expand Down Expand Up @@ -129,7 +129,7 @@ $videoId = Youtube::parseVidFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk
];
```

You can use the bail rule in conjunction with this in order to prevent unnecessary queries.
You can use the bail rule in conjunction with this in order to prevent unnecessary queries.

## Basic Search Pagination

Expand Down Expand Up @@ -238,6 +238,6 @@ Please read the ["Reference" section](https://developers.google.com/youtube/v3/d
## Donation
If you find this project to be of use to you please consider buying me a cup of tea :)

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/alaouym)
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/malaouy)
## Credits
Built on code from Madcoda's [php-youtube-api](https://github.com/madcoda/php-youtube-api).
4 changes: 1 addition & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
stopOnFailure="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
Expand Down
Loading

0 comments on commit fa398db

Please sign in to comment.