@meumobi/ngx-youtube-provider
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@meumobi/ngx-youtube-provider

A angular service to fetch Youtube channel videos, playlists and latest videos.

Dependencies

  • apiKey: YouTube Data API v3 key, generated here
  • apiURL: https://www.googleapis.com/youtube/v3

Installation

$ npm install @meumobi/ngx-youtube-provider --save

Use

On app.module.js

...
import { YoutubeService, YoutubeModule } from '@meumobi/ngx-youtube-provider';

@NgModule({
  declarations: [...],
  imports: [
      YoutubeModule.forRoot(
      {
        apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        apiURL: 'https://www.googleapis.com/youtube/v3'
      }
    ),
    ...
  ],
  bootstrap: [...],
  entryComponents: [...],
  providers: [
    YoutubeService,
    ...
  ]
})
export class AppModule {}

your-component.module.ts

...
import { YoutubeService } from '@meumobi/ngx-youtube-provider';

@NgModule({
  declarations: [...],
  imports: [...],
  providers: [
    YoutubeService,
    ...
  ]
})
export class YoutComponentModule {}

you-component.ts

...
import { YoutubeService } from '@meumobi/ngx-youtube-provider';
@Component({
  selector: 'your-component',
  templateUrl: 'your-component',
})
export class YoutComponent  {

  constructor(
    private youtubeService: YoutubeService,
    ...
  ) {}

  fetchPlaylists(channelId: string) {
    this.youtubeService.fetchPlaylists(channelId)
    .then(
      data => console.log(data)
    );
  }

  fetchVideos(channelId: string, playlistId: string) {
    this.youtubeService.fetchVideos(channelId, playlistId)
    .then(
      data => console.log(data)
    );
  }

}

Functions

fetchPlaylists

It returns an array of all channel playlists.
If there is no playlist it returns [] this.youtubeService.fetchPlaylists(channelId)

  • channelId: string like UCZZPgUIorPao48a1tBYSDgg
    Playlist Object

fetchVideos

It returns an array of the latest 20 playlist vides.
If not pass a playlistId, it returns the latest 20 channel videos.
If there is no video on channel/playlist it returns [].
this.youtubeService.fetchVideos(channelId, playlistId)

  • channelId: string like UCZZPgUIorPao48a1tBYSDgg
  • playlistId: string like PLNFwX8PVq5q6CHLk0tLCiyh96nALzi3_x

Video Object

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    1
  • 0.0.1
    0

Package Sidebar

Install

npm i @meumobi/ngx-youtube-provider

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

21.2 kB

Total Files

24

Last publish

Collaborators

  • danconte72
  • vdias38