Coder Social home page Coder Social logo

claudebot / hubot-youtube-info Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 17 KB

:information_source: Show video metadata when YouTube URLs are seen. [Original: https://github.com/github/hubot-scripts/blob/master/src/scripts/youtube-info.coffee]

License: Other

JavaScript 16.83% CoffeeScript 73.45% Shell 9.72%

hubot-youtube-info's Issues

YouTube API v3

New API endpoint as the old one is deprecated:

GET https://www.googleapis.com/youtube/v3/videos?part=contentDetails%2Cstatistics%2Csnippet&id={VIDEO_ID_HERE}&key={YOUR_API_KEY}

It's part of the videos.list resource so it returns a list of items. Thus, to access the number of views for example:

data.items[0].statistics.viewCount

Assuming data is the fetched / parsed JSON from the API.

Sample return from API call:

{
 "kind": "youtube#videoListResponse",
 "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/FVju79dVVBMGXdQVZBiE9geOys8\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#video",
   "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/7-TwPYToOeOT84MVTtjy5cVvabc\"",
   "id": "tGx-u-Rmzws",
   "snippet": {
    "publishedAt": "2015-05-06T21:00:29.000Z",
    "channelId": "UC18NaGQLruOEw65eQE3bNbg",
    "title": "Dota 2 WTF Moments 115",
    "description": "Dota 2 fail/win compilation\nSubmit your clip / Manda tu video: \nhttp://dotawatafak.com/\n\nCheck out the WTF Tees:\nhttp://shrsl.com/?~8c3r\n\nFacebook\nhttps://www.facebook.com/DotaWatafak\n\nTwitter:\nhttps://twitter.com/Dota2WTF\n\n---------------\n\nLAST CLIP MUSIC\n\nTrack Name: OMFG - Hello\nVideo Link: https://www.youtube.com/watch?v=XRgiNUtJurk\nYoutube: https://www.youtube.com/channel/UCMkh-WZrlhqwh_m42ZQNe7g\nDownload: http://bit.ly/alexomfghello\nFacebook: https://www.facebook.com/alexomfg\nSoundCloud: https://soundcloud.com/alexomfg\nTwitter: https://twitter.com/AlexSavageOMFG",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/tGx-u-Rmzws/default.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/tGx-u-Rmzws/mqdefault.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/tGx-u-Rmzws/hqdefault.jpg",
      "width": 480,
      "height": 360
     },
     "standard": {
      "url": "https://i.ytimg.com/vi/tGx-u-Rmzws/sddefault.jpg",
      "width": 640,
      "height": 480
     },
     "maxres": {
      "url": "https://i.ytimg.com/vi/tGx-u-Rmzws/maxresdefault.jpg",
      "width": 1280,
      "height": 720
     }
    },
    "channelTitle": "Dota Watafak",
    "categoryId": "20",
    "liveBroadcastContent": "none",
    "localized": {
     "title": "Dota 2 WTF Moments 115",
     "description": "Dota 2 fail/win compilation\nSubmit your clip / Manda tu video: \nhttp://dotawatafak.com/\n\nCheck out the WTF Tees:\nhttp://shrsl.com/?~8c3r\n\nFacebook\nhttps://www.facebook.com/DotaWatafak\n\nTwitter:\nhttps://twitter.com/Dota2WTF\n\n---------------\n\nLAST CLIP MUSIC\n\nTrack Name: OMFG - Hello\nVideo Link: https://www.youtube.com/watch?v=XRgiNUtJurk\nYoutube: https://www.youtube.com/channel/UCMkh-WZrlhqwh_m42ZQNe7g\nDownload: http://bit.ly/alexomfghello\nFacebook: https://www.facebook.com/alexomfg\nSoundCloud: https://soundcloud.com/alexomfg\nTwitter: https://twitter.com/AlexSavageOMFG"
    }
   },
   "contentDetails": {
    "duration": "PT8M11S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true
   },
   "statistics": {
    "viewCount": "301",
    "likeCount": "5198",
    "dislikeCount": "36",
    "favoriteCount": "0",
    "commentCount": "364"
   }
  }
 ]
}

Migration notes:

  • contentDetails contains the video duration (in ISO6801 format).
  • statistics contains the views, likes / dislikes, favourites, comments.
  • snippet contains the title, description, etc.

More on properties: https://developers.google.com/youtube/v3/docs/videos

Package is invalid

Due to an error encountered in package.json, the repo is not seen as a valid package by NPM. This is preventing claudebot from using this script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.