•  


functions-samples/Node-1st-gen/youtube at main · firebase/functions-samples · GitHub
Skip to content

Latest commit

 

History

History

youtube

Folders and files

Name Name
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

YouTube: Get information about a YouTube channel

This quickstart demonstrates how to query the YouTube Data API using Cloud Functions for Firebase with an HTTPS trigger.

Introduction

The function getChannelInfo returns information about a Youtube channel. By default it will return information about the Firebase YouTube channel , but you can pass it a channelId URL Query parameter to query any channel you'd like.

Setup

Get a YouTube API Key

  1. Create a Firebase Project on the Firebase Console if you don't already have a project you want to use.
    1. Upgrade your Firebase project to the Blaze "pay as you go" plan
  2. Enable the Youtube API by visiting the API console , selecting your Firebase project, and clicking "ENABLE".
    1. Once the API is enabled, visit the credentials tab and click "CREATE CREDENTIALS" to create a YouTube API key.

Clone and configure the function

  1. Install the Firebase CLI and log in:
    npm install --global firebase-tools
    
    firebase login
    
  2. Clone or download this repo and open the youtube directory.
  3. cd into the functions directory and install dependencies with npm install
  4. Set up your Firebase project by running firebase use --add with the Firebase CLI, select your Project ID and follow the instructions.
  5. Set the YouTube API key as an environment variable:
    firebase functions:config:set youtube.key=
    "
    THE API KEY
    "
    

Run your function locally with the Firebase Emulator Suite

  1. Set up the Firebase emulators with your config ( docs ):
    cd
     functions
    
    firebase functions:config:get 
    >
     .runtimeconfig.json
    
  2. Run the following command to start the emulator:
    firebase emulators:start --only functions
    
  3. Check the emulator output to find the URL of the getChannelInfo function. It will looks something like http://localhost:5001/my-project-id/us-central1/getChannelInfo
  4. Via CURL or in your browser, visit the URL that the function is running at. Optionally, add a query string ?channelId=SOME_CHANNEL_ID to the end of the URL.
  5. You should get a JSON response with information about the YouTube channel!

Deploy the app to prod

Deploy to Firebase using the following command:

firebase deploy

This deploys and activates the getChannelInfo function.

The first time you call firebase deploy on a new project with Functions will take longer than usual.

Modify it to your needs

Now that you've got this sample working, modify it to work for your use case! Some ideas:

  • Check out the other things you can query with the YouTube Data API
  • Convert getChannelInfo function to a scheduled function, and write the new latest videos for a channel into Firestore or Realtime Database
  • ...anything else you can think of!
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본